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