diff options
Diffstat (limited to 'runtime/syntax/context.vim')
-rw-r--r-- | runtime/syntax/context.vim | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/runtime/syntax/context.vim b/runtime/syntax/context.vim index 1b3d2446f..93b14b194 100644 --- a/runtime/syntax/context.vim +++ b/runtime/syntax/context.vim @@ -1,30 +1,24 @@ " Vim syntax file " Language: ConTeXt typesetting engine -" Maintainer: Nikolai Weibull <nikolai+work.vim@bitwi.se> -" Latest Revision: 2005-07-04 +" Maintainer: Nikolai Weibull <now@bitwi.se> +" Latest Revision: 2006-04-19 if exists("b:current_syntax") finish endif +runtime! syntax/plaintex.vim + let s:cpo_save = &cpo set cpo&vim -syn keyword contextTodo TODO FIXME XXX NOTE - -syn region contextComment display oneline start='%' end='$' - \ contains=contextTodo -syn region contextComment display oneline start='^\s*%[CDM]' end='$' - \ contains=ALL - -syn match contextStatement display '\\[a-zA-Z@]\+' contains=@NoSpell +if !exists('g:context_include') + let g:context_include = ['mp', 'javascript', 'xml'] +endif syn match contextBlockDelim display '\\\%(start\|stop\)\a\+' \ contains=@NoSpell -syn match contextDelimiter '[][{}]' - -syn match contextEscaped display '\\\_[\{}|&%$ ]' syn region contextEscaped display matchgroup=contextPreProc \ start='\\type\z(\A\)' end='\z1' syn region contextEscaped display matchgroup=contextPreProc @@ -39,34 +33,52 @@ syn region contextEscaped display matchgroup=contextPreProc syn region contextEscaped display matchgroup=contextPreProc \ start='\\Typed\h\+{' end='}' -"syn region contextMath matchgroup=contextMath start='\$' end='\$' -" \ contains=contextStatement - -syn match contextBuiltin '\\\%(newif\|def\|gdef\|global\|let\|glet\|bgroup\)\>' - \ contains=@NoSpell -syn match contextBuiltin '\\\%(begingroup\|egroup\|endgroup\|long\|catcode\)\>' - \ contains=@NoSpell -syn match contextBuiltin '\\\%(unprotect\|unexpanded\|if\|else\|fi\|ifx\)\>' - \ contains=@NoSpell -syn match contextBuiltin '\\\%(futurelet\|protect\)\>' contains=@NoSpell -syn match contextBuiltin '\\\%([lr]q\)\>' contains=@NoSpell +syn match contextBuiltin display contains=@NoSpell + \ '\\\%(unprotect\|protect\|unexpanded\)' syn match contextPreProc '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\).*$' \ contains=@NoSpell -syn match contextPreProc '^\s*\\input\s\+.*$' contains=@NoSpell + +if index(g:context_include, 'mp') != -1 + syn include @mpTop syntax/mp.vim + unlet b:current_syntax + + syn region contextMPGraphic transparent matchgroup=contextBlockDelim + \ start='\\start\z(\a*MPgraphic\|MP\%(page\|inclusions\|run\)\).*' + \ end='\\stop\z1' + \ contains=@mpTop +endif + +" TODO: also need to implement this for \\typeC or something along those +" lines. +function! s:include_syntax(name, group) + if index(g:context_include, a:name) != -1 + execute 'syn include @' . a:name . 'Top' 'syntax/' . a:name . '.vim' + unlet b:current_syntax + execute 'syn region context' . a:group . 'Code' + \ 'transparent matchgroup=contextBlockDelim' + \ 'start=+\\start' . a:group . '+ end=+\\stop' . a:group . '+' + \ 'contains=@' . a:name . 'Top' + endif +endfunction + +call s:include_syntax('c', 'C') +call s:include_syntax('ruby', 'Ruby') +call s:include_syntax('javascript', 'JS') +call s:include_syntax('xml', 'XML') syn match contextSectioning '\\chapter\>' contains=@NoSpell syn match contextSectioning '\\\%(sub\)*section\>' contains=@NoSpell syn match contextSpecial '\\crlf\>\|\\par\>\|-\{2,3}\||[<>/]\=|' \ contains=@NoSpell -syn match contextSpecial '\\[`'"]' +syn match contextSpecial /\\[`'"]/ syn match contextSpecial +\\char\%(\d\{1,3}\|'\o\{1,3}\|"\x\{1,2}\)\>+ \ contains=@NoSpell syn match contextSpecial '\^\^.' syn match contextSpecial '`\%(\\.\|\^\^.\|.\)' -syn match contextStyle '\\\%(em\|tt\|rm\|ss\|hw\|cg\)\>' +syn match contextStyle '\\\%(em\|ss\|hw\|cg\|mf\)\>' \ contains=@NoSpell syn match contextFont '\\\%(CAP\|Cap\|cap\|Caps\|kap\|nocap\)\>' \ contains=@NoSpell @@ -74,29 +86,18 @@ syn match contextFont '\\\%(Word\|WORD\|Words\|WORDS\)\>' \ contains=@NoSpell syn match contextFont '\\\%(vi\{1,3}\|ix\|xi\{0,2}\)\>' \ contains=@NoSpell -syn match contextFont '\\\%(tf[abcdx]\|bfx\|[is]lx\)\>' - \ contains=@NoSpell -syn match contextFont '\\\%(b[fsi]\|s[cl]\|it\|os\|mf\)\>' +syn match contextFont '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>' \ contains=@NoSpell -syn match contextDimension '[+-]\=\s*\%(\d\+\%([.,]\d*\)\=\|[.,]\d\+\)\s*\%(true\)\=\s*\%(p[tc]\|in\|bp\|c[mc]\|mm\|dd\|sp\|e[mx]\)\>' - \ contains=@NoSpell - -hi def link contextTodo Todo -hi def link contextComment Comment -hi def link contextEscaped Special -hi def link contextStatement Identifier -hi def link contextMath String hi def link contextBlockDelim Keyword hi def link contextBuiltin Keyword hi def link contextDelimiter Delimiter hi def link contextPreProc PreProc hi def link contextSectioning PreProc hi def link contextSpecial Special +hi def link contextType Type hi def link contextStyle contextType hi def link contextFont contextType -hi def link contextType Type -hi def link contextDimension Number let b:current_syntax = "context" |