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