1" Vim filetype plugin file 2" Language: Zimbu 3" Maintainer: Bram Moolenaar <[email protected]> 4" Last Change: 2012 Sep 08 5 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 18let b:undo_ftplugin = "setl fo< com< ofu< efm< tw< et< sts< sw< | if has('vms') | setl isk< | endif" 19 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 if v:char != ' ' && v:char != "\r" && v:char != "\x1b" && v:char != '.' && v:char != ')' && v:char != '}' && v:char != ',' 47 " no space or dot after the typed text 48 let g:got_char = v:char 49 return a:what 50 endif 51 return GCUpperCommon(a:what) 52endfunc 53 54" Does not replace when a dot is typed. 55func! 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) 62endfunc 63 64" Only replaces when a space is typed. 65func! 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) 72endfunc 73 74func! GCUpperCommon(what) 75 let col = col(".") - strlen(a:what) 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) 89endfunc 90 91iabbr <buffer> <expr> alias GCUpperSpace("alias") 92iabbr <buffer> <expr> arg GCUpperDot("arg") 93iabbr <buffer> <expr> break GCUpper("break") 94iabbr <buffer> <expr> case GCUpperSpace("case") 95iabbr <buffer> <expr> catch GCUpperSpace("catch") 96iabbr <buffer> <expr> check GCUpperDot("check") 97iabbr <buffer> <expr> class GCUpperSpace("class") 98iabbr <buffer> <expr> interface GCUpperSpace("interface") 99iabbr <buffer> <expr> implements GCUpperSpace("implements") 100iabbr <buffer> <expr> shared GCUpperSpace("shared") 101iabbr <buffer> <expr> continue GCUpper("continue") 102iabbr <buffer> <expr> default GCUpper("default") 103iabbr <buffer> <expr> extends GCUpper("extends") 104iabbr <buffer> <expr> do GCUpper("do") 105iabbr <buffer> <expr> else GCUpper("else") 106iabbr <buffer> <expr> elseif GCUpperSpace("elseif") 107iabbr <buffer> <expr> enum GCUpperSpace("enum") 108iabbr <buffer> <expr> exit GCUpper("exit") 109iabbr <buffer> <expr> false GCUpper("false") 110iabbr <buffer> <expr> fail GCUpper("fail") 111iabbr <buffer> <expr> finally GCUpper("finally") 112iabbr <buffer> <expr> for GCUpperSpace("for") 113iabbr <buffer> <expr> func GCUpperSpace("func") 114iabbr <buffer> <expr> if GCUpperSpace("if") 115iabbr <buffer> <expr> import GCUpperSpace("import") 116iabbr <buffer> <expr> in GCUpperSpace("in") 117iabbr <buffer> <expr> io GCUpperDot("io") 118iabbr <buffer> <expr> main GCUpper("main") 119iabbr <buffer> <expr> module GCUpperSpace("module") 120iabbr <buffer> <expr> new GCUpper("new") 121iabbr <buffer> <expr> nil GCUpper("nil") 122iabbr <buffer> <expr> ok GCUpper("ok") 123iabbr <buffer> <expr> proc GCUpperSpace("proc") 124iabbr <buffer> <expr> proceed GCUpper("proceed") 125iabbr <buffer> <expr> return GCUpper("return") 126iabbr <buffer> <expr> step GCUpperSpace("step") 127iabbr <buffer> <expr> switch GCUpperSpace("switch") 128iabbr <buffer> <expr> sys GCUpperDot("sys") 129iabbr <buffer> <expr> this GCUpperDot("this") 130iabbr <buffer> <expr> throw GCUpperSpace("throw") 131iabbr <buffer> <expr> try GCUpper("try") 132iabbr <buffer> <expr> to GCUpperSpace("to") 133iabbr <buffer> <expr> true GCUpper("true") 134iabbr <buffer> <expr> until GCUpperSpace("until") 135iabbr <buffer> <expr> while GCUpperSpace("while") 136iabbr <buffer> <expr> repeat GCUpper("repeat") 137 138nnoremap <silent> <buffer> [[ m`:call ZimbuGoStartBlock()<CR> 139nnoremap <silent> <buffer> ]] m`:call ZimbuGoEndBlock()<CR> 140 141" Using a function makes sure the search pattern is restored 142func! ZimbuGoStartBlock() 143 ?^\s*\(FUNC\|PROC\|MAIN\|ENUM\|CLASS\|INTERFACE\)\> 144endfunc 145func! ZimbuGoEndBlock() 146 /^\s*\(FUNC\|PROC\|MAIN\|ENUM\|CLASS\|INTERFACE\)\> 147endfunc 148 149 150let &cpo = s:cpo_save 151unlet s:cpo_save 152