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