Mercurial > vim
comparison runtime/indent/sh.vim @ 7013:349e6c01f35d
Update runtime files.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 11 Aug 2015 20:34:49 +0200 |
parents | 2def7b25de60 |
children | aea5ebf352c4 |
comparison
equal
deleted
inserted
replaced
7012:0175e7cfea2e | 7013:349e6c01f35d |
---|---|
1 " Vim indent file | 1 " Vim indent file |
2 " Language: Shell Script | 2 " Language: Shell Script |
3 " Maintainer: Currently unmaintained. If you want to take it, please | 3 " Maintainer: Christian Brabandt <cb@256bit.org> |
4 " email Bram | |
5 " Previous Maintainer: Peter Aronoff <telemachus@arpinum.org> | 4 " Previous Maintainer: Peter Aronoff <telemachus@arpinum.org> |
6 " Original Author: Nikolai Weibull <now@bitwi.se> | 5 " Original Author: Nikolai Weibull <now@bitwi.se> |
7 " Latest Revision: 2014-08-22 | 6 " Latest Revision: 2015-07-28 |
7 " License: Vim (see :h license) | |
8 " Repository: https://github.com/chrisbra/vim-sh-indent | |
8 | 9 |
9 if exists("b:did_indent") | 10 if exists("b:did_indent") |
10 finish | 11 finish |
11 endif | 12 endif |
12 let b:did_indent = 1 | 13 let b:did_indent = 1 |
13 | 14 |
14 setlocal indentexpr=GetShIndent() | 15 setlocal indentexpr=GetShIndent() |
15 setlocal indentkeys+=0=then,0=do,0=else,0=elif,0=fi,0=esac,0=done,),0=;;,0=;& | 16 setlocal indentkeys+=0=then,0=do,0=else,0=elif,0=fi,0=esac,0=done,0=end,),0=;;,0=;& |
16 setlocal indentkeys+=0=fin,0=fil,0=fip,0=fir,0=fix | 17 setlocal indentkeys+=0=fin,0=fil,0=fip,0=fir,0=fix |
17 setlocal indentkeys-=:,0# | 18 setlocal indentkeys-=:,0# |
18 setlocal nosmartindent | 19 setlocal nosmartindent |
19 | 20 |
20 if exists("*GetShIndent") | 21 if exists("*GetShIndent") |
54 | 55 |
55 let pnum = prevnonblank(lnum - 1) | 56 let pnum = prevnonblank(lnum - 1) |
56 | 57 |
57 let ind = indent(lnum) | 58 let ind = indent(lnum) |
58 let line = getline(lnum) | 59 let line = getline(lnum) |
59 if line =~ '^\s*\%(if\|then\|do\|else\|elif\|case\|while\|until\|for\|select\)\>' | 60 if line =~ '^\s*\%(if\|then\|do\|else\|elif\|case\|while\|until\|for\|select\|foreach\)\>' |
60 if line !~ '\<\%(fi\|esac\|done\)\>\s*\%(#.*\)\=$' | 61 if line !~ '\<\%(fi\|esac\|done\|end\)\>\s*\%(#.*\)\=$' |
61 let ind += s:indent_value('default') | 62 let ind += s:indent_value('default') |
62 endif | 63 endif |
63 elseif s:is_case_label(line, pnum) | 64 elseif s:is_case_label(line, pnum) |
64 if !s:is_case_ended(line) | 65 if !s:is_case_ended(line) |
65 let ind += s:indent_value('case-statements') | 66 let ind += s:indent_value('case-statements') |
76 let ind = indent(s:find_continued_lnum(pnum)) | 77 let ind = indent(s:find_continued_lnum(pnum)) |
77 endif | 78 endif |
78 | 79 |
79 let pine = line | 80 let pine = line |
80 let line = getline(v:lnum) | 81 let line = getline(v:lnum) |
81 if line =~ '^\s*\%(then\|do\|else\|elif\|fi\|done\)\>' || line =~ '^\s*}' | 82 if line =~ '^\s*\%(then\|do\|else\|elif\|fi\|done\|end\)\>' || line =~ '^\s*}' |
82 let ind -= s:indent_value('default') | 83 let ind -= s:indent_value('default') |
83 elseif line =~ '^\s*esac\>' && s:is_case_empty(getline(v:lnum - 1)) | 84 elseif line =~ '^\s*esac\>' && s:is_case_empty(getline(v:lnum - 1)) |
84 let ind -= s:indent_value('default') | 85 let ind -= s:indent_value('default') |
85 elseif line =~ '^\s*esac\>' | 86 elseif line =~ '^\s*esac\>' |
86 let ind -= (s:is_case_label(pine, lnum) && s:is_case_ended(pine) ? | 87 let ind -= (s:is_case_label(pine, lnum) && s:is_case_ended(pine) ? |