Mercurial > vim
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 |
rev | line source |
---|---|
3513 | 1 " Vim indent file |
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 | 6 |
7 " Only load this indent file when no other was loaded. | |
8 if exists("b:did_indent") | |
9 finish | |
10 endif | |
11 let b:did_indent = 1 | |
12 | |
13 setlocal ai nolisp nocin | |
14 setlocal indentexpr=GetZimbuIndent(v:lnum) | |
15 setlocal indentkeys=0{,0},!^F,o,O,0=ELSE,0=ELSEIF,0=CASE,0=DEFAULT,0=FINALLY | |
16 | |
17 " We impose recommended defaults: no Tabs, 'shiftwidth' = 2 | |
18 setlocal sw=2 et | |
19 | |
25880 | 20 let b:undo_indent = "setl ai< cin< et< indentkeys< indentexpr< lisp< sw<" |
3513 | 21 |
22 " Only define the function once. | |
23 if exists("*GetZimbuIndent") | |
24 finish | |
25 endif | |
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 | 30 " Come here when loading the script the first time. |
31 | |
32 let s:maxoff = 50 " maximum number of lines to look backwards for () | |
33 | |
34 func GetZimbuIndent(lnum) | |
35 let prevLnum = prevnonblank(a:lnum - 1) | |
36 if prevLnum == 0 | |
37 " This is the first non-empty line, use zero indent. | |
38 return 0 | |
39 endif | |
40 | |
41 " Taken from Python indenting: | |
42 " If the previous line is inside parenthesis, use the indent of the starting | |
43 " line. | |
44 " Trick: use the non-existing "dummy" variable to break out of the loop when | |
45 " going too far back. | |
46 call cursor(prevLnum, 1) | |
47 let parlnum = searchpair('(\|{\|\[', '', ')\|}\|\]', 'nbW', | |
48 \ "line('.') < " . (prevLnum - s:maxoff) . " ? dummy :" | |
49 \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')" | |
50 \ . " =~ '\\(Comment\\|String\\|Char\\)$'") | |
51 if parlnum > 0 | |
52 let plindent = indent(parlnum) | |
53 let plnumstart = parlnum | |
54 else | |
55 let plindent = indent(prevLnum) | |
56 let plnumstart = prevLnum | |
57 endif | |
58 | |
59 | |
60 " When inside parenthesis: If at the first line below the parenthesis add | |
61 " two 'shiftwidth', otherwise same as previous line. | |
62 " i = (a | |
63 " + b | |
64 " + c) | |
65 call cursor(a:lnum, 1) | |
66 let p = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW', | |
67 \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :" | |
68 \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')" | |
69 \ . " =~ '\\(Comment\\|String\\|Char\\)$'") | |
70 if p > 0 | |
71 if p == prevLnum | |
72 " When the start is inside parenthesis, only indent one 'shiftwidth'. | |
73 let pp = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW', | |
74 \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :" | |
75 \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')" | |
76 \ . " =~ '\\(Comment\\|String\\|Char\\)$'") | |
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 | 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 | 81 endif |
82 if plnumstart == p | |
83 return indent(prevLnum) | |
84 endif | |
85 return plindent | |
86 endif | |
87 | |
88 let prevline = getline(prevLnum) | |
89 let thisline = getline(a:lnum) | |
90 | |
91 " If this line is not a comment and the previous one is then move the | |
92 " previous line further back. | |
93 if thisline !~ '^\s*#' | |
94 while prevline =~ '^\s*#' | |
95 let prevLnum = prevnonblank(prevLnum - 1) | |
96 if prevLnum == 0 | |
97 " Only comment lines before this, no indent | |
98 return 0 | |
99 endif | |
100 let prevline = getline(prevLnum) | |
101 let plindent = indent(prevLnum) | |
102 endwhile | |
103 endif | |
104 | |
3830 | 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 | 107 endif |
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 | 110 endif |
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 | 113 endif |
114 | |
115 " line up continued comment that started after some code | |
116 " String something # comment comment | |
117 " # comment | |
118 if a:lnum == prevLnum + 1 && thisline =~ '^\s*#' && prevline !~ '^\s*#' | |
119 let n = match(prevline, '#') | |
120 if n > 1 | |
121 let plindent = n | |
122 endif | |
123 endif | |
124 | |
125 return plindent | |
126 endfunc | |
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 |