Mercurial > vim
annotate runtime/ftplugin/zimbu.vim @ 17479:35b73ec0ba25
Added tag v8.1.1737 for changeset f9a4433061742d95f7152c44a1ddf9b9899b0af9
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 23 Jul 2019 23:15:06 +0200 |
parents | a6d3e2081544 |
children | 624439a39432 |
rev | line source |
---|---|
3513 | 1 " Vim filetype plugin file |
2 " Language: Zimbu | |
3 " Maintainer: Bram Moolenaar <Bram@vim.org> | |
13051 | 4 " Last Change: 2017 Dec 05 |
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. | |
3830 | 37 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\>\)' |
3513 | 38 |
39 let b:match_skip = 's:comment\|string\|zimbuchar' | |
40 | |
41 setlocal tw=78 | |
42 setlocal et sts=2 sw=2 | |
43 | |
44 " Does replace when a dot, space or closing brace is typed. | |
45 func! GCUpperDot(what) | |
3830 | 46 if v:char != ' ' && v:char != "\r" && v:char != "\x1b" && v:char != '.' && v:char != ')' && v:char != '}' && v:char != ',' |
3513 | 47 " no space or dot after the typed text |
48 let g:got_char = v:char | |
49 return a:what | |
50 endif | |
3830 | 51 return GCUpperCommon(a:what) |
52 endfunc | |
53 | |
54 " Does not replace when a dot is typed. | |
55 func! GCUpper(what) | |
56 if v:char != ' ' && v:char != "\r" && v:char != "\x1b" && v:char != ')' && v:char != ',' | |
57 " no space or other "terminating" character after the typed text | |
58 let g:got_char = v:char | |
59 return a:what | |
60 endif | |
61 return GCUpperCommon(a:what) | |
62 endfunc | |
63 | |
64 " Only replaces when a space is typed. | |
65 func! GCUpperSpace(what) | |
66 if v:char != ' ' | |
67 " no space after the typed text | |
68 let g:got_char = v:char | |
69 return a:what | |
70 endif | |
71 return GCUpperCommon(a:what) | |
72 endfunc | |
73 | |
74 func! GCUpperCommon(what) | |
75 let col = col(".") - strlen(a:what) | |
3513 | 76 if col > 1 && getline('.')[col - 2] != ' ' |
77 " no space before the typed text | |
78 let g:got_char = 999 | |
79 return a:what | |
80 endif | |
81 let synName = synIDattr(synID(line("."), col(".") - 2, 1), "name") | |
82 if synName =~ 'Comment\|String\|zimbuCregion\|\<c' | |
83 " inside a comment or C code | |
84 let g:got_char = 777 | |
85 return a:what | |
86 endif | |
87 let g:got_char = 1111 | |
88 return toupper(a:what) | |
89 endfunc | |
90 | |
91 iabbr <buffer> <expr> alias GCUpperSpace("alias") | |
92 iabbr <buffer> <expr> arg GCUpperDot("arg") | |
93 iabbr <buffer> <expr> break GCUpper("break") | |
94 iabbr <buffer> <expr> case GCUpperSpace("case") | |
95 iabbr <buffer> <expr> catch GCUpperSpace("catch") | |
96 iabbr <buffer> <expr> check GCUpperDot("check") | |
97 iabbr <buffer> <expr> class GCUpperSpace("class") | |
3830 | 98 iabbr <buffer> <expr> interface GCUpperSpace("interface") |
99 iabbr <buffer> <expr> implements GCUpperSpace("implements") | |
3513 | 100 iabbr <buffer> <expr> shared GCUpperSpace("shared") |
101 iabbr <buffer> <expr> continue GCUpper("continue") | |
102 iabbr <buffer> <expr> default GCUpper("default") | |
103 iabbr <buffer> <expr> extends GCUpper("extends") | |
104 iabbr <buffer> <expr> do GCUpper("do") | |
105 iabbr <buffer> <expr> else GCUpper("else") | |
106 iabbr <buffer> <expr> elseif GCUpperSpace("elseif") | |
107 iabbr <buffer> <expr> enum GCUpperSpace("enum") | |
108 iabbr <buffer> <expr> exit GCUpper("exit") | |
109 iabbr <buffer> <expr> false GCUpper("false") | |
110 iabbr <buffer> <expr> fail GCUpper("fail") | |
111 iabbr <buffer> <expr> finally GCUpper("finally") | |
112 iabbr <buffer> <expr> for GCUpperSpace("for") | |
113 iabbr <buffer> <expr> func GCUpperSpace("func") | |
114 iabbr <buffer> <expr> if GCUpperSpace("if") | |
115 iabbr <buffer> <expr> import GCUpperSpace("import") | |
116 iabbr <buffer> <expr> in GCUpperSpace("in") | |
117 iabbr <buffer> <expr> io GCUpperDot("io") | |
118 iabbr <buffer> <expr> main GCUpper("main") | |
119 iabbr <buffer> <expr> module GCUpperSpace("module") | |
120 iabbr <buffer> <expr> new GCUpper("new") | |
121 iabbr <buffer> <expr> nil GCUpper("nil") | |
122 iabbr <buffer> <expr> ok GCUpper("ok") | |
123 iabbr <buffer> <expr> proc GCUpperSpace("proc") | |
124 iabbr <buffer> <expr> proceed GCUpper("proceed") | |
125 iabbr <buffer> <expr> return GCUpper("return") | |
126 iabbr <buffer> <expr> step GCUpperSpace("step") | |
127 iabbr <buffer> <expr> switch GCUpperSpace("switch") | |
128 iabbr <buffer> <expr> sys GCUpperDot("sys") | |
129 iabbr <buffer> <expr> this GCUpperDot("this") | |
130 iabbr <buffer> <expr> throw GCUpperSpace("throw") | |
131 iabbr <buffer> <expr> try GCUpper("try") | |
132 iabbr <buffer> <expr> to GCUpperSpace("to") | |
133 iabbr <buffer> <expr> true GCUpper("true") | |
134 iabbr <buffer> <expr> until GCUpperSpace("until") | |
135 iabbr <buffer> <expr> while GCUpperSpace("while") | |
136 iabbr <buffer> <expr> repeat GCUpper("repeat") | |
137 | |
13051 | 138 if !exists("no_plugin_maps") && !exists("no_zimbu_maps") |
139 nnoremap <silent> <buffer> [[ m`:call ZimbuGoStartBlock()<CR> | |
140 nnoremap <silent> <buffer> ]] m`:call ZimbuGoEndBlock()<CR> | |
141 endif | |
3513 | 142 |
143 " Using a function makes sure the search pattern is restored | |
144 func! ZimbuGoStartBlock() | |
145 ?^\s*\(FUNC\|PROC\|MAIN\|ENUM\|CLASS\|INTERFACE\)\> | |
146 endfunc | |
147 func! ZimbuGoEndBlock() | |
148 /^\s*\(FUNC\|PROC\|MAIN\|ENUM\|CLASS\|INTERFACE\)\> | |
149 endfunc | |
150 | |
151 | |
152 let &cpo = s:cpo_save | |
153 unlet s:cpo_save |