summaryrefslogtreecommitdiffstats
path: root/indent/blade.vim
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2015-05-11 15:05:13 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2015-05-11 15:05:13 +0200
commit271b63d71707720ad0d35590b8cb50f8f8f43014 (patch)
tree1b71daa457afc68465f66ee2afc9a00c1380f23d /indent/blade.vim
parentacd7ce59503b22ac7663fc25776efe25e266f1d4 (diff)
downloadvim-polyglot-1.13.2.tar.gz
vim-polyglot-1.13.2.zip
Updatev1.13.2
Diffstat (limited to 'indent/blade.vim')
-rw-r--r--indent/blade.vim62
1 files changed, 62 insertions, 0 deletions
diff --git a/indent/blade.vim b/indent/blade.vim
new file mode 100644
index 00000000..7515a239
--- /dev/null
+++ b/indent/blade.vim
@@ -0,0 +1,62 @@
+" Language: Blade
+" Author: Barry Deeney <sitemaster16@gmail.com>
+" Version: 0.1
+" Description: BLADE indent file based on HTML indentation...
+
+" Check if this file has already been loaded
+if exists("b:did_indent")
+ finish
+endif
+
+" Include HTML
+runtime! indent/html.vim
+runtime! indent/php.vim
+silent! unlet b:did_indent
+
+" What function do we need to use to detect indentation?
+setlocal indentexpr=BladeIndent()
+
+" What keys would trigger indentation?
+setlocal indentkeys=o,O,<Return>,<>>,{,},!^F,0{,0},0),:,!^F,o,O,e,*<Return>,=?>,=<?,=*/
+
+" THE MAIN INDENT FUNCTION. Return the amount of indent for v:lnum.
+func! BladeIndent()
+ " What is the current line?
+ let current_line = v:lnum
+
+ " What is the current text?
+ let current_text = tolower(getline(current_line))
+
+ " What was the last non blank line?
+ let previous_line = prevnonblank(current_line)
+
+ " What was the last non blank text?
+ let previous_text = tolower(getline(previous_line))
+
+ " How large are indents??
+ let indent_size = &sw
+
+ " Check if we have a PHPIndent value...
+ let indent = GetPhpIndent()
+
+ " check if we have indent
+ if indent == -1
+ " Check if we have BLADE
+ if current_text =~ '^\s*@' || previous_text =~ '^\s*@'
+ " We need to add to the indent
+ return indent_size * indent(previous_text)
+ endif
+
+ " Check if we have HTML
+ if current_text =~ '^\s*<' || previous_text =~ '^\s*<'
+ " We now give the honors to HtmlIndent()
+ let indent = HtmlIndent()
+ endif
+ endif
+
+ " Give the indent back!
+ return indent
+endfunc
+
+" Make sure we store that flag!
+let b:did_indent = 1