diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-02-26 12:25:45 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-02-26 12:25:45 +0000 |
commit | c51cf0329809c7ae946c59d6f56699227efc9d1b (patch) | |
tree | 825302ef0857905dbf08dc584ef6d6a8aae27790 /runtime/indent | |
parent | e41c1dd8890d3f701253255993f4e9af2d12225c (diff) |
Update runtime files.
Diffstat (limited to 'runtime/indent')
-rw-r--r-- | runtime/indent/vim.vim | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim index 733584a67d..e1b7876ba3 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: 2021 Nov 27 +" Last Change: 2022 Feb 23 " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -10,7 +10,7 @@ endif let b:did_indent = 1 setlocal indentexpr=GetVimIndent() -setlocal indentkeys+==end,=},=else,=cat,=finall,=END,0\\,0=\"\\\ +setlocal indentkeys+==endif,=enddef,=endfu,=endfor,=endwh,=endtry,=},=else,=cat,=finall,=END,0\\,0=\"\\\ setlocal indentkeys-=0# setlocal indentkeys-=: @@ -103,8 +103,9 @@ function GetVimIndentIntern() " A line starting with :au does not increment/decrement indent. " A { may start a block or a dict. Assume that when a } follows it's a " terminated dict. + " ":function" starts a block but "function(" doesn't. if prev_text !~ '^\s*au\%[tocmd]' && prev_text !~ '^\s*{.*}' - let i = match(prev_text, '\(^\||\)\s*\(export\s\+\)\?\({\|\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\|finall\%[y]\|fu\%[nction]\|def\|el\%[seif]\)\>\)') + let i = match(prev_text, '\(^\||\)\s*\(export\s\+\)\?\({\|\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\|finall\%[y]\|def\|el\%[seif]\)\>\|fu\%[nction]\s\)') if i >= 0 let ind += shiftwidth() if strpart(prev_text, i, 1) == '|' && has('syntax_items') @@ -170,10 +171,15 @@ function GetVimIndentIntern() let ind = ind + shiftwidth() endif - " Subtract a 'shiftwidth' on a :endif, :endwhile, :catch, :finally, :endtry, - " :endfun, :enddef, :else and :augroup END. - if cur_text =~ '^\s*\(ene\@!\|cat\|finall\|el\|aug\%[roup]\s\+[eE][nN][dD]\)' + " Subtract a 'shiftwidth' on a :endif, :endwhile, :endfor, :catch, :finally, + " :endtry, :endfun, :enddef, :else and :augroup END. + " Although ":en" would be enough only match short command names as in + " 'indentkeys'. + if cur_text =~ '^\s*\(endif\|endwh\|endfor\|endtry\|endfu\|enddef\|cat\|finall\|else\|aug\%[roup]\s\+[eE][nN][dD]\)' let ind = ind - shiftwidth() + if ind < 0 + let ind = 0 + endif endif return ind |