Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 1 | " Vim syntax file |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 2 | " Language: ConTeXt typesetting engine |
| 3 | " Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com> |
| 4 | " Former Maintainers: Nikolai Weibull <now@bitwi.se> |
| 5 | " Latest Revision: 2016 Oct 16 |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 6 | |
| 7 | if exists("b:current_syntax") |
| 8 | finish |
| 9 | endif |
| 10 | |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 11 | runtime! syntax/plaintex.vim |
Bram Moolenaar | 2539402 | 2007-05-10 19:06:20 +0000 | [diff] [blame] | 12 | unlet b:current_syntax |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 13 | |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 14 | let s:cpo_save = &cpo |
| 15 | set cpo&vim |
| 16 | |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 17 | " Dictionary of (filetype, group) pairs to highlight between \startGROUP \stopGROUP. |
| 18 | let s:context_include = get(b:, 'context_include', get(g:, 'context_include', {'xml': 'XML'})) |
| 19 | |
| 20 | " For backward compatibility (g:context_include used to be a List) |
| 21 | if type(s:context_include) ==# type([]) |
| 22 | let g:context_metapost = (index(s:context_include, 'mp') != -1) |
| 23 | let s:context_include = filter( |
| 24 | \ {'c': 'C', 'javascript': 'JS', 'ruby': 'Ruby', 'xml': 'XML'}, |
| 25 | \ { k,_ -> index(s:context_include, k) != -1 } |
| 26 | \ ) |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 27 | endif |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 28 | |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 29 | syn iskeyword @,48-57,a-z,A-Z,192-255 |
| 30 | |
Bram Moolenaar | 2539402 | 2007-05-10 19:06:20 +0000 | [diff] [blame] | 31 | syn spell toplevel |
| 32 | |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 33 | " ConTeXt options, i.e., [...] blocks |
| 34 | syn region contextOptions matchgroup=contextDelimiter start='\[' end=']\|\ze\\stop' skip='\\\[\|\\\]' contains=ALLBUT,contextBeginEndLua,@Spell |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 35 | |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 36 | " Highlight braces |
| 37 | syn match contextDelimiter '[{}]' |
| 38 | |
| 39 | " Comments |
| 40 | syn match contextComment '\\\@<!\%(\\\\\)*\zs%.*$' display contains=initexTodo |
| 41 | syn match contextComment '^\s*%[CDM].*$' display contains=initexTodo |
| 42 | |
| 43 | syn match contextBlockDelim '\\\%(start\|stop\)\a\+' contains=@NoSpell |
| 44 | |
| 45 | syn region contextEscaped matchgroup=contextPreProc start='\\type\%(\s*\|\n\)*\z([^A-Za-z%]\)' end='\z1' |
| 46 | syn region contextEscaped matchgroup=contextPreProc start='\\type\=\%(\s\|\n\)*{' end='}' |
| 47 | syn region contextEscaped matchgroup=contextPreProc start='\\type\=\%(\s*\|\n\)*<<' end='>>' |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 48 | syn region contextEscaped matchgroup=contextPreProc |
| 49 | \ start='\\start\z(\a*\%(typing\|typen\)\)' |
Bram Moolenaar | 2539402 | 2007-05-10 19:06:20 +0000 | [diff] [blame] | 50 | \ end='\\stop\z1' contains=plaintexComment keepend |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 51 | syn region contextEscaped matchgroup=contextPreProc start='\\\h\+Type\%(\s\|\n\)*{' end='}' |
| 52 | syn region contextEscaped matchgroup=contextPreProc start='\\Typed\h\+\%(\s\|\n\)*{' end='}' |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 53 | |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 54 | syn match contextBuiltin display contains=@NoSpell |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 55 | \ '\\\%(unprotect\|protect\|unexpanded\)\>' |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 56 | |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 57 | syn match contextPreProc '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\)\>' |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 58 | \ contains=@NoSpell |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 59 | |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 60 | if get(b:, 'context_metapost', get(g:, 'context_metapost', 1)) |
| 61 | let b:mp_metafun_macros = 1 " Highlight MetaFun keywords |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 62 | syn include @mpTop syntax/mp.vim |
| 63 | unlet b:current_syntax |
| 64 | |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 65 | syn region contextMPGraphic matchgroup=contextBlockDelim |
| 66 | \ start='\\start\z(MP\%(clip\|code\|definitions\|drawing\|environment\|extensions\|inclusions\|initializations\|page\|\)\)\>.*$' |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 67 | \ end='\\stop\z1' |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 68 | \ contains=@mpTop,@NoSpell |
| 69 | syn region contextMPGraphic matchgroup=contextBlockDelim |
| 70 | \ start='\\start\z(\%(\%[re]usable\|use\|unique\|static\)MPgraphic\|staticMPfigure\|uniqueMPpagegraphic\)\>.*$' |
| 71 | \ end='\\stop\z1' |
| 72 | \ contains=@mpTop,@NoSpell |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 73 | endif |
| 74 | |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 75 | if get(b:, 'context_lua', get(g:, 'context_lua', 1)) |
| 76 | syn include @luaTop syntax/lua.vim |
| 77 | unlet b:current_syntax |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 78 | |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 79 | syn region contextLuaCode matchgroup=contextBlockDelim |
| 80 | \ start='\\startluacode\>' |
| 81 | \ end='\\stopluacode\>' keepend |
| 82 | \ contains=@luaTop,@NoSpell |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 83 | |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 84 | syn match contextDirectLua "\\\%(directlua\|ctxlua\)\>\%(\s*%.*$\)\=" |
| 85 | \ nextgroup=contextBeginEndLua skipwhite skipempty |
| 86 | \ contains=initexComment |
| 87 | syn region contextBeginEndLua matchgroup=contextSpecial |
| 88 | \ start="{" end="}" skip="\\[{}]" |
| 89 | \ contained contains=@luaTop,@NoSpell |
| 90 | endif |
| 91 | |
| 92 | for synname in keys(s:context_include) |
| 93 | execute 'syn include @' . synname . 'Top' 'syntax/' . synname . '.vim' |
| 94 | unlet b:current_syntax |
| 95 | execute 'syn region context' . s:context_include[synname] . 'Code' |
| 96 | \ 'matchgroup=contextBlockDelim' |
| 97 | \ 'start=+\\start' . s:context_include[synname] . '+' |
| 98 | \ 'end=+\\stop' . s:context_include[synname] . '+' |
| 99 | \ 'contains=@' . synname . 'Top,@NoSpell' |
| 100 | endfor |
| 101 | |
| 102 | syn match contextSectioning '\\\%(start\|stop\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>' |
| 103 | \ contains=@NoSpell |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 104 | |
| 105 | syn match contextSpecial '\\crlf\>\|\\par\>\|-\{2,3}\||[<>/]\=|' |
| 106 | \ contains=@NoSpell |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 107 | syn match contextSpecial /\\[`'"]/ |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 108 | syn match contextSpecial +\\char\%(\d\{1,3}\|'\o\{1,3}\|"\x\{1,2}\)\>+ |
| 109 | \ contains=@NoSpell |
| 110 | syn match contextSpecial '\^\^.' |
| 111 | syn match contextSpecial '`\%(\\.\|\^\^.\|.\)' |
| 112 | |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 113 | syn match contextStyle '\\\%(em\|ss\|hw\|cg\|mf\)\>' |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 114 | \ contains=@NoSpell |
| 115 | syn match contextFont '\\\%(CAP\|Cap\|cap\|Caps\|kap\|nocap\)\>' |
| 116 | \ contains=@NoSpell |
| 117 | syn match contextFont '\\\%(Word\|WORD\|Words\|WORDS\)\>' |
| 118 | \ contains=@NoSpell |
| 119 | syn match contextFont '\\\%(vi\{1,3}\|ix\|xi\{0,2}\)\>' |
| 120 | \ contains=@NoSpell |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 121 | syn match contextFont '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>' |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 122 | \ contains=@NoSpell |
| 123 | |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 124 | hi def link contextOptions Typedef |
| 125 | hi def link contextComment Comment |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 126 | hi def link contextBlockDelim Keyword |
| 127 | hi def link contextBuiltin Keyword |
| 128 | hi def link contextDelimiter Delimiter |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 129 | hi def link contextEscaped String |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 130 | hi def link contextPreProc PreProc |
| 131 | hi def link contextSectioning PreProc |
| 132 | hi def link contextSpecial Special |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 133 | hi def link contextType Type |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 134 | hi def link contextStyle contextType |
| 135 | hi def link contextFont contextType |
Bram Moolenaar | 46fceaa | 2016-10-23 21:21:08 +0200 | [diff] [blame] | 136 | hi def link contextDirectLua Keyword |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 137 | |
| 138 | let b:current_syntax = "context" |
| 139 | |
| 140 | let &cpo = s:cpo_save |
| 141 | unlet s:cpo_save |