annotate runtime/indent/vim.vim @ 28447:6f753a8125f0 v8.2.4748

patch 8.2.4748: cannot use an imported function in a mapping Commit: https://github.com/vim/vim/commit/8944551534b311a2d25acf6e8db235c6d906256c Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 14 12:58:23 2022 +0100 patch 8.2.4748: cannot use an imported function in a mapping Problem: Cannot use an imported function in a mapping. Solution: Recognize <SID>name.Func.
author Bram Moolenaar <Bram@vim.org>
date Thu, 14 Apr 2022 14:00:05 +0200
parents c968191a8557
children d314efe6447a
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: Vim script
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Maintainer: Bram Moolenaar <Bram@vim.org>
28010
c968191a8557 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27903
diff changeset
4 " Last Change: 2022 Mar 01
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 setlocal indentexpr=GetVimIndent()
27903
d19b7aee1925 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
13 setlocal indentkeys+==endif,=enddef,=endfu,=endfor,=endwh,=endtry,=},=else,=cat,=finall,=END,0\\,0=\"\\\
21499
3a1ed539ae2a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
14 setlocal indentkeys-=0#
26438
c725b8e17f1f Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 26100
diff changeset
15 setlocal indentkeys-=:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3557
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
17 let b:undo_indent = "setl indentkeys< indentexpr<"
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
18
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 if exists("*GetVimIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 endif
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2729
diff changeset
23 let s:keepcpo= &cpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2729
diff changeset
24 set cpo&vim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 function GetVimIndent()
3750
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3557
diff changeset
27 let ignorecase_save = &ignorecase
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3557
diff changeset
28 try
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3557
diff changeset
29 let &ignorecase = 0
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3557
diff changeset
30 return GetVimIndentIntern()
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3557
diff changeset
31 finally
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3557
diff changeset
32 let &ignorecase = ignorecase_save
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3557
diff changeset
33 endtry
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3557
diff changeset
34 endfunc
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3557
diff changeset
35
14714
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 9407
diff changeset
36 let s:lineContPat = '^\s*\(\\\|"\\ \)'
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 9407
diff changeset
37
3750
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3557
diff changeset
38 function GetVimIndentIntern()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 " Find a non-blank line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41
23737
34b4eb3a8458 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23573
diff changeset
42 " The previous line, ignoring line continuation
34b4eb3a8458 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23573
diff changeset
43 let prev_text_end = lnum > 0 ? getline(lnum) : ''
34b4eb3a8458 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23573
diff changeset
44
14714
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 9407
diff changeset
45 " If the current line doesn't start with '\' or '"\ ' and below a line that
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 9407
diff changeset
46 " starts with '\' or '"\ ', use the indent of the line above it.
6238
47b1887483da Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
47 let cur_text = getline(v:lnum)
14714
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 9407
diff changeset
48 if cur_text !~ s:lineContPat
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 9407
diff changeset
49 while lnum > 0 && getline(lnum) =~ s:lineContPat
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 let lnum = lnum - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 " At the start of the file use zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 endif
23737
34b4eb3a8458 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23573
diff changeset
58
34b4eb3a8458 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23573
diff changeset
59 " the start of the previous line, skipping over line continuation
6238
47b1887483da Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
60 let prev_text = getline(lnum)
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
61 let found_cont = 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " Add a 'shiftwidth' after :if, :while, :try, :catch, :finally, :function
14714
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 9407
diff changeset
64 " and :else. Add it three times for a line that starts with '\' or '"\ '
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 9407
diff changeset
65 " after a line that doesn't (or g:vim_indent_cont if it exists).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 let ind = indent(lnum)
18489
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
67
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
68 " In heredoc indenting works completely differently.
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
69 if has('syntax_items')
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
70 let syn_here = synIDattr(synID(v:lnum, 1, 1), "name")
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
71 if syn_here =~ 'vimLetHereDocStop'
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
72 " End of heredoc: use indent of matching start line
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
73 let lnum = v:lnum - 1
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
74 while lnum > 0
24520
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24024
diff changeset
75 let attr = synIDattr(synID(lnum, 1, 1), "name")
5bda4653aced Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24024
diff changeset
76 if attr != '' && attr !~ 'vimLetHereDoc'
18489
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
77 return indent(lnum)
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
78 endif
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
79 let lnum -= 1
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
80 endwhile
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
81 return 0
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
82 endif
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
83 if syn_here =~ 'vimLetHereDoc'
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
84 if synIDattr(synID(lnum, 1, 1), "name") !~ 'vimLetHereDoc'
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
85 " First line in heredoc: increase indent
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
86 return ind + shiftwidth()
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
87 endif
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
88 " Heredoc continues: no change in indent
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
89 return ind
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
90 endif
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
91 endif
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14714
diff changeset
92
14714
bdbb049c2aa8 patch 8.1.0369: continuation lines cannot contain comments
Christian Brabandt <cb@256bit.org>
parents: 9407
diff changeset
93 if cur_text =~ s:lineContPat && v:lnum > 1 && prev_text !~ s:lineContPat
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
94 let found_cont = 1
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 7
diff changeset
95 if exists("g:vim_indent_cont")
cc049b00ee70 updated for version 7.0014
vimboss
parents: 7
diff changeset
96 let ind = ind + g:vim_indent_cont
cc049b00ee70 updated for version 7.0014
vimboss
parents: 7
diff changeset
97 else
7742
5f6f35a3cb12 commit https://github.com/vim/vim/commit/705ada1aff27ecd9c47c690df817d043c2ceb5e2
Christian Brabandt <cb@256bit.org>
parents: 6447
diff changeset
98 let ind = ind + shiftwidth() * 3
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 7
diff changeset
99 endif
9407
619a98a67f67 commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents: 8951
diff changeset
100 elseif prev_text =~ '^\s*aug\%[roup]\s\+' && prev_text !~ '^\s*aug\%[roup]\s\+[eE][nN][dD]\>'
7742
5f6f35a3cb12 commit https://github.com/vim/vim/commit/705ada1aff27ecd9c47c690df817d043c2ceb5e2
Christian Brabandt <cb@256bit.org>
parents: 6447
diff changeset
101 let ind = ind + shiftwidth()
2729
12f838be9c59 Updated runtime file. Fix Italian translations.
Bram Moolenaar <bram@vim.org>
parents: 395
diff changeset
102 else
6238
47b1887483da Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
103 " A line starting with :au does not increment/decrement indent.
23931
5b37a0bf7e3a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 23737
diff changeset
104 " A { may start a block or a dict. Assume that when a } follows it's a
5b37a0bf7e3a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 23737
diff changeset
105 " terminated dict.
27903
d19b7aee1925 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
106 " ":function" starts a block but "function(" doesn't.
23931
5b37a0bf7e3a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 23737
diff changeset
107 if prev_text !~ '^\s*au\%[tocmd]' && prev_text !~ '^\s*{.*}'
28010
c968191a8557 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27903
diff changeset
108 let i = match(prev_text, '\(^\||\)\s*\(export\s\+\)\?\({\|\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\|finall\%[y]\|def\|el\%[seif]\)\>\|fu\%[nction][! ]\)')
6238
47b1887483da Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
109 if i >= 0
7742
5f6f35a3cb12 commit https://github.com/vim/vim/commit/705ada1aff27ecd9c47c690df817d043c2ceb5e2
Christian Brabandt <cb@256bit.org>
parents: 6447
diff changeset
110 let ind += shiftwidth()
6238
47b1887483da Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
111 if strpart(prev_text, i, 1) == '|' && has('syntax_items')
26100
babd9f1dbe12 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24520
diff changeset
112 \ && synIDattr(synID(lnum, i, 1), "name") =~ '\(Comment\|String\|PatSep\)$'
7742
5f6f35a3cb12 commit https://github.com/vim/vim/commit/705ada1aff27ecd9c47c690df817d043c2ceb5e2
Christian Brabandt <cb@256bit.org>
parents: 6447
diff changeset
113 let ind -= shiftwidth()
6238
47b1887483da Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
114 endif
2729
12f838be9c59 Updated runtime file. Fix Italian translations.
Bram Moolenaar <bram@vim.org>
parents: 395
diff changeset
115 endif
12f838be9c59 Updated runtime file. Fix Italian translations.
Bram Moolenaar <bram@vim.org>
parents: 395
diff changeset
116 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 " If the previous line contains an "end" after a pipe, but not in an ":au"
333
18f024844150 updated for version 7.0086
vimboss
parents: 170
diff changeset
120 " command. And not when there is a backslash before the pipe.
395
339c55711247 updated for version 7.0104
vimboss
parents: 333
diff changeset
121 " And when syntax HL is enabled avoid a match inside a string.
6238
47b1887483da Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
122 let i = match(prev_text, '[^\\]|\s*\(ene\@!\)')
47b1887483da Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
123 if i > 0 && prev_text !~ '^\s*au\%[tocmd]'
395
339c55711247 updated for version 7.0104
vimboss
parents: 333
diff changeset
124 if !has('syntax_items') || synIDattr(synID(lnum, i + 2, 1), "name") !~ '\(Comment\|String\)$'
7742
5f6f35a3cb12 commit https://github.com/vim/vim/commit/705ada1aff27ecd9c47c690df817d043c2ceb5e2
Christian Brabandt <cb@256bit.org>
parents: 6447
diff changeset
125 let ind = ind - shiftwidth()
395
339c55711247 updated for version 7.0104
vimboss
parents: 333
diff changeset
126 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
129 " For a line starting with "}" find the matching "{". If it is at the start
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
130 " of the line align with it, probably end of a block.
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
131 " Use the mapped "%" from matchit to find the match, otherwise we may match
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
132 " a { inside a comment or string.
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
133 if cur_text =~ '^\s*}'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
134 if maparg('%') != ''
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
135 exe v:lnum
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
136 silent! normal %
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
137 if line('.') < v:lnum && getline('.') =~ '^\s*{'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
138 let ind = indent('.')
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
139 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
140 else
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
141 " todo: use searchpair() to find a match
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
142 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
143 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
144
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
145 " Below a line starting with "}" find the matching "{". If it is at the
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
146 " end of the line we must be below the end of a dictionary.
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
147 if prev_text =~ '^\s*}'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
148 if maparg('%') != ''
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
149 exe lnum
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
150 silent! normal %
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
151 if line('.') == lnum || getline('.') !~ '^\s*{'
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
152 let ind = ind - shiftwidth()
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
153 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
154 else
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
155 " todo: use searchpair() to find a match
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
156 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
157 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
158
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
159 " Below a line starting with "]" we must be below the end of a list.
23931
5b37a0bf7e3a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 23737
diff changeset
160 " Include a "}" and "},} in case a dictionary ends too.
5b37a0bf7e3a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 23737
diff changeset
161 if prev_text_end =~ '^\s*\(},\=\s*\)\=]'
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
162 let ind = ind - shiftwidth()
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
163 endif
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
164
23931
5b37a0bf7e3a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 23737
diff changeset
165 let ends_in_comment = has('syntax_items')
24024
ef454a7f485d Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23931
diff changeset
166 \ && synIDattr(synID(lnum, len(getline(lnum)), 1), "name") =~ '\(Comment\|String\)$'
23931
5b37a0bf7e3a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 23737
diff changeset
167
24024
ef454a7f485d Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 23931
diff changeset
168 " A line ending in "{" or "[" is most likely the start of a dict/list literal,
23931
5b37a0bf7e3a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 23737
diff changeset
169 " indent the next line more. Not for a continuation line or {{{.
5b37a0bf7e3a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 23737
diff changeset
170 if !ends_in_comment && prev_text_end =~ '\s[{[]\s*$' && !found_cont
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
171 let ind = ind + shiftwidth()
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 22441
diff changeset
172 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173
27903
d19b7aee1925 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
174 " Subtract a 'shiftwidth' on a :endif, :endwhile, :endfor, :catch, :finally,
d19b7aee1925 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
175 " :endtry, :endfun, :enddef, :else and :augroup END.
d19b7aee1925 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
176 " Although ":en" would be enough only match short command names as in
d19b7aee1925 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
177 " 'indentkeys'.
d19b7aee1925 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
178 if cur_text =~ '^\s*\(endif\|endwh\|endfor\|endtry\|endfu\|enddef\|cat\|finall\|else\|aug\%[roup]\s\+[eE][nN][dD]\)'
7742
5f6f35a3cb12 commit https://github.com/vim/vim/commit/705ada1aff27ecd9c47c690df817d043c2ceb5e2
Christian Brabandt <cb@256bit.org>
parents: 6447
diff changeset
179 let ind = ind - shiftwidth()
27903
d19b7aee1925 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
180 if ind < 0
d19b7aee1925 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
181 let ind = 0
d19b7aee1925 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
182 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2729
diff changeset
188 let &cpo = s:keepcpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2729
diff changeset
189 unlet s:keepcpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2729
diff changeset
190
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 " vim:sw=2