" Vim filetype plugin file " Language: Zimbu " Maintainer: The Vim Project " Last Change: 2023 Aug 10 " Former Maintainer: Bram Moolenaar " Only do this when not done yet for this buffer if exists("b:did_ftplugin") finish endif " Don't load another plugin for this buffer let b:did_ftplugin = 1 " Using line continuation here. let s:cpo_save = &cpo set cpo-=C let b:undo_ftplugin = "setl fo< com< ofu< efm< tw< et< sts< sw<" " Set 'formatoptions' to break comment lines but not other lines, " and insert the comment leader when hitting or using "o". setlocal fo-=t fo+=croql " Set completion with CTRL-X CTRL-O to autoloaded function. if exists('&ofu') setlocal ofu=ccomplete#Complete endif " Set 'comments' to format dashed lists in comments. " And to keep Zudocu comment characters. setlocal comments=sO:#\ -,mO:#\ \ ,exO:#/,s:/*,m:\ ,ex:*/,:#=,:#-,:#%,:# setlocal errorformat^=%f\ line\ %l\ col\ %c:\ %m,ERROR:\ %m " When the matchit plugin is loaded, this makes the % command skip parens and " braces in comments. if exists("loaded_matchit") && !exists("b:match_words") 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*\)\@<=\(}\|\\)' let b:match_skip = 's:comment\|string\|zimbuchar' let b:undo_ftplugin ..= " | unlet! b:match_words b:match_skip" endif setlocal tw=78 setlocal et sts=2 sw=2 " Does replace when a dot, space or closing brace is typed. func! GCUpperDot(what) if v:char != ' ' && v:char != "\r" && v:char != "\x1b" && v:char != '.' && v:char != ')' && v:char != '}' && v:char != ',' " no space or dot after the typed text let g:got_char = v:char return a:what endif return GCUpperCommon(a:what) endfunc " Does not replace when a dot is typed. func! GCUpper(what) if v:char != ' ' && v:char != "\r" && v:char != "\x1b" && v:char != ')' && v:char != ',' " no space or other "terminating" character after the typed text let g:got_char = v:char return a:what endif return GCUpperCommon(a:what) endfunc " Only replaces when a space is typed. func! GCUpperSpace(what) if v:char != ' ' " no space after the typed text let g:got_char = v:char return a:what endif return GCUpperCommon(a:what) endfunc func! GCUpperCommon(what) let col = col(".") - strlen(a:what) if col > 1 && getline('.')[col - 2] != ' ' " no space before the typed text let g:got_char = 999 return a:what endif let synName = synIDattr(synID(line("."), col(".") - 2, 1), "name") if synName =~ 'Comment\|String\|zimbuCregion\|\ alias GCUpperSpace("alias") iabbr arg GCUpperDot("arg") iabbr break GCUpper("break") iabbr case GCUpperSpace("case") iabbr catch GCUpperSpace("catch") iabbr check GCUpperDot("check") iabbr class GCUpperSpace("class") iabbr interface GCUpperSpace("interface") iabbr implements GCUpperSpace("implements") iabbr shared GCUpperSpace("shared") iabbr continue GCUpper("continue") iabbr default GCUpper("default") iabbr extends GCUpper("extends") iabbr do GCUpper("do") iabbr else GCUpper("else") iabbr elseif GCUpperSpace("elseif") iabbr enum GCUpperSpace("enum") iabbr exit GCUpper("exit") iabbr false GCUpper("false") iabbr fail GCUpper("fail") iabbr finally GCUpper("finally") iabbr for GCUpperSpace("for") iabbr func GCUpperSpace("func") iabbr if GCUpperSpace("if") iabbr import GCUpperSpace("import") iabbr in GCUpperSpace("in") iabbr io GCUpperDot("io") iabbr main GCUpper("main") iabbr module GCUpperSpace("module") iabbr new GCUpper("new") iabbr nil GCUpper("nil") iabbr ok GCUpper("ok") iabbr proc GCUpperSpace("proc") iabbr proceed GCUpper("proceed") iabbr return GCUpper("return") iabbr step GCUpperSpace("step") iabbr switch GCUpperSpace("switch") iabbr sys GCUpperDot("sys") iabbr this GCUpperDot("this") iabbr throw GCUpperSpace("throw") iabbr try GCUpper("try") iabbr to GCUpperSpace("to") iabbr true GCUpper("true") iabbr until GCUpperSpace("until") iabbr while GCUpperSpace("while") iabbr repeat GCUpper("repeat") let b:undo_ftplugin ..= \ " | iunabbr alias" .. \ " | iunabbr arg" .. \ " | iunabbr break" .. \ " | iunabbr case" .. \ " | iunabbr catch" .. \ " | iunabbr check" .. \ " | iunabbr class" .. \ " | iunabbr interface" .. \ " | iunabbr implements" .. \ " | iunabbr shared" .. \ " | iunabbr continue" .. \ " | iunabbr default" .. \ " | iunabbr extends" .. \ " | iunabbr do" .. \ " | iunabbr else" .. \ " | iunabbr elseif" .. \ " | iunabbr enum" .. \ " | iunabbr exit" .. \ " | iunabbr false" .. \ " | iunabbr fail" .. \ " | iunabbr finally" .. \ " | iunabbr for" .. \ " | iunabbr func" .. \ " | iunabbr if" .. \ " | iunabbr import" .. \ " | iunabbr in" .. \ " | iunabbr io" .. \ " | iunabbr main" .. \ " | iunabbr module" .. \ " | iunabbr new" .. \ " | iunabbr nil" .. \ " | iunabbr ok" .. \ " | iunabbr proc" .. \ " | iunabbr proceed" .. \ " | iunabbr return" .. \ " | iunabbr step" .. \ " | iunabbr switch" .. \ " | iunabbr sys" .. \ " | iunabbr this" .. \ " | iunabbr throw" .. \ " | iunabbr try" .. \ " | iunabbr to" .. \ " | iunabbr true" .. \ " | iunabbr until" .. \ " | iunabbr while" .. \ " | iunabbr repeat" if !exists("no_plugin_maps") && !exists("no_zimbu_maps") nnoremap [[ m`:call ZimbuGoStartBlock() nnoremap ]] m`:call ZimbuGoEndBlock() let b:undo_ftplugin ..= \ " | silent! exe 'nunmap [['" .. \ " | silent! exe 'nunmap ]]'" endif " Using a function makes sure the search pattern is restored func! ZimbuGoStartBlock() ?^\s*\(FUNC\|PROC\|MAIN\|ENUM\|CLASS\|INTERFACE\)\> endfunc func! ZimbuGoEndBlock() /^\s*\(FUNC\|PROC\|MAIN\|ENUM\|CLASS\|INTERFACE\)\> endfunc let &cpo = s:cpo_save unlet s:cpo_save