Sync with newest CVS repository.
[MacVim/jjgod.git] / runtime / syntax / context.vim
blob93b14b194f7e0d2aea9df3f9ace71bb79507df92
1 " Vim syntax file
2 " Language:         ConTeXt typesetting engine
3 " Maintainer:       Nikolai Weibull <now@bitwi.se>
4 " Latest Revision:  2006-04-19
6 if exists("b:current_syntax")
7   finish
8 endif
10 runtime! syntax/plaintex.vim
12 let s:cpo_save = &cpo
13 set cpo&vim
15 if !exists('g:context_include')
16   let g:context_include = ['mp', 'javascript', 'xml']
17 endif
19 syn match   contextBlockDelim display '\\\%(start\|stop\)\a\+'
20                               \ contains=@NoSpell
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\)\)'
30                               \ end='\\stop\z1'
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\).*$'
40                               \ contains=@NoSpell
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\)\).*'
48                                 \ end='\\stop\z1'
49                                 \ contains=@mpTop
50 endif
52 " TODO: also need to implement this for \\typeC or something along those
53 " lines.
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'
62   endif
63 endfunction
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}\||[<>/]\=|'
74                               \ contains=@NoSpell
75 syn match   contextSpecial    /\\[`'"]/
76 syn match   contextSpecial    +\\char\%(\d\{1,3}\|'\o\{1,3}\|"\x\{1,2}\)\>+
77                               \ contains=@NoSpell
78 syn match   contextSpecial    '\^\^.'
79 syn match   contextSpecial    '`\%(\\.\|\^\^.\|.\)'
81 syn match   contextStyle      '\\\%(em\|ss\|hw\|cg\|mf\)\>'
82                               \ contains=@NoSpell
83 syn match   contextFont       '\\\%(CAP\|Cap\|cap\|Caps\|kap\|nocap\)\>'
84                               \ contains=@NoSpell
85 syn match   contextFont       '\\\%(Word\|WORD\|Words\|WORDS\)\>'
86                               \ contains=@NoSpell
87 syn match   contextFont       '\\\%(vi\{1,3}\|ix\|xi\{0,2}\)\>'
88                               \ contains=@NoSpell
89 syn match   contextFont       '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>'
90                               \ contains=@NoSpell
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
105 unlet s:cpo_save