annotate runtime/indent/sh.vim @ 8668:9a56be645421

Added tag v7.4.1623 for changeset 8c80c21a1885e04204d2f6d02267c15d30ea8194
author Christian Brabandt <cb@256bit.org>
date Sun, 20 Mar 2016 19:45:04 +0100
parents f16bfe02cef1
children 619a98a67f67
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim indent file
7013
349e6c01f35d Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6918
diff changeset
2 " Language: Shell Script
349e6c01f35d Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6918
diff changeset
3 " Maintainer: Christian Brabandt <cb@256bit.org>
6918
2def7b25de60 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6153
diff changeset
4 " Previous Maintainer: Peter Aronoff <telemachus@arpinum.org>
7013
349e6c01f35d Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6918
diff changeset
5 " Original Author: Nikolai Weibull <now@bitwi.se>
8246
f16bfe02cef1 commit https://github.com/vim/vim/commit/f391327adbbffb11180cf6038a92af1ed144e907
Christian Brabandt <cb@256bit.org>
parents: 7924
diff changeset
6 " Latest Revision: 2016-02-15
7013
349e6c01f35d Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6918
diff changeset
7 " License: Vim (see :h license)
349e6c01f35d Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6918
diff changeset
8 " Repository: https://github.com/chrisbra/vim-sh-indent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 setlocal indentexpr=GetShIndent()
7013
349e6c01f35d Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6918
diff changeset
16 setlocal indentkeys+=0=then,0=do,0=else,0=elif,0=fi,0=esac,0=done,0=end,),0=;;,0=;&
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
17 setlocal indentkeys+=0=fin,0=fil,0=fip,0=fir,0=fix
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 setlocal indentkeys-=:,0#
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
19 setlocal nosmartindent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
8246
f16bfe02cef1 commit https://github.com/vim/vim/commit/f391327adbbffb11180cf6038a92af1ed144e907
Christian Brabandt <cb@256bit.org>
parents: 7924
diff changeset
21 let b:undo_indent = 'setlocal indentexpr< indentkeys< smartindent<'
f16bfe02cef1 commit https://github.com/vim/vim/commit/f391327adbbffb11180cf6038a92af1ed144e907
Christian Brabandt <cb@256bit.org>
parents: 7924
diff changeset
22
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 if exists("*GetShIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
27 let s:cpo_save = &cpo
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
28 set cpo&vim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
30 function s:buffer_shiftwidth()
7924
00d64eb49ce1 commit https://github.com/vim/vim/commit/681baaf4a4c81418693dcafb81421a8614832e91
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
31 return shiftwidth()
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
32 endfunction
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
33
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
34 let s:sh_indent_defaults = {
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
35 \ 'default': function('s:buffer_shiftwidth'),
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
36 \ 'continuation-line': function('s:buffer_shiftwidth'),
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
37 \ 'case-labels': function('s:buffer_shiftwidth'),
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
38 \ 'case-statements': function('s:buffer_shiftwidth'),
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
39 \ 'case-breaks': 0 }
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
40
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
41 function! s:indent_value(option)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
42 let Value = exists('b:sh_indent_options')
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
43 \ && has_key(b:sh_indent_options, a:option) ?
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
44 \ b:sh_indent_options[a:option] :
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
45 \ s:sh_indent_defaults[a:option]
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
46 if type(Value) == type(function('type'))
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
47 return Value()
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
48 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
49 return Value
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
50 endfunction
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
51
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
52 function! GetShIndent()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
58 let pnum = prevnonblank(lnum - 1)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
59
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 let line = getline(lnum)
7013
349e6c01f35d Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6918
diff changeset
62 if line =~ '^\s*\%(if\|then\|do\|else\|elif\|case\|while\|until\|for\|select\|foreach\)\>'
349e6c01f35d Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6918
diff changeset
63 if line !~ '\<\%(fi\|esac\|done\|end\)\>\s*\%(#.*\)\=$'
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
64 let ind += s:indent_value('default')
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
65 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
66 elseif s:is_case_label(line, pnum)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
67 if !s:is_case_ended(line)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
68 let ind += s:indent_value('case-statements')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 endif
8246
f16bfe02cef1 commit https://github.com/vim/vim/commit/f391327adbbffb11180cf6038a92af1ed144e907
Christian Brabandt <cb@256bit.org>
parents: 7924
diff changeset
70 elseif line =~ '^\s*\<\k\+\>\s*()\s*{' || line =~ '^\s*{' || line =~ '^\s*function\s*\w\S\+\s*\%(()\)\?\s*{'
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
71 if line !~ '}\s*\%(#.*\)\=$'
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
72 let ind += s:indent_value('default')
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
73 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
74 elseif s:is_continuation_line(line)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
75 if pnum == 0 || !s:is_continuation_line(getline(pnum))
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
76 let ind += s:indent_value('continuation-line')
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
77 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
78 elseif pnum != 0 && s:is_continuation_line(getline(pnum))
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
79 let ind = indent(s:find_continued_lnum(pnum))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
82 let pine = line
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 let line = getline(v:lnum)
7013
349e6c01f35d Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 6918
diff changeset
84 if line =~ '^\s*\%(then\|do\|else\|elif\|fi\|done\|end\)\>' || line =~ '^\s*}'
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
85 let ind -= s:indent_value('default')
5555
7818ca6de3d0 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
86 elseif line =~ '^\s*esac\>' && s:is_case_empty(getline(v:lnum - 1))
7818ca6de3d0 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
87 let ind -= s:indent_value('default')
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
88 elseif line =~ '^\s*esac\>'
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
89 let ind -= (s:is_case_label(pine, lnum) && s:is_case_ended(pine) ?
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
90 \ 0 : s:indent_value('case-statements')) +
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
91 \ s:indent_value('case-labels')
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
92 if s:is_case_break(pine)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
93 let ind += s:indent_value('case-breaks')
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
94 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
95 elseif s:is_case_label(line, lnum)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
96 if s:is_case(pine)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
97 let ind = indent(lnum) + s:indent_value('case-labels')
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
98 else
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5555
diff changeset
99 let ind -= (s:is_case_label(pine, lnum) && s:is_case_ended(pine) ?
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5555
diff changeset
100 \ 0 : s:indent_value('case-statements')) -
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5555
diff changeset
101 \ s:indent_value('case-breaks')
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
102 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
103 elseif s:is_case_break(line)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
104 let ind -= s:indent_value('case-breaks')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
110 function! s:is_continuation_line(line)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
111 return a:line =~ '\%(\%(^\|[^\\]\)\\\|&&\|||\)$'
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
112 endfunction
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
113
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
114 function! s:find_continued_lnum(lnum)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
115 let i = a:lnum
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
116 while i > 1 && s:is_continuation_line(getline(i - 1))
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
117 let i -= 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
118 endwhile
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
119 return i
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
120 endfunction
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
121
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
122 function! s:is_case_label(line, pnum)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
123 if a:line !~ '^\s*(\=.*)'
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
124 return 0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
125 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
126
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
127 if a:pnum > 0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
128 let pine = getline(a:pnum)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
129 if !(s:is_case(pine) || s:is_case_ended(pine))
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
130 return 0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
131 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
132 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
133
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
134 let suffix = substitute(a:line, '^\s*(\=', "", "")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
135 let nesting = 0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
136 let i = 0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
137 let n = strlen(suffix)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
138 while i < n
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
139 let c = suffix[i]
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
140 let i += 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
141 if c == '\\'
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
142 let i += 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
143 elseif c == '('
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
144 let nesting += 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
145 elseif c == ')'
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
146 if nesting == 0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
147 return 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
148 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
149 let nesting -= 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
150 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
151 endwhile
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
152 return 0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
153 endfunction
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
154
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
155 function! s:is_case(line)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
156 return a:line =~ '^\s*case\>'
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
157 endfunction
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
158
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
159 function! s:is_case_break(line)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
160 return a:line =~ '^\s*;[;&]'
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
161 endfunction
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
162
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
163 function! s:is_case_ended(line)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
164 return s:is_case_break(a:line) || a:line =~ ';[;&]\s*\%(#.*\)\=$'
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
165 endfunction
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 856
diff changeset
166
5555
7818ca6de3d0 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
167 function! s:is_case_empty(line)
7818ca6de3d0 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
168 if a:line =~ '^\s*$' || a:line =~ '^\s*#'
7818ca6de3d0 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
169 return s:is_case_empty(getline(v:lnum - 1))
7818ca6de3d0 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
170 else
7818ca6de3d0 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
171 return a:line =~ '^\s*case\>'
7818ca6de3d0 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
172 endif
7818ca6de3d0 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
173 endfunction
7818ca6de3d0 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
174
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
175 let &cpo = s:cpo_save
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
176 unlet s:cpo_save