Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: ConTeXt typesetting engine |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 3 | " Maintainer: Nikolai Weibull <now@bitwi.se> |
| 4 | " Latest Revision: 2006-04-19 |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 5 | |
| 6 | if exists("b:current_syntax") |
| 7 | finish |
| 8 | endif |
| 9 | |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 10 | runtime! syntax/plaintex.vim |
| 11 | |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 12 | let s:cpo_save = &cpo |
| 13 | set cpo&vim |
| 14 | |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 15 | if !exists('g:context_include') |
| 16 | let g:context_include = ['mp', 'javascript', 'xml'] |
| 17 | endif |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 18 | |
| 19 | syn match contextBlockDelim display '\\\%(start\|stop\)\a\+' |
| 20 | \ contains=@NoSpell |
| 21 | |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 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='}' |
| 35 | |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 36 | syn match contextBuiltin display contains=@NoSpell |
| 37 | \ '\\\%(unprotect\|protect\|unexpanded\)' |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 38 | |
| 39 | syn match contextPreProc '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\).*$' |
| 40 | \ contains=@NoSpell |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 41 | |
| 42 | if 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 |
| 50 | endif |
| 51 | |
| 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 |
| 64 | |
| 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') |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 69 | |
| 70 | syn match contextSectioning '\\chapter\>' contains=@NoSpell |
| 71 | syn match contextSectioning '\\\%(sub\)*section\>' contains=@NoSpell |
| 72 | |
| 73 | syn match contextSpecial '\\crlf\>\|\\par\>\|-\{2,3}\||[<>/]\=|' |
| 74 | \ contains=@NoSpell |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 75 | syn match contextSpecial /\\[`'"]/ |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 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 '`\%(\\.\|\^\^.\|.\)' |
| 80 | |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 81 | syn match contextStyle '\\\%(em\|ss\|hw\|cg\|mf\)\>' |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 89 | syn match contextFont '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>' |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 90 | \ contains=@NoSpell |
| 91 | |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 98 | hi def link contextType Type |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 99 | hi def link contextStyle contextType |
| 100 | hi def link contextFont contextType |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 101 | |
| 102 | let b:current_syntax = "context" |
| 103 | |
| 104 | let &cpo = s:cpo_save |
| 105 | unlet s:cpo_save |