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