annotate runtime/indent/zimbu.vim @ 34205:b629e912b0fb v9.1.0051

patch 9.1.0051: MS-Windows: Key event test fail Commit: https://github.com/vim/vim/commit/f6ebaa7ae64edbe2e56d65c2a3f2494301d11acb Author: Christian Brabandt <cb@256bit.org> Date: Thu Jan 25 20:44:49 2024 +0100 patch 9.1.0051: MS-Windows: Key event test fail Problem: MS-Windows: Key event test fail (after 9.1.0050) Solution: Catch Interrupt and return Ctrl-C Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Thu, 25 Jan 2024 21:00:04 +0100
parents 4027cefc2aab
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3513
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1 " Vim indent file
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2 " Language: Zimbu
32770
4027cefc2aab Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents: 25880
diff changeset
3 " Maintainer: The Vim Project <https://github.com/vim/vim>
4027cefc2aab Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents: 25880
diff changeset
4 " Last Change: 2023 Aug 10
4027cefc2aab Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents: 25880
diff changeset
5 " Former Maintainer: Bram Moolenaar <Bram@vim.org>
3513
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7 " Only load this indent file when no other was loaded.
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8 if exists("b:did_indent")
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
9 finish
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
10 endif
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11 let b:did_indent = 1
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 setlocal ai nolisp nocin
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14 setlocal indentexpr=GetZimbuIndent(v:lnum)
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 setlocal indentkeys=0{,0},!^F,o,O,0=ELSE,0=ELSEIF,0=CASE,0=DEFAULT,0=FINALLY
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17 " We impose recommended defaults: no Tabs, 'shiftwidth' = 2
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18 setlocal sw=2 et
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
19
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 7790
diff changeset
20 let b:undo_indent = "setl ai< cin< et< indentkeys< indentexpr< lisp< sw<"
3513
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
21
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
22 " Only define the function once.
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
23 if exists("*GetZimbuIndent")
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
24 finish
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
25 endif
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3513
diff changeset
27 let s:cpo_save = &cpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3513
diff changeset
28 set cpo&vim
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3513
diff changeset
29
3513
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
30 " Come here when loading the script the first time.
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
31
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
32 let s:maxoff = 50 " maximum number of lines to look backwards for ()
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
33
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
34 func GetZimbuIndent(lnum)
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
35 let prevLnum = prevnonblank(a:lnum - 1)
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
36 if prevLnum == 0
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
37 " This is the first non-empty line, use zero indent.
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
38 return 0
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
39 endif
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
40
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
41 " Taken from Python indenting:
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
42 " If the previous line is inside parenthesis, use the indent of the starting
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
43 " line.
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
44 " Trick: use the non-existing "dummy" variable to break out of the loop when
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
45 " going too far back.
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
46 call cursor(prevLnum, 1)
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
47 let parlnum = searchpair('(\|{\|\[', '', ')\|}\|\]', 'nbW',
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
48 \ "line('.') < " . (prevLnum - s:maxoff) . " ? dummy :"
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
49 \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
50 \ . " =~ '\\(Comment\\|String\\|Char\\)$'")
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
51 if parlnum > 0
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
52 let plindent = indent(parlnum)
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
53 let plnumstart = parlnum
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
54 else
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
55 let plindent = indent(prevLnum)
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
56 let plnumstart = prevLnum
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
57 endif
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
58
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
59
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
60 " When inside parenthesis: If at the first line below the parenthesis add
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
61 " two 'shiftwidth', otherwise same as previous line.
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
62 " i = (a
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
63 " + b
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
64 " + c)
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
65 call cursor(a:lnum, 1)
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
66 let p = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW',
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
67 \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
68 \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
69 \ . " =~ '\\(Comment\\|String\\|Char\\)$'")
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
70 if p > 0
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
71 if p == prevLnum
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
72 " When the start is inside parenthesis, only indent one 'shiftwidth'.
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
73 let pp = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW',
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
74 \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
75 \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
76 \ . " =~ '\\(Comment\\|String\\|Char\\)$'")
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
77 if pp > 0
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 3830
diff changeset
78 return indent(prevLnum) + shiftwidth()
3513
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
79 endif
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 3830
diff changeset
80 return indent(prevLnum) + shiftwidth() * 2
3513
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
81 endif
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
82 if plnumstart == p
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
83 return indent(prevLnum)
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
84 endif
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
85 return plindent
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
86 endif
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
87
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
88 let prevline = getline(prevLnum)
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
89 let thisline = getline(a:lnum)
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
90
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
91 " If this line is not a comment and the previous one is then move the
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
92 " previous line further back.
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
93 if thisline !~ '^\s*#'
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
94 while prevline =~ '^\s*#'
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
95 let prevLnum = prevnonblank(prevLnum - 1)
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
96 if prevLnum == 0
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
97 " Only comment lines before this, no indent
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
98 return 0
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
99 endif
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
100 let prevline = getline(prevLnum)
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
101 let plindent = indent(prevLnum)
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
102 endwhile
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
103 endif
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
104
3830
04592728474a Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
105 if prevline =~ '^\s*\(IF\|\|ELSEIF\|ELSE\|GENERATE_IF\|\|GENERATE_ELSEIF\|GENERATE_ELSE\|WHILE\|REPEAT\|TRY\|CATCH\|FINALLY\|FOR\|DO\|SWITCH\|CASE\|DEFAULT\|FUNC\|VIRTUAL\|ABSTRACT\|DEFINE\|REPLACE\|FINAL\|PROC\|MAIN\|NEW\|ENUM\|CLASS\|INTERFACE\|BITS\|MODULE\|SHARED\)\>'
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 3830
diff changeset
106 let plindent += shiftwidth()
3513
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
107 endif
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
108 if thisline =~ '^\s*\(}\|ELSEIF\>\|ELSE\>\|CATCH\|FINALLY\|GENERATE_ELSEIF\>\|GENERATE_ELSE\>\|UNTIL\>\)'
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 3830
diff changeset
109 let plindent -= shiftwidth()
3513
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
110 endif
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
111 if thisline =~ '^\s*\(CASE\>\|DEFAULT\>\)' && prevline !~ '^\s*SWITCH\>'
7790
ca19726d5e83 commit https://github.com/vim/vim/commit/298b440930ecece38d6ea0505a3e582dc817e79b
Christian Brabandt <cb@256bit.org>
parents: 3830
diff changeset
112 let plindent -= shiftwidth()
3513
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
113 endif
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
114
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
115 " line up continued comment that started after some code
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
116 " String something # comment comment
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
117 " # comment
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
118 if a:lnum == prevLnum + 1 && thisline =~ '^\s*#' && prevline !~ '^\s*#'
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
119 let n = match(prevline, '#')
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
120 if n > 1
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
121 let plindent = n
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
122 endif
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
123 endif
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
124
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
125 return plindent
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
126 endfunc
1b584a6f446c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
127
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3513
diff changeset
128 let &cpo = s:cpo_save
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3513
diff changeset
129 unlet s:cpo_save