diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-04-04 13:11:03 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-04-04 13:11:03 +0200 |
commit | 723dd946f94856be94a943876945fb1bd8169059 (patch) | |
tree | bbccfb567f3565a0a5bd2eb06b3c7e90181ef4ee /runtime/indent/sh.vim | |
parent | 7a66627cf43412604a28e0d99df8f96a29ff1c3a (diff) | |
download | vim-git-723dd946f94856be94a943876945fb1bd8169059.tar.gz |
Update runtime files.
Diffstat (limited to 'runtime/indent/sh.vim')
-rw-r--r-- | runtime/indent/sh.vim | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/runtime/indent/sh.vim b/runtime/indent/sh.vim index 0396b4eb9..32bc9f35b 100644 --- a/runtime/indent/sh.vim +++ b/runtime/indent/sh.vim @@ -3,13 +3,10 @@ " Maintainer: Christian Brabandt <cb@256bit.org> " Original Author: Nikolai Weibull <now@bitwi.se> " Previous Maintainer: Peter Aronoff <telemachus@arpinum.org> -" Latest Revision: 2019-02-02 +" Latest Revision: 2018-03-26 " License: Vim (see :h license) " Repository: https://github.com/chrisbra/vim-sh-indent " Changelog: -" 20190316 - Make use of searchpairpos for nested if sections -" fixes #11 -" 20190201 - Better check for closing if sections " 20180724 - make check for zsh syntax more rigid (needs word-boundaries) " 20180326 - better support for line continuation " 20180325 - better detection of function definitions @@ -62,7 +59,6 @@ function! s:indent_value(option) endfunction function! GetShIndent() - let curline = getline(v:lnum) let lnum = prevnonblank(v:lnum - 1) if lnum == 0 return 0 @@ -76,7 +72,7 @@ function! GetShIndent() " Check contents of previous lines if line =~ '^\s*\%(if\|then\|do\|else\|elif\|case\|while\|until\|for\|select\|foreach\)\>' || \ (&ft is# 'zsh' && line =~ '\<\%(if\|then\|do\|else\|elif\|case\|while\|until\|for\|select\|foreach\)\>') - if !s:is_end_expression(line) + if line !~ '\<\%(fi\|esac\|done\|end\)\>\s*\%(#.*\)\=$' let ind += s:indent_value('default') endif elseif s:is_case_label(line, pnum) @@ -94,10 +90,7 @@ function! GetShIndent() endif elseif s:end_block(line) && !s:start_block(line) let ind -= s:indent_value('default') - elseif pnum != 0 && - \ s:is_continuation_line(pline) && - \ !s:end_block(curline) && - \ !s:is_end_expression(curline) + elseif pnum != 0 && s:is_continuation_line(pline) && !s:end_block(getline(v:lnum)) " only add indent, if line and pline is in the same block let i = v:lnum let ind2 = indent(s:find_continued_lnum(pnum)) @@ -113,15 +106,8 @@ function! GetShIndent() let pine = line " Check content of current line - let line = curline - " Current line is a endif line, so get indent from start of "if condition" line - " TODO: should we do the same for other "end" lines? - if curline =~ '^\s*\%(fi\)\s*\%(#.*\)\=$' - let previous_line = searchpair('\<if\>', '', '\<fi\>', 'bnW') - if previous_line > 0 - let ind = indent(previous_line) - endif - elseif line =~ '^\s*\%(then\|do\|else\|elif\|done\|end\)\>' || s:end_block(line) + let line = getline(v:lnum) + if line =~ '^\s*\%(then\|do\|else\|elif\|fi\|done\|end\)\>' || s:end_block(line) let ind -= s:indent_value('default') elseif line =~ '^\s*esac\>' && s:is_case_empty(getline(v:lnum - 1)) let ind -= s:indent_value('default') @@ -224,8 +210,8 @@ endfunction function! s:is_here_doc(line) if a:line =~ '^\w\+$' - let here_pat = '<<-\?'. s:escape(a:line). '\$' - return search(here_pat, 'bnW') > 0 + let here_pat = '<<-\?'. s:escape(a:line). '\$' + return search(here_pat, 'bnW') > 0 endif return 0 endfunction @@ -270,9 +256,5 @@ function! s:is_comment(line) return a:line =~ '^\s*#' endfunction -function! s:is_end_expression(line) - return a:line =~ '\<\%(fi\|esac\|done\|end\)\>\s*\%(#.*\)\=$' -endfunction - let &cpo = s:cpo_save unlet s:cpo_save |