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