annotate runtime/indent/nsis.vim @ 35198:8cb8025670aa default tip

Added tag v9.1.0418 for changeset ffa6ed03a9f2718c1c898c53de7dfe0860986ae3
author Christian Brabandt <cb@256bit.org>
date Fri, 17 May 2024 19:00:05 +0200
parents d46f974fd69e
children
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
26050
ebedba7a4898 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13125
diff changeset
5 " Last Change: 2021-10-18
13125
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
32974
d46f974fd69e runtime: Fix typos in various files
Christian Brabandt <cb@256bit.org>
parents: 26050
diff changeset
18 setlocal indentkeys+==~${Else,=~${EndIf,=~${EndUnless,=~${AndIf,=~${AndUnless,=~${OrIf,=~${OrUnless,=~${Case,=~${Default,=~${EndSelect,=~${EndSwitch,=~${Loop,=~${Next,=~${MementoSectionEnd,=~FunctionEnd,=~SectionEnd,=~SectionGroupEnd,=~PageExEnd,0=~!macroend,0=~!if,0=~!else,0=~!endif
13125
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19
26050
ebedba7a4898 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13125
diff changeset
20 let b:undo_indent = "setl ai< inde< indk< si<"
ebedba7a4898 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13125
diff changeset
21
13125
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 if exists("*GetNsisIndent")
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 finish
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 function! GetNsisIndent(lnum)
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 " 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
28 " line it up with that one, otherwise add two 'shiftwidth'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 if getline(a:lnum - 1) =~ '\\$'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 if a:lnum > 1 && getline(a:lnum - 2) =~ '\\$'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 return indent(a:lnum - 1)
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 return indent(a:lnum - 1) + shiftwidth() * 2
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 " Grab the current line, stripping comments.
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 let l:thisl = substitute(getline(a:lnum), '[;#].*$', '', '')
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 " Check if this line is a conditional preprocessor line.
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 let l:preproc = l:thisl =~? '^\s*!\%(if\|else\|endif\)'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 " Grab the previous line, stripping comments.
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 " Skip preprocessor lines and continued lines.
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 let l:prevlnum = a:lnum
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 while 1
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 let l:prevlnum = prevnonblank(l:prevlnum - 1)
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 if l:prevlnum == 0
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 " top of file
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 return 0
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 let l:prevl = substitute(getline(l:prevlnum), '[;#].*$', '', '')
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 let l:prevpreproc = l:prevl =~? '^\s*!\%(if\|else\|endif\)'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 if l:preproc == l:prevpreproc && getline(l:prevlnum - 1) !~? '\\$'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 break
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 endwhile
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 let l:previ = indent(l:prevlnum)
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 let l:ind = l:previ
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 if l:preproc
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 " conditional preprocessor
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 if l:prevl =~? '^\s*!\%(if\%(\%(macro\)\?n\?def\)\?\|else\)\>'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 let l:ind += shiftwidth()
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 if l:thisl =~? '^\s*!\%(else\|endif\)\?\>'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 let l:ind -= shiftwidth()
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 return l:ind
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 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
71 " previous line opened a block
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 let l:ind += shiftwidth()
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 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
75 " this line closed a block
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 let l:ind -= shiftwidth()
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 elseif l:thisl =~? '^\s*\${\%(Case\|Case[2-5]\|CaseElse\|Default\)\>}\?'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 if l:prevl !~? '^\s*\${\%(Select\|Switch\)}'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 let l:ind -= shiftwidth()
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 elseif l:thisl =~? '^\s*\${\%(EndSelect\|EndSwitch\)\>}\?'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 " this line closed a block
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 if l:prevl =~? '^\s*\${\%(Select\|Switch\)}'
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 let l:ind -= shiftwidth()
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 else
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 let l:ind -= shiftwidth() * 2
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 return l:ind
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 endfunction
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 " vim: ts=8 sw=2 sts=2