blob: 85b57f464f4730aab5a5b81b0298e1631081b408 [file] [log] [blame]
Bram Moolenaar1aeaf8c2012-05-18 13:46:39 +02001" Vim filetype plugin file
2" Language: Zimbu
3" Maintainer: Bram Moolenaar <Bram@vim.org>
Bram Moolenaar8e52a592012-05-18 21:49:28 +02004" Last Change: 2012 May 18
Bram Moolenaar1aeaf8c2012-05-18 13:46:39 +02005
6" Only do this when not done yet for this buffer
7if exists("b:did_ftplugin")
8 finish
9endif
10
11" Don't load another plugin for this buffer
12let b:did_ftplugin = 1
13
14" Using line continuation here.
15let s:cpo_save = &cpo
16set cpo-=C
17
Bram Moolenaar8e52a592012-05-18 21:49:28 +020018let b:undo_ftplugin = "setl fo< com< ofu< efm< tw< et< sts< sw< | if has('vms') | setl isk< | endif"
Bram Moolenaar1aeaf8c2012-05-18 13:46:39 +020019
20" Set 'formatoptions' to break comment lines but not other lines,
21" and insert the comment leader when hitting <CR> or using "o".
22setlocal fo-=t fo+=croql
23
24" Set completion with CTRL-X CTRL-O to autoloaded function.
25if exists('&ofu')
26 setlocal ofu=ccomplete#Complete
27endif
28
29" Set 'comments' to format dashed lists in comments.
30" And to keep Zudocu comment characters.
31setlocal comments=sO:#\ -,mO:#\ \ ,:#=,:#-,:#%,:#
32
33setlocal 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.
37let 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\>'
38
39let b:match_skip = 's:comment\|string\|zimbuchar'
40
41setlocal tw=78
42setlocal et sts=2 sw=2
43
44" Does replace when a dot, space or closing brace is typed.
45func! GCUpperDot(what)
46 let col = col(".") - strlen(a:what)
47 if v:char != ' ' && v:char != "\r" && v:char != "\x1b" && v:char != '.' && v:char != ')' && v:char != '}'
48 " no space or dot after the typed text
49 let g:got_char = v:char
50 return a:what
51 endif
52 if col > 1 && getline('.')[col - 2] != ' '
53 " no space before the typed text
54 let g:got_char = 999
55 return a:what
56 endif
57 let synName = synIDattr(synID(line("."), col(".") - 2, 1), "name")
58 if synName =~ 'Comment\|String\|zimbuCregion\|\<c'
59 " inside a comment or C code
60 let g:got_char = 777
61 return a:what
62 endif
63 let g:got_char = 1111
64 return toupper(a:what)
65endfunc
66
67" Does not replace when a dot is typed.
68func! GCUpper(what)
69 if v:char != ' ' && v:char != "\r" && v:char != "\x1b" && v:char != ')'
70 " no space after the typed text
71 let g:got_char = v:char
72 return a:what
73 endif
74 return GCUpperDot(a:what)
75endfunc
76
77" Only replaces when a space is typed.
78func! GCUpperSpace(what)
79 if v:char != ' '
80 " no space after the typed text
81 let g:got_char = v:char
82 return a:what
83 endif
84 return GCUpperDot(a:what)
85endfunc
86
87iabbr <buffer> <expr> alias GCUpperSpace("alias")
88iabbr <buffer> <expr> arg GCUpperDot("arg")
89iabbr <buffer> <expr> bad GCUpper("bad")
90iabbr <buffer> <expr> break GCUpper("break")
91iabbr <buffer> <expr> case GCUpperSpace("case")
92iabbr <buffer> <expr> catch GCUpperSpace("catch")
93iabbr <buffer> <expr> check GCUpperDot("check")
94iabbr <buffer> <expr> class GCUpperSpace("class")
95iabbr <buffer> <expr> shared GCUpperSpace("shared")
96iabbr <buffer> <expr> continue GCUpper("continue")
97iabbr <buffer> <expr> default GCUpper("default")
98iabbr <buffer> <expr> extends GCUpper("extends")
99iabbr <buffer> <expr> do GCUpper("do")
100iabbr <buffer> <expr> else GCUpper("else")
101iabbr <buffer> <expr> elseif GCUpperSpace("elseif")
102iabbr <buffer> <expr> enum GCUpperSpace("enum")
103iabbr <buffer> <expr> exit GCUpper("exit")
104iabbr <buffer> <expr> false GCUpper("false")
105iabbr <buffer> <expr> fail GCUpper("fail")
106iabbr <buffer> <expr> finally GCUpper("finally")
107iabbr <buffer> <expr> for GCUpperSpace("for")
108iabbr <buffer> <expr> func GCUpperSpace("func")
109iabbr <buffer> <expr> if GCUpperSpace("if")
110iabbr <buffer> <expr> import GCUpperSpace("import")
111iabbr <buffer> <expr> in GCUpperSpace("in")
112iabbr <buffer> <expr> io GCUpperDot("io")
113iabbr <buffer> <expr> main GCUpper("main")
114iabbr <buffer> <expr> module GCUpperSpace("module")
115iabbr <buffer> <expr> new GCUpper("new")
116iabbr <buffer> <expr> nil GCUpper("nil")
117iabbr <buffer> <expr> ok GCUpper("ok")
118iabbr <buffer> <expr> proc GCUpperSpace("proc")
119iabbr <buffer> <expr> proceed GCUpper("proceed")
120iabbr <buffer> <expr> return GCUpper("return")
121iabbr <buffer> <expr> step GCUpperSpace("step")
122iabbr <buffer> <expr> switch GCUpperSpace("switch")
123iabbr <buffer> <expr> sys GCUpperDot("sys")
124iabbr <buffer> <expr> this GCUpperDot("this")
125iabbr <buffer> <expr> throw GCUpperSpace("throw")
126iabbr <buffer> <expr> try GCUpper("try")
127iabbr <buffer> <expr> to GCUpperSpace("to")
128iabbr <buffer> <expr> true GCUpper("true")
129iabbr <buffer> <expr> until GCUpperSpace("until")
130iabbr <buffer> <expr> while GCUpperSpace("while")
131iabbr <buffer> <expr> repeat GCUpper("repeat")
132
133nnoremap <silent> <buffer> [[ m`:call ZimbuGoStartBlock()<CR>
134nnoremap <silent> <buffer> ]] m`:call ZimbuGoEndBlock()<CR>
135
136" Using a function makes sure the search pattern is restored
137func! ZimbuGoStartBlock()
138 ?^\s*\(FUNC\|PROC\|MAIN\|ENUM\|CLASS\|INTERFACE\)\>
139endfunc
140func! ZimbuGoEndBlock()
141 /^\s*\(FUNC\|PROC\|MAIN\|ENUM\|CLASS\|INTERFACE\)\>
142endfunc
143
144
145let &cpo = s:cpo_save
146unlet s:cpo_save