xref: /vim-8.2.3635/runtime/syntax/context.vim (revision cb03397a)
1" Vim syntax file
2" Language:         ConTeXt typesetting engine
3" Maintainer:       Nikolai Weibull <[email protected]>
4" Latest Revision:  2006-08-10
5
6if exists("b:current_syntax")
7  finish
8endif
9
10runtime! syntax/plaintex.vim
11unlet b:current_syntax
12
13let s:cpo_save = &cpo
14set cpo&vim
15
16if !exists('g:context_include')
17  let g:context_include = ['mp', 'javascript', 'xml']
18endif
19
20syn spell   toplevel
21
22syn match   contextBlockDelim display '\\\%(start\|stop\)\a\+'
23                              \ contains=@NoSpell
24
25syn region  contextEscaped    display matchgroup=contextPreProc
26                              \ start='\\type\z(\A\)' end='\z1'
27syn region  contextEscaped    display matchgroup=contextPreProc
28                              \ start='\\type\={' end='}'
29syn region  contextEscaped    display matchgroup=contextPreProc
30                              \ start='\\type\=<<' end='>>'
31syn region  contextEscaped    matchgroup=contextPreProc
32                              \ start='\\start\z(\a*\%(typing\|typen\)\)'
33                              \ end='\\stop\z1' contains=plaintexComment keepend
34syn region  contextEscaped    display matchgroup=contextPreProc
35                              \ start='\\\h\+Type{' end='}'
36syn region  contextEscaped    display matchgroup=contextPreProc
37                              \ start='\\Typed\h\+{' end='}'
38
39syn match   contextBuiltin    display contains=@NoSpell
40      \ '\\\%(unprotect\|protect\|unexpanded\)'
41
42syn match   contextPreProc    '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\).*$'
43                              \ contains=@NoSpell
44
45if index(g:context_include, 'mp') != -1
46  syn include @mpTop          syntax/mp.vim
47  unlet b:current_syntax
48
49  syn region  contextMPGraphic  transparent matchgroup=contextBlockDelim
50                                \ start='\\start\z(\a*MPgraphic\|MP\%(page\|inclusions\|run\)\).*'
51                                \ end='\\stop\z1'
52                                \ contains=@mpTop
53endif
54
55" TODO: also need to implement this for \\typeC or something along those
56" lines.
57function! 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'
65  endif
66endfunction
67
68call s:include_syntax('c', 'C')
69call s:include_syntax('ruby', 'Ruby')
70call s:include_syntax('javascript', 'JS')
71call s:include_syntax('xml', 'XML')
72
73syn match   contextSectioning '\\chapter\>' contains=@NoSpell
74syn match   contextSectioning '\\\%(sub\)*section\>' contains=@NoSpell
75
76syn match   contextSpecial    '\\crlf\>\|\\par\>\|-\{2,3}\||[<>/]\=|'
77                              \ contains=@NoSpell
78syn match   contextSpecial    /\\[`'"]/
79syn match   contextSpecial    +\\char\%(\d\{1,3}\|'\o\{1,3}\|"\x\{1,2}\)\>+
80                              \ contains=@NoSpell
81syn match   contextSpecial    '\^\^.'
82syn match   contextSpecial    '`\%(\\.\|\^\^.\|.\)'
83
84syn match   contextStyle      '\\\%(em\|ss\|hw\|cg\|mf\)\>'
85                              \ contains=@NoSpell
86syn match   contextFont       '\\\%(CAP\|Cap\|cap\|Caps\|kap\|nocap\)\>'
87                              \ contains=@NoSpell
88syn match   contextFont       '\\\%(Word\|WORD\|Words\|WORDS\)\>'
89                              \ contains=@NoSpell
90syn match   contextFont       '\\\%(vi\{1,3}\|ix\|xi\{0,2}\)\>'
91                              \ contains=@NoSpell
92syn match   contextFont       '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>'
93                              \ contains=@NoSpell
94
95hi def link contextBlockDelim Keyword
96hi def link contextBuiltin    Keyword
97hi def link contextDelimiter  Delimiter
98hi def link contextPreProc    PreProc
99hi def link contextSectioning PreProc
100hi def link contextSpecial    Special
101hi def link contextType       Type
102hi def link contextStyle      contextType
103hi def link contextFont       contextType
104
105let b:current_syntax = "context"
106
107let &cpo = s:cpo_save
108unlet s:cpo_save
109