Bram Moolenaar | 1aeaf8c | 2012-05-18 13:46:39 +0200 | [diff] [blame] | 1 | " Vim filetype plugin file |
| 2 | " Language: Zimbu |
| 3 | " Maintainer: Bram Moolenaar <Bram@vim.org> |
Bram Moolenaar | 8e52a59 | 2012-05-18 21:49:28 +0200 | [diff] [blame] | 4 | " Last Change: 2012 May 18 |
Bram Moolenaar | 1aeaf8c | 2012-05-18 13:46:39 +0200 | [diff] [blame] | 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 | |
Bram Moolenaar | 8e52a59 | 2012-05-18 21:49:28 +0200 | [diff] [blame] | 18 | let b:undo_ftplugin = "setl fo< com< ofu< efm< tw< et< sts< sw< | if has('vms') | setl isk< | endif" |
Bram Moolenaar | 1aeaf8c | 2012-05-18 13:46:39 +0200 | [diff] [blame] | 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. |
| 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\>' |
| 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) |
| 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) |
| 65 | endfunc |
| 66 | |
| 67 | " Does not replace when a dot is typed. |
| 68 | func! 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) |
| 75 | endfunc |
| 76 | |
| 77 | " Only replaces when a space is typed. |
| 78 | func! 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) |
| 85 | endfunc |
| 86 | |
| 87 | iabbr <buffer> <expr> alias GCUpperSpace("alias") |
| 88 | iabbr <buffer> <expr> arg GCUpperDot("arg") |
| 89 | iabbr <buffer> <expr> bad GCUpper("bad") |
| 90 | iabbr <buffer> <expr> break GCUpper("break") |
| 91 | iabbr <buffer> <expr> case GCUpperSpace("case") |
| 92 | iabbr <buffer> <expr> catch GCUpperSpace("catch") |
| 93 | iabbr <buffer> <expr> check GCUpperDot("check") |
| 94 | iabbr <buffer> <expr> class GCUpperSpace("class") |
| 95 | iabbr <buffer> <expr> shared GCUpperSpace("shared") |
| 96 | iabbr <buffer> <expr> continue GCUpper("continue") |
| 97 | iabbr <buffer> <expr> default GCUpper("default") |
| 98 | iabbr <buffer> <expr> extends GCUpper("extends") |
| 99 | iabbr <buffer> <expr> do GCUpper("do") |
| 100 | iabbr <buffer> <expr> else GCUpper("else") |
| 101 | iabbr <buffer> <expr> elseif GCUpperSpace("elseif") |
| 102 | iabbr <buffer> <expr> enum GCUpperSpace("enum") |
| 103 | iabbr <buffer> <expr> exit GCUpper("exit") |
| 104 | iabbr <buffer> <expr> false GCUpper("false") |
| 105 | iabbr <buffer> <expr> fail GCUpper("fail") |
| 106 | iabbr <buffer> <expr> finally GCUpper("finally") |
| 107 | iabbr <buffer> <expr> for GCUpperSpace("for") |
| 108 | iabbr <buffer> <expr> func GCUpperSpace("func") |
| 109 | iabbr <buffer> <expr> if GCUpperSpace("if") |
| 110 | iabbr <buffer> <expr> import GCUpperSpace("import") |
| 111 | iabbr <buffer> <expr> in GCUpperSpace("in") |
| 112 | iabbr <buffer> <expr> io GCUpperDot("io") |
| 113 | iabbr <buffer> <expr> main GCUpper("main") |
| 114 | iabbr <buffer> <expr> module GCUpperSpace("module") |
| 115 | iabbr <buffer> <expr> new GCUpper("new") |
| 116 | iabbr <buffer> <expr> nil GCUpper("nil") |
| 117 | iabbr <buffer> <expr> ok GCUpper("ok") |
| 118 | iabbr <buffer> <expr> proc GCUpperSpace("proc") |
| 119 | iabbr <buffer> <expr> proceed GCUpper("proceed") |
| 120 | iabbr <buffer> <expr> return GCUpper("return") |
| 121 | iabbr <buffer> <expr> step GCUpperSpace("step") |
| 122 | iabbr <buffer> <expr> switch GCUpperSpace("switch") |
| 123 | iabbr <buffer> <expr> sys GCUpperDot("sys") |
| 124 | iabbr <buffer> <expr> this GCUpperDot("this") |
| 125 | iabbr <buffer> <expr> throw GCUpperSpace("throw") |
| 126 | iabbr <buffer> <expr> try GCUpper("try") |
| 127 | iabbr <buffer> <expr> to GCUpperSpace("to") |
| 128 | iabbr <buffer> <expr> true GCUpper("true") |
| 129 | iabbr <buffer> <expr> until GCUpperSpace("until") |
| 130 | iabbr <buffer> <expr> while GCUpperSpace("while") |
| 131 | iabbr <buffer> <expr> repeat GCUpper("repeat") |
| 132 | |
| 133 | nnoremap <silent> <buffer> [[ m`:call ZimbuGoStartBlock()<CR> |
| 134 | nnoremap <silent> <buffer> ]] m`:call ZimbuGoEndBlock()<CR> |
| 135 | |
| 136 | " Using a function makes sure the search pattern is restored |
| 137 | func! ZimbuGoStartBlock() |
| 138 | ?^\s*\(FUNC\|PROC\|MAIN\|ENUM\|CLASS\|INTERFACE\)\> |
| 139 | endfunc |
| 140 | func! ZimbuGoEndBlock() |
| 141 | /^\s*\(FUNC\|PROC\|MAIN\|ENUM\|CLASS\|INTERFACE\)\> |
| 142 | endfunc |
| 143 | |
| 144 | |
| 145 | let &cpo = s:cpo_save |
| 146 | unlet s:cpo_save |