Mercurial > vim
annotate runtime/ftplugin/zimbu.vim @ 28944:f498ab5c82ea v8.2.4994
patch 8.2.4994: tests are using legacy functions
Commit: https://github.com/vim/vim/commit/7e569d09d2ec4fa334a2d3d5b0b6dbca16d97133
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 21 21:30:50 2022 +0100
patch 8.2.4994: tests are using legacy functions
Problem: Tests are using legacy functions.
Solution: Convert a few tests to use :def functions.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 21 May 2022 22:45:03 +0200 |
parents | 624439a39432 |
children | fee9eccee266 |
rev | line source |
---|---|
3513 | 1 " Vim filetype plugin file |
2 " Language: Zimbu | |
3 " Maintainer: Bram Moolenaar <Bram@vim.org> | |
26148 | 4 " Last Change: 2021 Nov 12 |
3513 | 5 |
6 " Only do this when not done yet for this buffer | |
7 if exists("b:did_ftplugin") | |
8 finish | |
9 endif | |
10 | |
11 " Don't load another plugin for this buffer | |
12 let b:did_ftplugin = 1 | |
13 | |
14 " Using line continuation here. | |
15 let s:cpo_save = &cpo | |
16 set cpo-=C | |
17 | |
3526
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
3513
diff
changeset
|
18 let b:undo_ftplugin = "setl fo< com< ofu< efm< tw< et< sts< sw< | if has('vms') | setl isk< | endif" |
3513 | 19 |
20 " Set 'formatoptions' to break comment lines but not other lines, | |
21 " and insert the comment leader when hitting <CR> or using "o". | |
22 setlocal fo-=t fo+=croql | |
23 | |
24 " Set completion with CTRL-X CTRL-O to autoloaded function. | |
25 if exists('&ofu') | |
26 setlocal ofu=ccomplete#Complete | |
27 endif | |
28 | |
29 " Set 'comments' to format dashed lists in comments. | |
30 " And to keep Zudocu comment characters. | |
31 setlocal comments=sO:#\ -,mO:#\ \ ,:#=,:#-,:#%,:# | |
32 | |
33 setlocal errorformat^=%f\ line\ %l\ col\ %c:\ %m,ERROR:\ %m | |
34 | |
35 " When the matchit plugin is loaded, this makes the % command skip parens and | |
36 " braces in comments. | |
26148 | 37 if exists("loaded_matchit") && !exists("b:match_words") |
38 let b:match_words = '\(^\s*\)\@<=\(MODULE\|CLASS\|INTERFACE\|BITS\|ENUM\|SHARED\|FUNC\|REPLACE\|DEFINE\|PROC\|EQUAL\|MAIN\|IF\|GENERATE_IF\|WHILE\|REPEAT\|WITH\|DO\|FOR\|SWITCH\|TRY\)\>\|{\s*$:\(^\s*\)\@<=\(ELSE\|ELSEIF\|GENERATE_ELSE\|GENERATE_ELSEIF\|CATCH\|FINALLY\)\>:\(^\s*\)\@<=\(}\|\<UNTIL\>\)' | |
39 let b:match_skip = 's:comment\|string\|zimbuchar' | |
40 let b:undo_ftplugin ..= " | unlet! b:match_words b:match_skip" | |
41 endif | |
3513 | 42 |
43 setlocal tw=78 | |
44 setlocal et sts=2 sw=2 | |
45 | |
46 " Does replace when a dot, space or closing brace is typed. | |
47 func! GCUpperDot(what) | |
3830 | 48 if v:char != ' ' && v:char != "\r" && v:char != "\x1b" && v:char != '.' && v:char != ')' && v:char != '}' && v:char != ',' |
3513 | 49 " no space or dot after the typed text |
50 let g:got_char = v:char | |
51 return a:what | |
52 endif | |
3830 | 53 return GCUpperCommon(a:what) |
54 endfunc | |
55 | |
56 " Does not replace when a dot is typed. | |
57 func! GCUpper(what) | |
58 if v:char != ' ' && v:char != "\r" && v:char != "\x1b" && v:char != ')' && v:char != ',' | |
59 " no space or other "terminating" character after the typed text | |
60 let g:got_char = v:char | |
61 return a:what | |
62 endif | |
63 return GCUpperCommon(a:what) | |
64 endfunc | |
65 | |
66 " Only replaces when a space is typed. | |
67 func! GCUpperSpace(what) | |
68 if v:char != ' ' | |
69 " no space after the typed text | |
70 let g:got_char = v:char | |
71 return a:what | |
72 endif | |
73 return GCUpperCommon(a:what) | |
74 endfunc | |
75 | |
76 func! GCUpperCommon(what) | |
77 let col = col(".") - strlen(a:what) | |
3513 | 78 if col > 1 && getline('.')[col - 2] != ' ' |
79 " no space before the typed text | |
80 let g:got_char = 999 | |
81 return a:what | |
82 endif | |
83 let synName = synIDattr(synID(line("."), col(".") - 2, 1), "name") | |
84 if synName =~ 'Comment\|String\|zimbuCregion\|\<c' | |
85 " inside a comment or C code | |
86 let g:got_char = 777 | |
87 return a:what | |
88 endif | |
89 let g:got_char = 1111 | |
90 return toupper(a:what) | |
91 endfunc | |
92 | |
93 iabbr <buffer> <expr> alias GCUpperSpace("alias") | |
94 iabbr <buffer> <expr> arg GCUpperDot("arg") | |
95 iabbr <buffer> <expr> break GCUpper("break") | |
96 iabbr <buffer> <expr> case GCUpperSpace("case") | |
97 iabbr <buffer> <expr> catch GCUpperSpace("catch") | |
98 iabbr <buffer> <expr> check GCUpperDot("check") | |
99 iabbr <buffer> <expr> class GCUpperSpace("class") | |
3830 | 100 iabbr <buffer> <expr> interface GCUpperSpace("interface") |
101 iabbr <buffer> <expr> implements GCUpperSpace("implements") | |
3513 | 102 iabbr <buffer> <expr> shared GCUpperSpace("shared") |
103 iabbr <buffer> <expr> continue GCUpper("continue") | |
104 iabbr <buffer> <expr> default GCUpper("default") | |
105 iabbr <buffer> <expr> extends GCUpper("extends") | |
106 iabbr <buffer> <expr> do GCUpper("do") | |
107 iabbr <buffer> <expr> else GCUpper("else") | |
108 iabbr <buffer> <expr> elseif GCUpperSpace("elseif") | |
109 iabbr <buffer> <expr> enum GCUpperSpace("enum") | |
110 iabbr <buffer> <expr> exit GCUpper("exit") | |
111 iabbr <buffer> <expr> false GCUpper("false") | |
112 iabbr <buffer> <expr> fail GCUpper("fail") | |
113 iabbr <buffer> <expr> finally GCUpper("finally") | |
114 iabbr <buffer> <expr> for GCUpperSpace("for") | |
115 iabbr <buffer> <expr> func GCUpperSpace("func") | |
116 iabbr <buffer> <expr> if GCUpperSpace("if") | |
117 iabbr <buffer> <expr> import GCUpperSpace("import") | |
118 iabbr <buffer> <expr> in GCUpperSpace("in") | |
119 iabbr <buffer> <expr> io GCUpperDot("io") | |
120 iabbr <buffer> <expr> main GCUpper("main") | |
121 iabbr <buffer> <expr> module GCUpperSpace("module") | |
122 iabbr <buffer> <expr> new GCUpper("new") | |
123 iabbr <buffer> <expr> nil GCUpper("nil") | |
124 iabbr <buffer> <expr> ok GCUpper("ok") | |
125 iabbr <buffer> <expr> proc GCUpperSpace("proc") | |
126 iabbr <buffer> <expr> proceed GCUpper("proceed") | |
127 iabbr <buffer> <expr> return GCUpper("return") | |
128 iabbr <buffer> <expr> step GCUpperSpace("step") | |
129 iabbr <buffer> <expr> switch GCUpperSpace("switch") | |
130 iabbr <buffer> <expr> sys GCUpperDot("sys") | |
131 iabbr <buffer> <expr> this GCUpperDot("this") | |
132 iabbr <buffer> <expr> throw GCUpperSpace("throw") | |
133 iabbr <buffer> <expr> try GCUpper("try") | |
134 iabbr <buffer> <expr> to GCUpperSpace("to") | |
135 iabbr <buffer> <expr> true GCUpper("true") | |
136 iabbr <buffer> <expr> until GCUpperSpace("until") | |
137 iabbr <buffer> <expr> while GCUpperSpace("while") | |
138 iabbr <buffer> <expr> repeat GCUpper("repeat") | |
139 | |
26148 | 140 let b:undo_ftplugin ..= |
141 \ " | iunabbr <buffer> alias" .. | |
142 \ " | iunabbr <buffer> arg" .. | |
143 \ " | iunabbr <buffer> break" .. | |
144 \ " | iunabbr <buffer> case" .. | |
145 \ " | iunabbr <buffer> catch" .. | |
146 \ " | iunabbr <buffer> check" .. | |
147 \ " | iunabbr <buffer> class" .. | |
148 \ " | iunabbr <buffer> interface" .. | |
149 \ " | iunabbr <buffer> implements" .. | |
150 \ " | iunabbr <buffer> shared" .. | |
151 \ " | iunabbr <buffer> continue" .. | |
152 \ " | iunabbr <buffer> default" .. | |
153 \ " | iunabbr <buffer> extends" .. | |
154 \ " | iunabbr <buffer> do" .. | |
155 \ " | iunabbr <buffer> else" .. | |
156 \ " | iunabbr <buffer> elseif" .. | |
157 \ " | iunabbr <buffer> enum" .. | |
158 \ " | iunabbr <buffer> exit" .. | |
159 \ " | iunabbr <buffer> false" .. | |
160 \ " | iunabbr <buffer> fail" .. | |
161 \ " | iunabbr <buffer> finally" .. | |
162 \ " | iunabbr <buffer> for" .. | |
163 \ " | iunabbr <buffer> func" .. | |
164 \ " | iunabbr <buffer> if" .. | |
165 \ " | iunabbr <buffer> import" .. | |
166 \ " | iunabbr <buffer> in" .. | |
167 \ " | iunabbr <buffer> io" .. | |
168 \ " | iunabbr <buffer> main" .. | |
169 \ " | iunabbr <buffer> module" .. | |
170 \ " | iunabbr <buffer> new" .. | |
171 \ " | iunabbr <buffer> nil" .. | |
172 \ " | iunabbr <buffer> ok" .. | |
173 \ " | iunabbr <buffer> proc" .. | |
174 \ " | iunabbr <buffer> proceed" .. | |
175 \ " | iunabbr <buffer> return" .. | |
176 \ " | iunabbr <buffer> step" .. | |
177 \ " | iunabbr <buffer> switch" .. | |
178 \ " | iunabbr <buffer> sys" .. | |
179 \ " | iunabbr <buffer> this" .. | |
180 \ " | iunabbr <buffer> throw" .. | |
181 \ " | iunabbr <buffer> try" .. | |
182 \ " | iunabbr <buffer> to" .. | |
183 \ " | iunabbr <buffer> true" .. | |
184 \ " | iunabbr <buffer> until" .. | |
185 \ " | iunabbr <buffer> while" .. | |
186 \ " | iunabbr <buffer> repeat" | |
187 | |
13051 | 188 if !exists("no_plugin_maps") && !exists("no_zimbu_maps") |
189 nnoremap <silent> <buffer> [[ m`:call ZimbuGoStartBlock()<CR> | |
190 nnoremap <silent> <buffer> ]] m`:call ZimbuGoEndBlock()<CR> | |
26148 | 191 let b:undo_ftplugin ..= |
192 \ " | silent! exe 'nunmap <buffer> [['" .. | |
193 \ " | silent! exe 'nunmap <buffer> ]]'" | |
13051 | 194 endif |
3513 | 195 |
196 " Using a function makes sure the search pattern is restored | |
197 func! ZimbuGoStartBlock() | |
198 ?^\s*\(FUNC\|PROC\|MAIN\|ENUM\|CLASS\|INTERFACE\)\> | |
199 endfunc | |
200 func! ZimbuGoEndBlock() | |
201 /^\s*\(FUNC\|PROC\|MAIN\|ENUM\|CLASS\|INTERFACE\)\> | |
202 endfunc | |
203 | |
204 | |
205 let &cpo = s:cpo_save | |
206 unlet s:cpo_save |