diff options
Diffstat (limited to 'indent')
-rw-r--r-- | indent/blade.vim | 62 | ||||
-rw-r--r-- | indent/elixir.vim | 7 | ||||
-rw-r--r-- | indent/gohtmltmpl.vim | 5 | ||||
-rw-r--r-- | indent/perl.vim | 5 | ||||
-rw-r--r-- | indent/perl6.vim | 5 | ||||
-rw-r--r-- | indent/tex.vim | 12 | ||||
-rw-r--r-- | indent/typescript.vim | 10 |
7 files changed, 95 insertions, 11 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 diff --git a/indent/elixir.vim b/indent/elixir.vim index 92b98460..636097b7 100644 --- a/indent/elixir.vim +++ b/indent/elixir.vim @@ -25,6 +25,7 @@ let s:block_skip = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '" . s:s let s:block_start = 'do\|fn' let s:block_middle = 'else\|match\|elsif\|catch\|after\|rescue' let s:block_end = 'end' +let s:symbols_end = '\]\|}' let s:arrow = '^.*->$' let s:pipeline = '^\s*|>.*$' @@ -59,7 +60,11 @@ function! GetElixirIndent() let ind += opened_symbol * &sw - if current_line =~ '^\s*\(\]\|}\)' + if last_line =~ '^\s*\(' . s:symbols_end . '\)' + let ind += &sw + endif + + if current_line =~ '^\s*\(' . s:symbols_end . '\)' let ind -= &sw endif diff --git a/indent/gohtmltmpl.vim b/indent/gohtmltmpl.vim new file mode 100644 index 00000000..50399f2b --- /dev/null +++ b/indent/gohtmltmpl.vim @@ -0,0 +1,5 @@ +if exists("b:did_indent") + finish +endif + +runtime! indent/html.vim diff --git a/indent/perl.vim b/indent/perl.vim index 3ce3e59a..7d21d219 100644 --- a/indent/perl.vim +++ b/indent/perl.vim @@ -48,11 +48,6 @@ function! GetPerlIndent() return 0 endif - " Don't reindent comments on first column - if cline =~ '^#.' - return 0 - endif - " Get current syntax item at the line's first char let csynid = '' if b:indent_use_syntax diff --git a/indent/perl6.vim b/indent/perl6.vim index 161782e8..564ca81b 100644 --- a/indent/perl6.vim +++ b/indent/perl6.vim @@ -60,11 +60,6 @@ function! GetPerl6Indent() return 0 endif - " Don't reindent coments on first column - if cline =~ '^#' - return 0 - endif - " Get current syntax item at the line's first char let csynid = '' if b:indent_use_syntax diff --git a/indent/tex.vim b/indent/tex.vim index e7653d03..3abc44ba 100644 --- a/indent/tex.vim +++ b/indent/tex.vim @@ -101,9 +101,21 @@ function! Latexbox_CallIndent() let window = getpos('.') call setpos('.', cursor) + " Get first non-whitespace character of current line. + let line_start_char = matchstr(getline('.'), '\S') + + " Get initial tab position. + let initial_tab = stridx(getline('.'), line_start_char) + " Execute the command. execute 'normal! ==' + " Get tab position difference. + let difference = stridx(getline('.'), line_start_char) - initial_tab + + " Set new cursor Y position based on calculated difference. + let cursor[2] = cursor[2] + difference + " Restore the previous window position. call setpos('.', window) normal! zt diff --git a/indent/typescript.vim b/indent/typescript.vim index f498298b..78d04c5c 100644 --- a/indent/typescript.vim +++ b/indent/typescript.vim @@ -3,6 +3,10 @@ " Maintainer: None! Wanna improve this? " Last Change: 2015 Mar 07 +if get(g:, 'typescript_indent_disable') + finish +endif + " Only load this indent file when no other was loaded. if exists("b:did_indent") finish @@ -54,6 +58,12 @@ function GetTypescriptIndent() return indent(prev) endif + " If a variable was declared and the semicolon omitted, do not indent + " the next line + if getline(prev) =~ '^\s*var\s\+\w\+' + return indent(prev) + endif + " Try to find out whether the last `}` ended a `<variable> : {` block if getline(prev) =~ '};\s*$' " jump to matching `{` bracket |