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