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> |
Bram Moolenaar | 2539402 | 2007-05-10 19:06:20 +0000 | [diff] [blame] | 4 | " Latest Revision: 2006-08-10 |
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 |
Bram Moolenaar | 2539402 | 2007-05-10 19:06:20 +0000 | [diff] [blame] | 11 | unlet b:current_syntax |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 12 | |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 13 | let s:cpo_save = &cpo |
| 14 | set cpo&vim |
| 15 | |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 16 | if !exists('g:context_include') |
| 17 | let g:context_include = ['mp', 'javascript', 'xml'] |
| 18 | endif |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 19 | |
Bram Moolenaar | 2539402 | 2007-05-10 19:06:20 +0000 | [diff] [blame] | 20 | syn spell toplevel |
| 21 | |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 22 | syn match contextBlockDelim display '\\\%(start\|stop\)\a\+' |
| 23 | \ contains=@NoSpell |
| 24 | |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 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\)\)' |
Bram Moolenaar | 2539402 | 2007-05-10 19:06:20 +0000 | [diff] [blame] | 33 | \ end='\\stop\z1' contains=plaintexComment keepend |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 34 | syn region contextEscaped display matchgroup=contextPreProc |
| 35 | \ start='\\\h\+Type{' end='}' |
| 36 | syn region contextEscaped display matchgroup=contextPreProc |
| 37 | \ start='\\Typed\h\+{' end='}' |
| 38 | |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 39 | syn match contextBuiltin display contains=@NoSpell |
| 40 | \ '\\\%(unprotect\|protect\|unexpanded\)' |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 41 | |
| 42 | syn match contextPreProc '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\).*$' |
| 43 | \ contains=@NoSpell |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 44 | |
| 45 | if 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 |
| 53 | endif |
| 54 | |
| 55 | " TODO: also need to implement this for \\typeC or something along those |
| 56 | " lines. |
| 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' |
| 65 | endif |
| 66 | endfunction |
| 67 | |
| 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') |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 72 | |
| 73 | syn match contextSectioning '\\chapter\>' contains=@NoSpell |
| 74 | syn match contextSectioning '\\\%(sub\)*section\>' contains=@NoSpell |
| 75 | |
| 76 | syn match contextSpecial '\\crlf\>\|\\par\>\|-\{2,3}\||[<>/]\=|' |
| 77 | \ contains=@NoSpell |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 78 | syn match contextSpecial /\\[`'"]/ |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 79 | syn match contextSpecial +\\char\%(\d\{1,3}\|'\o\{1,3}\|"\x\{1,2}\)\>+ |
| 80 | \ contains=@NoSpell |
| 81 | syn match contextSpecial '\^\^.' |
| 82 | syn match contextSpecial '`\%(\\.\|\^\^.\|.\)' |
| 83 | |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 84 | syn match contextStyle '\\\%(em\|ss\|hw\|cg\|mf\)\>' |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 85 | \ contains=@NoSpell |
| 86 | syn match contextFont '\\\%(CAP\|Cap\|cap\|Caps\|kap\|nocap\)\>' |
| 87 | \ contains=@NoSpell |
| 88 | syn match contextFont '\\\%(Word\|WORD\|Words\|WORDS\)\>' |
| 89 | \ contains=@NoSpell |
| 90 | syn match contextFont '\\\%(vi\{1,3}\|ix\|xi\{0,2}\)\>' |
| 91 | \ contains=@NoSpell |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 92 | syn match contextFont '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>' |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 93 | \ contains=@NoSpell |
| 94 | |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 101 | hi def link contextType Type |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 102 | hi def link contextStyle contextType |
| 103 | hi def link contextFont contextType |
Bram Moolenaar | 42eeac3 | 2005-06-29 22:40:58 +0000 | [diff] [blame] | 104 | |
| 105 | let b:current_syntax = "context" |
| 106 | |
| 107 | let &cpo = s:cpo_save |
| 108 | unlet s:cpo_save |