annotate runtime/indent/nsis.vim @ 25954:336f67070095

Added tag v8.2.3510 for changeset d7e1cf30728cc8a3111b2cc1f1e7aa6248392f7b
author Bram Moolenaar <Bram@vim.org>
date Thu, 14 Oct 2021 22:30:05 +0200
parents 371ceeebbdaa
children ebedba7a4898
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13125
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Vim indent file
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " Language: NSIS script
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " Maintainer: Ken Takata
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 " URL: https://github.com/k-takata/vim-nsis
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 " Last Change: 2018-01-21
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 " Filenames: *.nsi
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 " License: VIM License
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 if exists("b:did_indent")
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 finish
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 let b:did_indent = 1
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 setlocal nosmartindent
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 setlocal noautoindent
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 setlocal indentexpr=GetNsisIndent(v:lnum)
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 setlocal indentkeys=!^F,o,O
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 setlocal indentkeys+==~${Else,=~${EndIf,=~${EndUnless,=~${AndIf,=~${AndUnless,=~${OrIf,=~${OrUnless,=~${Case,=~${Default,=~${EndSelect,=~${EndSwith,=~${Loop,=~${Next,=~${MementoSectionEnd,=~FunctionEnd,=~SectionEnd,=~SectionGroupEnd,=~PageExEnd,0=~!macroend,0=~!if,0=~!else,0=~!endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 if exists("*GetNsisIndent")
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 finish
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 function! GetNsisIndent(lnum)
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 " If this line is explicitly joined: If the previous line was also joined,
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 " line it up with that one, otherwise add two 'shiftwidth'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 if getline(a:lnum - 1) =~ '\\$'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 if a:lnum > 1 && getline(a:lnum - 2) =~ '\\$'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 return indent(a:lnum - 1)
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 return indent(a:lnum - 1) + shiftwidth() * 2
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 " Grab the current line, stripping comments.
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 let l:thisl = substitute(getline(a:lnum), '[;#].*$', '', '')
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 " Check if this line is a conditional preprocessor line.
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 let l:preproc = l:thisl =~? '^\s*!\%(if\|else\|endif\)'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 " Grab the previous line, stripping comments.
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 " Skip preprocessor lines and continued lines.
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 let l:prevlnum = a:lnum
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 while 1
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 let l:prevlnum = prevnonblank(l:prevlnum - 1)
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 if l:prevlnum == 0
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 " top of file
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 return 0
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 let l:prevl = substitute(getline(l:prevlnum), '[;#].*$', '', '')
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 let l:prevpreproc = l:prevl =~? '^\s*!\%(if\|else\|endif\)'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 if l:preproc == l:prevpreproc && getline(l:prevlnum - 1) !~? '\\$'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 break
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 endwhile
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 let l:previ = indent(l:prevlnum)
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 let l:ind = l:previ
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 if l:preproc
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 " conditional preprocessor
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 if l:prevl =~? '^\s*!\%(if\%(\%(macro\)\?n\?def\)\?\|else\)\>'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 let l:ind += shiftwidth()
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 if l:thisl =~? '^\s*!\%(else\|endif\)\?\>'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 let l:ind -= shiftwidth()
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 return l:ind
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 if l:prevl =~? '^\s*\%(\${\%(If\|IfNot\|Unless\|ElseIf\|ElseIfNot\|ElseUnless\|Else\|AndIf\|AndIfNot\|AndUnless\|OrIf\|OrIfNot\|OrUnless\|Select\|Case\|Case[2-5]\|CaseElse\|Default\|Switch\|Do\|DoWhile\|DoUntil\|For\|ForEach\|MementoSection\)}\|Function\>\|Section\>\|SectionGroup\|PageEx\>\|!macro\>\)'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 " previous line opened a block
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 let l:ind += shiftwidth()
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 if l:thisl =~? '^\s*\%(\${\%(ElseIf\|ElseIfNot\|ElseUnless\|Else\|EndIf\|EndUnless\|AndIf\|AndIfNot\|AndUnless\|OrIf\|OrIfNot\|OrUnless\|Loop\|LoopWhile\|LoopUntil\|Next\|MementoSectionEnd\)\>}\?\|FunctionEnd\>\|SectionEnd\>\|SectionGroupEnd\|PageExEnd\>\|!macroend\>\)'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 " this line closed a block
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 let l:ind -= shiftwidth()
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 elseif l:thisl =~? '^\s*\${\%(Case\|Case[2-5]\|CaseElse\|Default\)\>}\?'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 if l:prevl !~? '^\s*\${\%(Select\|Switch\)}'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 let l:ind -= shiftwidth()
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 elseif l:thisl =~? '^\s*\${\%(EndSelect\|EndSwitch\)\>}\?'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 " this line closed a block
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 if l:prevl =~? '^\s*\${\%(Select\|Switch\)}'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 let l:ind -= shiftwidth()
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 else
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 let l:ind -= shiftwidth() * 2
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 return l:ind
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 endfunction
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 " vim: ts=8 sw=2 sts=2