diff options
author | Bram Moolenaar <Bram@vim.org> | 2014-09-19 22:38:48 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2014-09-19 22:38:48 +0200 |
commit | 91e15e13da0ec7825111133f0342288a47368d6e (patch) | |
tree | 351b68b49bf8447710e302db53c009639902794c /runtime/indent/vim.vim | |
parent | 3fa57e0d50d90248de9ad1867203b8ce6eedc92a (diff) |
Updated runtime files.
Diffstat (limited to 'runtime/indent/vim.vim')
-rw-r--r-- | runtime/indent/vim.vim | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim index 8c215733b3..ff4af027b4 100644 --- a/runtime/indent/vim.vim +++ b/runtime/indent/vim.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Vim script " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2012 Aug 02 +" Last Change: 2014 Sep 19 " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -37,7 +37,8 @@ function GetVimIndentIntern() " If the current line doesn't start with '\' and below a line that starts " with '\', use the indent of the line above it. - if getline(v:lnum) !~ '^\s*\\' + let cur_text = getline(v:lnum) + if cur_text !~ '^\s*\\' while lnum > 0 && getline(lnum) =~ '^\s*\\' let lnum = lnum - 1 endwhile @@ -47,27 +48,30 @@ function GetVimIndentIntern() if lnum == 0 return 0 endif + let prev_text = getline(lnum) " Add a 'shiftwidth' after :if, :while, :try, :catch, :finally, :function " and :else. Add it three times for a line that starts with '\' after " a line that doesn't (or g:vim_indent_cont if it exists). let ind = indent(lnum) - if getline(v:lnum) =~ '^\s*\\' && v:lnum > 1 && getline(lnum) !~ '^\s*\\' + if cur_text =~ '^\s*\\' && v:lnum > 1 && prev_text !~ '^\s*\\' if exists("g:vim_indent_cont") let ind = ind + g:vim_indent_cont else let ind = ind + &sw * 3 endif - elseif getline(lnum) =~ '^\s*aug\%[roup]' && getline(lnum) !~ '^\s*aug\%[roup]\s*!\=\s\+END' + elseif prev_text =~ '^\s*aug\%[roup]' && prev_text !~ '^\s*aug\%[roup]\s*!\=\s\+END' let ind = ind + &sw else - let line = getline(lnum) - let i = match(line, '\(^\||\)\s*\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\%[lly]\|fu\%[nction]\|el\%[seif]\)\>') - if i >= 0 - let ind += &sw - if strpart(line, i, 1) == '|' && has('syntax_items') - \ && synIDattr(synID(lnum, i, 1), "name") =~ '\(Comment\|String\)$' - let ind -= &sw + " A line starting with :au does not increment/decrement indent. + if prev_text !~ '^\s*au\%[tocmd]' + let i = match(prev_text, '\(^\||\)\s*\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\%[lly]\|fu\%[nction]\|el\%[seif]\)\>') + if i >= 0 + let ind += &sw + if strpart(prev_text, i, 1) == '|' && has('syntax_items') + \ && synIDattr(synID(lnum, i, 1), "name") =~ '\(Comment\|String\)$' + let ind -= &sw + endif endif endif endif @@ -75,9 +79,8 @@ function GetVimIndentIntern() " If the previous line contains an "end" after a pipe, but not in an ":au" " command. And not when there is a backslash before the pipe. " And when syntax HL is enabled avoid a match inside a string. - let line = getline(lnum) - let i = match(line, '[^\\]|\s*\(ene\@!\)') - if i > 0 && line !~ '^\s*au\%[tocmd]' + let i = match(prev_text, '[^\\]|\s*\(ene\@!\)') + if i > 0 && prev_text !~ '^\s*au\%[tocmd]' if !has('syntax_items') || synIDattr(synID(lnum, i + 2, 1), "name") !~ '\(Comment\|String\)$' let ind = ind - &sw endif @@ -86,7 +89,7 @@ function GetVimIndentIntern() " Subtract a 'shiftwidth' on a :endif, :endwhile, :catch, :finally, :endtry, " :endfun, :else and :augroup END. - if getline(v:lnum) =~ '^\s*\(ene\@!\|cat\|fina\|el\|aug\%[roup]\s*!\=\s\+END\)' + if cur_text =~ '^\s*\(ene\@!\|cat\|fina\|el\|aug\%[roup]\s*!\=\s\+END\)' let ind = ind - &sw endif |