summaryrefslogtreecommitdiff
path: root/runtime/syntax/context.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-08-15 18:51:32 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-15 18:51:32 +0100
commite1f3fd1d02e3f5fe6d2b6d82687c6846b8e500f8 (patch)
treef00150bb6e9c2813a69adef48cea5d43c0680c32 /runtime/syntax/context.vim
parent5a4fff4d948cd12a5cf5f637ad2c561815a77d8e (diff)
downloadvim-git-e1f3fd1d02e3f5fe6d2b6d82687c6846b8e500f8.tar.gz
Update runtime files
Diffstat (limited to 'runtime/syntax/context.vim')
-rw-r--r--runtime/syntax/context.vim187
1 files changed, 95 insertions, 92 deletions
diff --git a/runtime/syntax/context.vim b/runtime/syntax/context.vim
index b29f256ba..08ab1f698 100644
--- a/runtime/syntax/context.vim
+++ b/runtime/syntax/context.vim
@@ -1,141 +1,144 @@
-" Vim syntax file
-" Language: ConTeXt typesetting engine
-" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
-" Former Maintainers: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2016 Oct 16
+vim9script
+
+# Vim syntax file
+# Language: ConTeXt typesetting engine
+# Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
+# Former Maintainers: Nikolai Weibull <now@bitwi.se>
+# Latest Revision: 2022 Aug 12
if exists("b:current_syntax")
finish
endif
-runtime! syntax/plaintex.vim
-unlet b:current_syntax
+# Dictionary of (filetype, group) pairs to highlight between \startGROUP \stopGROUP.
+var context_include = get(b:, 'context_include', get(g:, 'context_include', {'xml': 'XML'}))
-let s:cpo_save = &cpo
-set cpo&vim
+# Deprecation warning
+if type(context_include) ==# type([])
+ echomsg "[ConTeXt] b:context_include/g:context_include must be Dictionaries."
+ context_include = {'xml': 'XML'}
+endif
-" Dictionary of (filetype, group) pairs to highlight between \startGROUP \stopGROUP.
-let s:context_include = get(b:, 'context_include', get(g:, 'context_include', {'xml': 'XML'}))
+syn iskeyword @,48-57,_,!,?,a-z,A-Z,192-255
-" 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 }
- \ )
-endif
+syn spell toplevel
-syn iskeyword @,48-57,a-z,A-Z,192-255
+runtime! syntax/shared/context-data-context.vim
+runtime! syntax/shared/context-data-interfaces.vim
+runtime! syntax/shared/context-data-tex.vim
-syn spell toplevel
+syn match contextCommand '\\\k\+\>' display contains=@NoSpell
-" ConTeXt options, i.e., [...] blocks
-syn region contextOptions matchgroup=contextDelimiter start='\[' end=']\|\ze\\stop' skip='\\\[\|\\\]' contains=ALLBUT,contextBeginEndLua,@Spell
+# ConTeXt options, i.e., [...] blocks
+syn region contextOptions matchgroup=contextDelimiter start='\[' end=']\|\ze\\stop' skip='\\\[\|\\\]' contains=TOP,@Spell
-" Highlight braces
+# Highlight braces
syn match contextDelimiter '[{}]'
-" Comments
-syn match contextComment '\\\@<!\%(\\\\\)*\zs%.*$' display contains=initexTodo
-syn match contextComment '^\s*%[CDM].*$' display contains=initexTodo
+# Comments
+syn match contextComment '\%(\_^\|[^\\]\)\%(\\\\\)*\zs%.*$' display contains=contextTodo,contextMagicLine
+syn match contextComment '^\s*%[CDM].*$' display contains=contextTodo,contextMagicLine
+syn keyword contextTodo TODO FIXME XXX NOTE contained
+syn match contextMagicLine '^\s*%\s*!TEX.*$' contained
-syn match contextBlockDelim '\\\%(start\|stop\)\a\+' contains=@NoSpell
+syn match contextBlockDelim '\\\%(start\|stop\)\k\+' 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='>>'
syn region contextEscaped matchgroup=contextPreProc
\ start='\\start\z(\a*\%(typing\|typen\)\)'
- \ end='\\stop\z1' contains=plaintexComment keepend
+ \ end='\\stop\z1' contains=contextComment keepend
syn region contextEscaped matchgroup=contextPreProc start='\\\h\+Type\%(\s\|\n\)*{' end='}'
syn region contextEscaped matchgroup=contextPreProc start='\\Typed\h\+\%(\s\|\n\)*{' end='}'
-syn match contextBuiltin display contains=@NoSpell
- \ '\\\%(unprotect\|protect\|unexpanded\)\>'
+syn match contextBuiltin '\\unexpanded\>' display contains=@NoSpell
-syn match contextPreProc '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\)\>'
- \ contains=@NoSpell
+# \unprotect... \protect regions
+syn region contextUnprotect matchgroup=contextBuiltin start='\\unprotect' end='\\protect' contains=TOP
+syn match contextSequence '\\[a-zA-Z]*[@_!?]\+[a-zA-Z@_!?]*' contains=@NoSpell contained containedin=contextUnprotect
-if get(b:, 'context_metapost', get(g:, 'context_metapost', 1))
- let b:mp_metafun_macros = 1 " Highlight MetaFun keywords
- syn include @mpTop syntax/mp.vim
- unlet b:current_syntax
+# Math
+syn match contextMathCmd '\\m\%(ath\%(ematics\)\=\)\=\>'
+syn region contextInlineMath matchgroup=contextMathDelim start='\$' skip='\\\\\|\\\$' end='\$'
+syn region contextDisplayMath matchgroup=contextMathDelim start='\$\$' skip='\\\\\|\\\$' end='\$\$' keepend
+syn region contextDisplayMath matchgroup=contextBlockDelim start='\\startformula' end='\\stopformula' contains=TOP
- 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\)\>.*$'
- \ end='\\stop\z1'
- \ contains=@mpTop,@NoSpell
-endif
-
-if get(b:, 'context_lua', get(g:, 'context_lua', 1))
- syn include @luaTop syntax/lua.vim
- unlet b:current_syntax
+# MetaFun
+b:mp_metafun = 1
+syn include @mpTop syntax/mp.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
+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\)\>.*$'
+ \ end='\\stop\z1'
+ \ contains=@mpTop,@NoSpell
+
+# Lua
+syn include @luaTop syntax/lua.vim
+unlet b:current_syntax
-for synname in keys(s:context_include)
- execute 'syn include @' . synname . 'Top' 'syntax/' . synname . '.vim'
+syn region contextLuaCode matchgroup=contextBlockDelim
+ \ start='\\startluacode\>'
+ \ end='\\stopluacode\>' keepend
+ \ contains=@luaTop,@NoSpell
+syn match contextDirectLua "\\\%(directlua\|ctxlua\)\>\%(\s*%.*$\)\="
+ \ nextgroup=contextBeginEndLua skipwhite skipempty
+ \ contains=contextComment
+syn region contextBeginEndLua matchgroup=contextSpecial
+ \ start="{" end="}" skip="\\[{}]"
+ \ contained contains=@luaTop,@NoSpell
+
+for synname in keys(context_include)
+ execute 'syn include @' .. synname .. 'Top' 'syntax/' .. synname .. '.vim'
unlet b:current_syntax
- execute 'syn region context' . s:context_include[synname] . 'Code'
+ execute 'syn region context' .. context_include[synname] .. 'Code'
\ 'matchgroup=contextBlockDelim'
- \ 'start=+\\start' . s:context_include[synname] . '+'
- \ 'end=+\\stop' . s:context_include[synname] . '+'
- \ 'contains=@' . synname . 'Top,@NoSpell'
+ \ 'start=+\\start' .. context_include[synname] .. '\w*+'
+ \ 'end=+\\stop' .. context_include[synname] .. '\w*+'
+ \ 'contains=@' .. synname .. 'Top,@NoSpell'
endfor
-syn match contextSectioning '\\\%(start\|stop\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>'
- \ contains=@NoSpell
+syn match contextSectioning '\\\%(start\|stop\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>' contains=@NoSpell
-syn match contextSpecial '\\crlf\>\|\\par\>\|-\{2,3}\||[<>/]\=|'
- \ contains=@NoSpell
+syn match contextSpecial '\\par\>\|-\{2,3}\||[<>/]\=|' contains=@NoSpell
syn match contextSpecial /\\[`'"]/
-syn match contextSpecial +\\char\%(\d\{1,3}\|'\o\{1,3}\|"\x\{1,2}\)\>+
- \ contains=@NoSpell
+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\|ss\|hw\|cg\|mf\)\>'
- \ 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
-syn match contextFont '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>'
- \ contains=@NoSpell
+syn match contextStyle '\\\%(em\|ss\|hw\|cg\|mf\)\>' 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
+syn match contextFont '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>' contains=@NoSpell
-hi def link contextOptions Typedef
-hi def link contextComment Comment
hi def link contextBlockDelim Keyword
hi def link contextBuiltin Keyword
+hi def link contextCommand Keyword
+hi def link contextComment Comment
hi def link contextDelimiter Delimiter
+hi def link contextDirectLua Keyword
hi def link contextEscaped String
+hi def link contextFont contextType
+hi def link contextKeyword Keyword
+hi def link contextInlineMath String
+hi def link contextMagicLine PreProc
+hi def link contextMathCmd Identifier
+hi def link contextMathDelim Delimiter
+hi def link contextOptions Typedef
hi def link contextPreProc PreProc
hi def link contextSectioning PreProc
+hi def link contextSequence Identifier
hi def link contextSpecial Special
-hi def link contextType Type
hi def link contextStyle contextType
-hi def link contextFont contextType
-hi def link contextDirectLua Keyword
+hi def link contextTodo Todo
+hi def link contextType Type
-let b:current_syntax = "context"
+b:current_syntax = 'context'
-let &cpo = s:cpo_save
-unlet s:cpo_save
+# vim: sw=2 fdm=marker