1
0
Fork 0
mirror of https://github.com/vim/vim synced 2025-03-23 18:25:13 +01:00
vim/runtime/syntax/context.vim

109 lines
4.1 KiB
VimL
Raw Normal View History

2005-06-29 22:40:58 +00:00
" Vim syntax file
" Language: ConTeXt typesetting engine
2006-04-21 22:12:41 +00:00
" Maintainer: Nikolai Weibull <now@bitwi.se>
2007-05-10 19:06:20 +00:00
" Latest Revision: 2006-08-10
2005-06-29 22:40:58 +00:00
if exists("b:current_syntax")
finish
endif
2006-04-21 22:12:41 +00:00
runtime! syntax/plaintex.vim
2007-05-10 19:06:20 +00:00
unlet b:current_syntax
2006-04-21 22:12:41 +00:00
2005-06-29 22:40:58 +00:00
let s:cpo_save = &cpo
set cpo&vim
2006-04-21 22:12:41 +00:00
if !exists('g:context_include')
let g:context_include = ['mp', 'javascript', 'xml']
endif
2005-06-29 22:40:58 +00:00
2007-05-10 19:06:20 +00:00
syn spell toplevel
2005-06-29 22:40:58 +00:00
syn match contextBlockDelim display '\\\%(start\|stop\)\a\+'
\ contains=@NoSpell
syn region contextEscaped display matchgroup=contextPreProc
\ start='\\type\z(\A\)' end='\z1'
syn region contextEscaped display matchgroup=contextPreProc
\ start='\\type\={' end='}'
syn region contextEscaped display matchgroup=contextPreProc
\ start='\\type\=<<' end='>>'
syn region contextEscaped matchgroup=contextPreProc
\ start='\\start\z(\a*\%(typing\|typen\)\)'
2007-05-10 19:06:20 +00:00
\ end='\\stop\z1' contains=plaintexComment keepend
2005-06-29 22:40:58 +00:00
syn region contextEscaped display matchgroup=contextPreProc
\ start='\\\h\+Type{' end='}'
syn region contextEscaped display matchgroup=contextPreProc
\ start='\\Typed\h\+{' end='}'
2006-04-21 22:12:41 +00:00
syn match contextBuiltin display contains=@NoSpell
\ '\\\%(unprotect\|protect\|unexpanded\)'
2005-06-29 22:40:58 +00:00
syn match contextPreProc '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\).*$'
\ contains=@NoSpell
2006-04-21 22:12:41 +00:00
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')
2005-06-29 22:40:58 +00:00
syn match contextSectioning '\\chapter\>' contains=@NoSpell
syn match contextSectioning '\\\%(sub\)*section\>' contains=@NoSpell
syn match contextSpecial '\\crlf\>\|\\par\>\|-\{2,3}\||[<>/]\=|'
\ contains=@NoSpell
2006-04-21 22:12:41 +00:00
syn match contextSpecial /\\[`'"]/
2005-06-29 22:40:58 +00:00
syn match contextSpecial +\\char\%(\d\{1,3}\|'\o\{1,3}\|"\x\{1,2}\)\>+
\ contains=@NoSpell
syn match contextSpecial '\^\^.'
syn match contextSpecial '`\%(\\.\|\^\^.\|.\)'
2006-04-21 22:12:41 +00:00
syn match contextStyle '\\\%(em\|ss\|hw\|cg\|mf\)\>'
2005-06-29 22:40:58 +00:00
\ contains=@NoSpell
syn match contextFont '\\\%(CAP\|Cap\|cap\|Caps\|kap\|nocap\)\>'
\ contains=@NoSpell
syn match contextFont '\\\%(Word\|WORD\|Words\|WORDS\)\>'
\ contains=@NoSpell
syn match contextFont '\\\%(vi\{1,3}\|ix\|xi\{0,2}\)\>'
\ contains=@NoSpell
2006-04-21 22:12:41 +00:00
syn match contextFont '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>'
2005-06-29 22:40:58 +00:00
\ contains=@NoSpell
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
2006-04-21 22:12:41 +00:00
hi def link contextType Type
2005-06-29 22:40:58 +00:00
hi def link contextStyle contextType
hi def link contextFont contextType
let b:current_syntax = "context"
let &cpo = s:cpo_save
unlet s:cpo_save