0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00
vim/runtime/syntax/context.vim

142 lines
6.1 KiB
VimL
Raw Normal View History

2005-06-29 22:40:58 +00:00
" Vim syntax file
2016-10-23 21:21:08 +02:00
" Language: ConTeXt typesetting engine
" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
" Former Maintainers: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2016 Oct 16
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
2016-10-23 21:21:08 +02:00
" Dictionary of (filetype, group) pairs to highlight between \startGROUP \stopGROUP.
let s:context_include = get(b:, 'context_include', get(g:, 'context_include', {'xml': 'XML'}))
" For backward compatibility (g:context_include used to be a List)
if type(s:context_include) ==# type([])
let g:context_metapost = (index(s:context_include, 'mp') != -1)
let s:context_include = filter(
\ {'c': 'C', 'javascript': 'JS', 'ruby': 'Ruby', 'xml': 'XML'},
\ { k,_ -> index(s:context_include, k) != -1 }
\ )
2006-04-21 22:12:41 +00:00
endif
2005-06-29 22:40:58 +00:00
2016-10-23 21:21:08 +02:00
syn iskeyword @,48-57,a-z,A-Z,192-255
2007-05-10 19:06:20 +00:00
syn spell toplevel
2016-10-23 21:21:08 +02:00
" ConTeXt options, i.e., [...] blocks
syn region contextOptions matchgroup=contextDelimiter start='\[' end=']\|\ze\\stop' skip='\\\[\|\\\]' contains=ALLBUT,contextBeginEndLua,@Spell
" Highlight braces
syn match contextDelimiter '[{}]'
2005-06-29 22:40:58 +00:00
2016-10-23 21:21:08 +02:00
" Comments
syn match contextComment '\\\@<!\%(\\\\\)*\zs%.*$' display contains=initexTodo
syn match contextComment '^\s*%[CDM].*$' display contains=initexTodo
syn match contextBlockDelim '\\\%(start\|stop\)\a\+' contains=@NoSpell
syn region contextEscaped matchgroup=contextPreProc start='\\type\%(\s*\|\n\)*\z([^A-Za-z%]\)' end='\z1'
syn region contextEscaped matchgroup=contextPreProc start='\\type\=\%(\s\|\n\)*{' end='}'
syn region contextEscaped matchgroup=contextPreProc start='\\type\=\%(\s*\|\n\)*<<' end='>>'
2005-06-29 22:40:58 +00:00
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
2016-10-23 21:21:08 +02:00
syn region contextEscaped matchgroup=contextPreProc start='\\\h\+Type\%(\s\|\n\)*{' end='}'
syn region contextEscaped matchgroup=contextPreProc start='\\Typed\h\+\%(\s\|\n\)*{' end='}'
2005-06-29 22:40:58 +00:00
2006-04-21 22:12:41 +00:00
syn match contextBuiltin display contains=@NoSpell
2016-10-23 21:21:08 +02:00
\ '\\\%(unprotect\|protect\|unexpanded\)\>'
2005-06-29 22:40:58 +00:00
2016-10-23 21:21:08 +02:00
syn match contextPreProc '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\)\>'
2005-06-29 22:40:58 +00:00
\ contains=@NoSpell
2006-04-21 22:12:41 +00:00
2016-10-23 21:21:08 +02:00
if get(b:, 'context_metapost', get(g:, 'context_metapost', 1))
let b:mp_metafun_macros = 1 " Highlight MetaFun keywords
2006-04-21 22:12:41 +00:00
syn include @mpTop syntax/mp.vim
unlet b:current_syntax
2016-10-23 21:21:08 +02:00
syn region contextMPGraphic matchgroup=contextBlockDelim
\ start='\\start\z(MP\%(clip\|code\|definitions\|drawing\|environment\|extensions\|inclusions\|initializations\|page\|\)\)\>.*$'
\ end='\\stop\z1'
\ contains=@mpTop,@NoSpell
syn region contextMPGraphic matchgroup=contextBlockDelim
\ start='\\start\z(\%(\%[re]usable\|use\|unique\|static\)MPgraphic\|staticMPfigure\|uniqueMPpagegraphic\)\>.*$'
2006-04-21 22:12:41 +00:00
\ end='\\stop\z1'
2016-10-23 21:21:08 +02:00
\ contains=@mpTop,@NoSpell
2006-04-21 22:12:41 +00:00
endif
2016-10-23 21:21:08 +02:00
if get(b:, 'context_lua', get(g:, 'context_lua', 1))
syn include @luaTop syntax/lua.vim
unlet b:current_syntax
syn region contextLuaCode matchgroup=contextBlockDelim
\ start='\\startluacode\>'
\ end='\\stopluacode\>' keepend
\ contains=@luaTop,@NoSpell
syn match contextDirectLua "\\\%(directlua\|ctxlua\)\>\%(\s*%.*$\)\="
\ nextgroup=contextBeginEndLua skipwhite skipempty
\ contains=initexComment
syn region contextBeginEndLua matchgroup=contextSpecial
\ start="{" end="}" skip="\\[{}]"
\ contained contains=@luaTop,@NoSpell
endif
for synname in keys(s:context_include)
execute 'syn include @' . synname . 'Top' 'syntax/' . synname . '.vim'
unlet b:current_syntax
execute 'syn region context' . s:context_include[synname] . 'Code'
\ 'matchgroup=contextBlockDelim'
\ 'start=+\\start' . s:context_include[synname] . '+'
\ 'end=+\\stop' . s:context_include[synname] . '+'
\ 'contains=@' . synname . 'Top,@NoSpell'
endfor
syn match contextSectioning '\\\%(start\|stop\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>'
\ contains=@NoSpell
2005-06-29 22:40:58 +00:00
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
2016-10-23 21:21:08 +02:00
hi def link contextOptions Typedef
hi def link contextComment Comment
2005-06-29 22:40:58 +00:00
hi def link contextBlockDelim Keyword
hi def link contextBuiltin Keyword
hi def link contextDelimiter Delimiter
2016-10-23 21:21:08 +02:00
hi def link contextEscaped String
2005-06-29 22:40:58 +00:00
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
2016-10-23 21:21:08 +02:00
hi def link contextDirectLua Keyword
2005-06-29 22:40:58 +00:00
let b:current_syntax = "context"
let &cpo = s:cpo_save
unlet s:cpo_save