2 " Language: ConTeXt typesetting engine
3 " Maintainer: Nikolai Weibull <now@bitwi.se>
4 " Latest Revision: 2006-04-19
6 if exists("b:current_syntax")
10 runtime! syntax/plaintex.vim
15 if !exists('g:context_include')
16 let g:context_include = ['mp', 'javascript', 'xml']
19 syn match contextBlockDelim display '\\\%(start\|stop\)\a\+'
22 syn region contextEscaped display matchgroup=contextPreProc
23 \ start='\\type\z(\A\)' end='\z1'
24 syn region contextEscaped display matchgroup=contextPreProc
25 \ start='\\type\={' end='}'
26 syn region contextEscaped display matchgroup=contextPreProc
27 \ start='\\type\=<<' end='>>'
28 syn region contextEscaped matchgroup=contextPreProc
29 \ start='\\start\z(\a*\%(typing\|typen\)\)'
31 syn region contextEscaped display matchgroup=contextPreProc
32 \ start='\\\h\+Type{' end='}'
33 syn region contextEscaped display matchgroup=contextPreProc
34 \ start='\\Typed\h\+{' end='}'
36 syn match contextBuiltin display contains=@NoSpell
37 \ '\\\%(unprotect\|protect\|unexpanded\)'
39 syn match contextPreProc '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\).*$'
42 if index(g:context_include, 'mp') != -1
43 syn include @mpTop syntax/mp.vim
44 unlet b:current_syntax
46 syn region contextMPGraphic transparent matchgroup=contextBlockDelim
47 \ start='\\start\z(\a*MPgraphic\|MP\%(page\|inclusions\|run\)\).*'
52 " TODO: also need to implement this for \\typeC or something along those
54 function! s:include_syntax(name, group)
55 if index(g:context_include, a:name) != -1
56 execute 'syn include @' . a:name . 'Top' 'syntax/' . a:name . '.vim'
57 unlet b:current_syntax
58 execute 'syn region context' . a:group . 'Code'
59 \ 'transparent matchgroup=contextBlockDelim'
60 \ 'start=+\\start' . a:group . '+ end=+\\stop' . a:group . '+'
61 \ 'contains=@' . a:name . 'Top'
65 call s:include_syntax('c', 'C')
66 call s:include_syntax('ruby', 'Ruby')
67 call s:include_syntax('javascript', 'JS')
68 call s:include_syntax('xml', 'XML')
70 syn match contextSectioning '\\chapter\>' contains=@NoSpell
71 syn match contextSectioning '\\\%(sub\)*section\>' contains=@NoSpell
73 syn match contextSpecial '\\crlf\>\|\\par\>\|-\{2,3}\||[<>/]\=|'
75 syn match contextSpecial /\\[`'"]/
76 syn match contextSpecial +\\char\%(\d\{1,3}\|'\o\{1,3}\|"\x\{1,2}\)\>+
78 syn match contextSpecial '\^\^.'
79 syn match contextSpecial '`\%(\\.\|\^\^.\|.\)'
81 syn match contextStyle '\\\%(em\|ss\|hw\|cg\|mf\)\>'
83 syn match contextFont '\\\%(CAP\|Cap\|cap\|Caps\|kap\|nocap\)\>'
85 syn match contextFont '\\\%(Word\|WORD\|Words\|WORDS\)\>'
87 syn match contextFont '\\\%(vi\{1,3}\|ix\|xi\{0,2}\)\>'
89 syn match contextFont '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>'
92 hi def link contextBlockDelim Keyword
93 hi def link contextBuiltin Keyword
94 hi def link contextDelimiter Delimiter
95 hi def link contextPreProc PreProc
96 hi def link contextSectioning PreProc
97 hi def link contextSpecial Special
98 hi def link contextType Type
99 hi def link contextStyle contextType
100 hi def link contextFont contextType
102 let b:current_syntax = "context"
104 let &cpo = s:cpo_save