summaryrefslogtreecommitdiffstats
path: root/runtime/syntax
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
parent5a4fff4d948cd12a5cf5f637ad2c561815a77d8e (diff)
Update runtime files
Diffstat (limited to 'runtime/syntax')
-rw-r--r--runtime/syntax/README.txt3
-rw-r--r--runtime/syntax/context.vim187
-rw-r--r--runtime/syntax/mf.vim99
-rw-r--r--runtime/syntax/mp.vim684
-rw-r--r--runtime/syntax/shared/README.txt2
-rw-r--r--runtime/syntax/shared/typescriptcommon.vim2099
-rw-r--r--runtime/syntax/swayconfig.vim8
-rw-r--r--runtime/syntax/typescript.vim2
-rw-r--r--runtime/syntax/typescriptreact.vim2
9 files changed, 2355 insertions, 731 deletions
diff --git a/runtime/syntax/README.txt b/runtime/syntax/README.txt
index d88bd7ed5d..d6a86e5ca9 100644
--- a/runtime/syntax/README.txt
+++ b/runtime/syntax/README.txt
@@ -13,6 +13,9 @@ synload.vim Contains autocommands to load a language file when a certain
nosyntax.vim Used for the ":syntax off" command. Undo the loading of
synload.vim.
+The "shared" directory contains generated files and what is used by more than
+one syntax.
+
A few special files:
diff --git a/runtime/syntax/context.vim b/runtime/syntax/context.vim
index b29f256baa..08ab1f6988 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
diff --git a/runtime/syntax/mf.vim b/runtime/syntax/mf.vim
index 3589e4db3c..d1faa1913e 100644
--- a/runtime/syntax/mf.vim
+++ b/runtime/syntax/mf.vim
@@ -1,26 +1,39 @@
-" Vim syntax file
-" Language: METAFONT
-" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
-" Former Maintainers: Andreas Scherer <andreas.scherer@pobox.com>
-" Last Change: 2016 Oct 1
+vim9script
+
+# Vim syntax file
+# Language: METAFONT
+# Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
+# Former Maintainers: Andreas Scherer <andreas.scherer@pobox.com>
+# Latest Revision: 2022 Aug 12
if exists("b:current_syntax")
finish
endif
+# Deprecation warnings: to be removed eventually
+if exists("g:plain_mf_macros")
+ echomsg "[mf] g:plain_mf_macros is deprecated: use g:mf_plain_macros instead."
+endif
+if exists("g:plain_mf_modes")
+ echomsg "[mf] g:plain_mf_modes is deprecated: use g:mf_plain_modes instead."
+endif
+if exists("g:other_mf_macros")
+ echomsg "[mf] g:other_mf_macros is deprecated: use g:mf_other_macros instead."
+endif
+
syn iskeyword @,_
-" METAFONT 'primitives' as defined in chapter 25 of 'The METAFONTbook'
-" Page 210: 'boolean expressions'
+# METAFONT 'primitives' as defined in chapter 25 of 'The METAFONTbook'
+# Page 210: 'boolean expressions'
syn keyword mfBoolExp and charexists false known not odd or true unknown
-" Page 210: 'numeric expression'
+# Page 210: 'numeric expression'
syn keyword mfNumExp ASCII angle cosd directiontime floor hex length
syn keyword mfNumExp mexp mlog normaldeviate oct sind sqrt totalweight
syn keyword mfNumExp turningnumber uniformdeviate xpart xxpart xypart
syn keyword mfNumExp ypart yxpart yypart
-" Page 211: 'internal quantities'
+# Page 211: 'internal quantities'
syn keyword mfInternal autorounding boundarychar charcode chardp chardx
syn keyword mfInternal chardy charext charht charic charwd day designsize
syn keyword mfInternal fillin fontmaking granularity hppp jobname month
@@ -32,25 +45,25 @@ syn keyword mfInternal tracingrestores tracingspecs tracingstats
syn keyword mfInternal tracingtitles turningcheck vppp warningcheck
syn keyword mfInternal xoffset year yoffset
-" Page 212: 'pair expressions'
+# Page 212: 'pair expressions'
syn keyword mfPairExp of penoffset point postcontrol precontrol rotated
syn keyword mfPairExp scaled shifted slanted transformed xscaled yscaled
syn keyword mfPairExp zscaled
-" Page 213: 'path expressions'
+# Page 213: 'path expressions'
syn keyword mfPathExp atleast controls curl cycle makepath reverse
syn keyword mfPathExp subpath tension
-" Page 214: 'pen expressions'
+# Page 214: 'pen expressions'
syn keyword mfPenExp makepen nullpen pencircle
-" Page 214: 'picture expressions'
+# Page 214: 'picture expressions'
syn keyword mfPicExp nullpicture
-" Page 214: 'string expressions'
+# Page 214: 'string expressions'
syn keyword mfStringExp char decimal readstring str substring
-" Page 217: 'commands and statements'
+# Page 217: 'commands and statements'
syn keyword mfCommand addto also at batchmode contour cull delimiters
syn keyword mfCommand display doublepath dropping dump end errhelp
syn keyword mfCommand errmessage errorstopmode everyjob from interim
@@ -60,36 +73,36 @@ syn keyword mfCommand save scrollmode shipout show showdependencies
syn keyword mfCommand showstats showtoken showvariable special to withpen
syn keyword mfCommand withweight
-" Page 56: 'types'
+# Page 56: 'types'
syn keyword mfType boolean numeric pair path pen picture string
syn keyword mfType transform
-" Page 155: 'grouping'
+# Page 155: 'grouping'
syn keyword mfStatement begingroup endgroup
-" Page 165: 'definitions'
+# Page 165: 'definitions'
syn keyword mfDefinition def enddef expr primary primarydef secondary
syn keyword mfDefinition secondarydef suffix tertiary tertiarydef text
syn keyword mfDefinition vardef
-" Page 169: 'conditions and loops'
+# Page 169: 'conditions and loops'
syn keyword mfCondition else elseif endfor exitif fi for forever
syn keyword mfCondition forsuffixes if step until
-" Other primitives listed in the index
+# Other primitives listed in the index
syn keyword mfPrimitive charlist endinput expandafter extensible fontdimen
syn keyword mfPrimitive headerbyte inner input intersectiontimes kern
syn keyword mfPrimitive ligtable quote scantokens skipto
-" Implicit suffix parameters
+# Implicit suffix parameters
syn match mfSuffixParam "@#\|#@\|@"
-" These are just tags, but given their special status, we
-" highlight them as variables
+# These are just tags, but given their special status, we
+# highlight them as variables
syn keyword mfVariable x y
-" Keywords defined by plain.mf (defined on pp.262-278)
-if get(g:, "plain_mf_macros", 1)
+# Keywords defined by plain.mf (defined on pp.262-278)
+if get(g:, "mf_plain_macros", get(g:, "plain_mf_macros", 1))
syn keyword mfDef addto_currentpicture beginchar capsule_def
syn keyword mfDef change_width clear_pen_memory clearit clearpen
syn keyword mfDef clearxy culldraw cullit cutdraw
@@ -117,8 +130,8 @@ if get(g:, "plain_mf_macros", 1)
syn keyword mfVardef bot byte ceiling counterclockwise cutoff decr dir
syn keyword mfVardef direction directionpoint grayfont hround incr
syn keyword mfVardef interpath inverse labelfont labels lft magstep
- " Note: nodot is not a vardef, it is used as in makelabel.lft.nodot("5",z5)
- " (METAFONT only)
+ # Note: nodot is not a vardef, it is used as in makelabel.lft.nodot("5",z5)
+ # (METAFONT only)
syn keyword mfVardef makelabel max min nodot penlabels penpos
syn keyword mfVardef proofrulethickness round rt savepen slantfont solve
syn keyword mfVardef tensepath titlefont top unitvector vround whatever
@@ -130,24 +143,24 @@ if get(g:, "plain_mf_macros", 1)
syn keyword mfNewInternal infinity join_radius number_of_modes o_correction
syn keyword mfNewInternal pen_bot pen_lft pen_rt pen_top pixels_per_inch
syn keyword mfNewInternal screen_cols screen_rows tolerance
- " Predefined constants
+ # Predefined constants
syn keyword mfConstant base_name base_version blankpicture ditto down
syn keyword mfConstant fullcircle halfcircle identity left lowres origin
syn keyword mfConstant penspeck proof quartercircle right rulepen smoke
syn keyword mfConstant unitpixel unitsquare up
- " Other predefined variables
+ # Other predefined variables
syn keyword mfVariable aspect_ratio currentpen extra_beginchar
syn keyword mfVariable extra_endchar currentpen_path currentpicture
syn keyword mfVariable currenttransform d extra_setup h localfont mag mode
syn keyword mfVariable mode_name w
- " let statements:
+ # let statements:
syn keyword mfnumExp abs
syn keyword mfPairExp rotatedabout
syn keyword mfCommand bye relax
endif
-" By default, METAFONT loads modes.mf, too
-if get(g:, "plain_mf_modes", 1)
+# By default, METAFONT loads modes.mf, too
+if get(g:, "plain_mf_modes", get(g:, "mf_plain_modes", 1))
syn keyword mfConstant APSSixMed AgfaFourZeroZero AgfaThreeFourZeroZero
syn keyword mfConstant AtariNineFive AtariNineSix AtariSLMEightZeroFour
syn keyword mfConstant AtariSMOneTwoFour CItohEightFiveOneZero
@@ -228,36 +241,36 @@ if get(g:, "plain_mf_modes", 1)
syn keyword mfNewInternal blacker_min
endif
-" Some other basic macro names, e.g., from cmbase, logo, etc.
-if get(g:, "other_mf_macros", 1)
+# Some other basic macro names, e.g., from cmbase, logo, etc.
+if get(g:, "mf_other_macros", get(g:, "other_mf_macros", 1))
syn keyword mfDef beginlogochar
syn keyword mfDef font_setup
syn keyword mfPrimitive generate
endif
-" Numeric tokens
+# Numeric tokens
syn match mfNumeric "[-]\=\d\+"
syn match mfNumeric "[-]\=\.\d\+"
syn match mfNumeric "[-]\=\d\+\.\d\+"
-" METAFONT lengths
+# METAFONT lengths
syn match mfLength "\<\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\>"
syn match mfLength "[-]\=\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\="
syn match mfLength "[-]\=\.\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\="
syn match mfLength "[-]\=\d\+\.\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\="
-" String constants
+# String constants
syn match mfOpenString /"[^"]*/
syn region mfString oneline keepend start=+"+ end=+"+
-" Comments:
+# Comments:
syn keyword mfTodoComment contained TODO FIXME XXX DEBUG NOTE
syn match mfComment "%.*$" contains=mfTodoComment,@Spell
-" synchronizing
-syn sync maxlines=50
+# synchronizing
+syn sync maxlines=100
-" Define the default highlighting
+# Define the default highlighting
hi def link mfBoolExp Statement
hi def link mfNumExp Statement
hi def link mfPairExp Statement
@@ -290,6 +303,6 @@ hi def link mfVariable Identifier
hi def link mfConstant Constant
hi def link mfTodoComment Todo
-let b:current_syntax = "mf"
+b:current_syntax = "mf"
-" vim:sw=2
+# vim: sw=2 fdm=marker
diff --git a/runtime/syntax/mp.vim b/runtime/syntax/mp.vim
index a8fa36fe0a..36c07e64c9 100644
--- a/runtime/syntax/mp.vim
+++ b/runtime/syntax/mp.vim
@@ -1,109 +1,106 @@
-" Vim syntax file
-" Language: MetaPost
-" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
-" Former Maintainers: Andreas Scherer <andreas.scherer@pobox.com>
-" Last Change: 2016 Oct 14
+vim9script
+
+# Vim syntax file
+# Language: MetaPost
+# Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
+# Former Maintainers: Andreas Scherer <andreas.scherer@pobox.com>
+# Latest Revision: 2022 Aug 12
if exists("b:current_syntax")
finish
endif
-let s:cpo_sav = &cpo
-set cpo&vim
-
-if exists("g:plain_mf_macros")
- let s:plain_mf_macros = g:plain_mf_macros
+# Deprecation warnings: to be removed eventually
+if exists("g:plain_mp_macros")
+ echomsg "[mp] g:plain_mp_macros is deprecated: use g:mp_plain_macros instead."
endif
-if exists("g:plain_mf_modes")
- let s:plain_mf_modes = g:plain_mf_modes
+if exists("mfplain_mp_macros")
+ echomsg "[mp] g:mfplain_mp_macros is deprecated: use g:mp_mfplain_macros instead."
endif
-if exists("g:other_mf_macros")
- let s:other_mf_macros = g:other_mf_macros
+if exists("other_mp_macros")
+ echomsg "[mp] g:other_mp_macros is deprecated: use g:mp_other_macros instead."
endif
-let g:plain_mf_macros = 0 " plain.mf has no special meaning for MetaPost
-let g:plain_mf_modes = 0 " No METAFONT modes
-let g:other_mf_macros = 0 " cmbase.mf, logo.mf, ... neither
+# Store the current values of METAFONT global options
+const mf_plain_macros = get(g:, "mf_plain_macros", get(g:, "plain_mf_macros", -1))
+const mf_plain_modes = get(g:, "mf_plain_modes", get(g:, "plain_mf_modes", -1))
+const mf_other_macros = get(g:, "mf_other_macros", get(g:, "other_mf_macros", -1))
+
+g:mf_plain_macros = 0 # plain.mf has no special meaning for MetaPost
+g:mf_plain_modes = 0 # No METAFONT modes
+g:mf_other_macros = 0 # cmbase.mf, logo.mf, ... neither
-" Read the METAFONT syntax to start with
+# Read the METAFONT syntax to start with
runtime! syntax/mf.vim
-unlet b:current_syntax " Necessary for syn include below
+unlet b:current_syntax # Necessary for syn include below
-" Restore the value of existing global variables
-if exists("s:plain_mf_macros")
- let g:plain_mf_macros = s:plain_mf_macros
+# Restore the value of existing global variables
+if mf_plain_macros == -1
+ unlet g:mf_plain_macros
else
- unlet g:plain_mf_macros
+ g:plain_mf_macros = mf_plain_macros
endif
-if exists("s:plain_mf_modes")
- let g:plain_mf_modes = s:plain_mf_modes
+if mf_plain_modes == -1
+ unlet g:mf_plain_modes
else
- unlet g:plain_mf_modes
+ g:mf_plain_modes = mf_plain_modes
endif
-if exists("s:other_mf_macros")
- let g:other_mf_macros = s:other_mf_macros
+if mf_other_macros == -1
+ unlet g:mf_other_macros
else
- unlet g:other_mf_macros
+ g:mf_other_macros = mf_other_macros
endif
-" Use TeX highlighting inside verbatimtex/btex... etex
+# Use TeX highlighting inside verbatimtex/btex... etex
syn include @MPTeX syntax/tex.vim
unlet b:current_syntax
-" These are defined as keywords rather than using matchgroup
-" in order to make them available to syntaxcomplete.
+# These are defined as keywords rather than using matchgroup
+# in order to make them available to syntaxcomplete.
syn keyword mpTeXdelim btex etex verbatimtex contained
-syn region mpTeXinsert
- \ start=/\<verbatimtex\>\|\<btex\>/rs=e+1
- \ end=/\<etex\>/re=s-1 keepend
- \ contains=@MPTeX,mpTeXdelim
+syn region mpTeXinsert matchgroup=mpTeXdelim start=/\<verbatimtex\>\|\<btex\>/ end=/\<etex\>/ keepend contains=@MPTeX,mpTeXdelim
-" iskeyword must be set after the syn include above, because tex.vim sets `syn
-" iskeyword`. Note that keywords do not contain numbers (numbers are
-" subscripts)
+# iskeyword must be set after the syn include above, because tex.vim sets `syn
+# iskeyword`. Note that keywords do not contain numbers (numbers are
+# subscripts)
syntax iskeyword @,_
-" MetaPost primitives not found in METAFONT
+# MetaPost primitives not found in METAFONT
syn keyword mpBoolExp bounded clipped filled stroked textual arclength
syn keyword mpNumExp arctime blackpart bluepart colormodel cyanpart
syn keyword mpNumExp fontsize greenpart greypart magentapart redpart
syn keyword mpPairExp yellowpart llcorner lrcorner ulcorner urcorner
-" envelope is seemingly undocumented, but it exists since mpost 1.003.
-" The syntax is: envelope <polygonal pen> of <path primary>. For example,
-" path p;
-" p := envelope pensquare of (up--left);
-" (Thanks to Daniel H. Luecking for the example!)
syn keyword mpPathExp envelope pathpart
syn keyword mpPenExp penpart
syn keyword mpPicExp dashpart glyph infont
syn keyword mpStringExp fontpart readfrom textpart
syn keyword mpType cmykcolor color rgbcolor
-" Other MetaPost primitives listed in the manual
+# Other MetaPost primitives listed in the manual
syn keyword mpPrimitive mpxbreak within
-" Internal quantities not found in METAFONT
-" (Table 6 in MetaPost: A User's Manual)
+# Internal quantities not found in METAFONT
+# (Table 6 in MetaPost: A User's Manual)
syn keyword mpInternal defaultcolormodel hour minute linecap linejoin
syn keyword mpInternal miterlimit mpprocset mpversion numberprecision
syn keyword mpInternal numbersystem outputfilename outputformat
syn keyword mpInternal outputformatoptions outputtemplate prologues
syn keyword mpInternal restoreclipcolor tracinglostchars troffmode
syn keyword mpInternal truecorners
-" List of commands not found in METAFONT (from MetaPost: A User's Manual)
+# List of commands not found in METAFONT (from MetaPost: A User's Manual)
syn keyword mpCommand clip closefrom dashed filenametemplate fontmapfile
syn keyword mpCommand fontmapline setbounds withcmykcolor withcolor
syn keyword mpCommand withgreyscale withoutcolor withpostscript
syn keyword mpCommand withprescript withrgbcolor write
-" METAFONT internal variables not found in MetaPost
+# METAFONT internal variables not found in MetaPost
syn keyword notDefined autorounding chardx chardy fillin granularity
syn keyword notDefined proofing smoothing tracingedges tracingpens
syn keyword notDefined turningcheck xoffset yoffset
-" Suffix defined only in METAFONT:
+# Suffix defined only in METAFONT:
syn keyword notDefined nodot
-" Other not implemented primitives (see MetaPost: A User's Manual, §C.1)
+# Other not implemented primitives (see MetaPost: A User's Manual, §C.1)
syn keyword notDefined cull display openwindow numspecial totalweight
syn keyword notDefined withweight
-" Keywords defined by plain.mp
-if get(g:, "plain_mp_macros", 1) || get(g:, "mp_metafun_macros", 0)
+# Keywords defined by plain.mp
+if get(g:, "mp_plain_macros", get(g:, "plain_mp_macros", 1)) || get(b:, "mp_metafun", get(g:, "mp_metafun", 0))
syn keyword mpDef beginfig clear_pen_memory clearit clearpen clearpen
syn keyword mpDef clearxy colorpart cutdraw downto draw drawarrow
syn keyword mpDef drawdblarrow drawdot drawoptions endfig erase
@@ -126,33 +123,30 @@ if get(g:, "plain_mp_macros", 1) || get(g:, "mp_metafun_macros", 0)
syn keyword mpNewInternal defaultscale dotlabeldiam eps epsilon infinity
syn keyword mpNewInternal join_radius labeloffset mitered pen_bot pen_lft
syn keyword mpNewInternal pen_rt pen_top rounded squared tolerance
- " Predefined constants
+ # Predefined constants
syn keyword mpConstant EOF background base_name base_version black
syn keyword mpConstant blankpicture blue ditto down evenly fullcircle
syn keyword mpConstant green halfcircle identity left origin penrazor
syn keyword mpConstant penspeck pensquare quartercircle red right
syn keyword mpConstant unitsquare up white withdots
- " Other predefined variables
+ # Other predefined variables
syn keyword mpVariable currentpen currentpen_path currentpicture cuttings
syn keyword mpVariable defaultfont extra_beginfig extra_endfig
- syn match mpVariable /\<\%(laboff\|labxf\|labyf\)\>/
- syn match mpVariable /\<\%(laboff\|labxf\|labyf\)\.\%(lft\|rt\|bot\|top\|ulft\|urt\|llft\|lrt\)\>/
- " let statements:
+ syn keyword mpVariable laboff labxf labyf laboff labxf labyf
+ syn match mpVariable /\.\%(lft\|rt\|bot\|top\|ulft\|urt\|llft\|lrt\)\>/
+ # let statements:
syn keyword mpnumExp abs
syn keyword mpDef rotatedabout
syn keyword mpCommand bye relax
- " on and off are not technically keywords, but it is nice to highlight them
- " inside dashpattern().
+ # on and off are not technically keywords, but it is nice to highlight them
+ # inside dashpattern().
syn keyword mpOnOff off on contained
syn keyword mpDash dashpattern contained
- syn region mpDashPattern
- \ start="dashpattern\s*"
- \ end=")"he=e-1
- \ contains=mfNumeric,mfLength,mpOnOff,mpDash
+ syn region mpDashPattern start="dashpattern\s*" end=")"he=e-1 contains=mfNumeric,mfLength,mpOnOff,mpDash
endif
-" Keywords defined by mfplain.mp
-if get(g:, "mfplain_mp_macros", 0)
+# Keywords defined by mfplain.mp
+if get(g:, "mp_mfplain_macros", get(g:, "mfplain_mp_macros", 0))
syn keyword mpDef beginchar capsule_def change_width
syn keyword mpDef define_blacker_pixels define_corrected_pixels
syn keyword mpDef define_good_x_pixels define_good_y_pixels
@@ -169,15 +163,15 @@ if get(g:, "mfplain_mp_macros", 0)
syn keyword mpVardef hround proofrulethickness vround
syn keyword mpNewInternal blacker o_correction
syn keyword mpVariable extra_beginchar extra_endchar extra_setup rulepen
- " plus some no-ops, also from mfplain.mp
+ # plus some no-ops, also from mfplain.mp
syn keyword mpDef cull cullit gfcorners imagerules nodisplays
syn keyword mpDef notransforms openit proofoffset screenchars
syn keyword mpDef screenrule screenstrokes showit
syn keyword mpVardef grayfont slantfont titlefont
syn keyword mpVariable currenttransform
syn keyword mpConstant unitpixel
- " These are not listed in the MetaPost manual, and some are ignored by
- " MetaPost, but are nonetheless defined in mfplain.mp
+ # These are not listed in the MetaPost manual, and some are ignored by
+ # MetaPost, but are nonetheless defined in mfplain.mp
syn keyword mpDef killtext
syn match mpVardef "\<good\.\%(x\|y\|lft\|rt\|top\|bot\)\>"
syn keyword mpVariable aspect_ratio localfont mag mode mode_name
@@ -187,25 +181,25 @@ if get(g:, "mfplain_mp_macros", 0)
syn keyword mpNewInternal number_of_modes proofing smoothing turningcheck
endif
-" Keywords defined by all base macro packages:
-" - (r)boxes.mp
-" - format.mp
-" - graph.mp
-" - marith.mp
-" - sarith.mp
-" - string.mp
-" - TEX.mp
-if get(g:, "other_mp_macros", 1)
- " boxes and rboxes
+# Keywords defined by all base macro packages:
+# - (r)boxes.mp
+# - format.mp
+# - graph.mp
+# - marith.mp
+# - sarith.mp
+# - string.mp
+# - TEX.mp
+if get(g:, "mp_other_macros", get(g:, "other_mp_macros", 1))
+ # boxes and rboxes
syn keyword mpDef boxjoin drawboxed drawboxes drawunboxed
syn keyword mpNewInternal circmargin defaultdx defaultdy rbox_radius
syn keyword mpVardef boxit bpath circleit fixpos fixsize generic_declare
syn keyword mpVardef generic_redeclare generisize pic rboxit str_prefix
- " format
+ # format
syn keyword mpVardef Mformat format init_numbers roundd
syn keyword mpVariable Fe_base Fe_plus
syn keyword mpConstant Ten_to
- " graph
+ # graph
syn keyword mpDef Gfor Gxyscale OUT auto begingraph endgraph gdata
syn keyword mpDef gdraw gdrawarrow gdrawdblarrow gfill plot
syn keyword mpVardef augment autogrid frame gdotlabel glabel grid itick
@@ -215,528 +209,41 @@ if get(g:, "other_mp_macros", 1)
syn keyword mpVariable Autoform Gemarks Glmarks Gumarks
syn keyword mpConstant Gtemplate
syn match mpVariable /Gmargin\.\%(low\|high\)/
- " marith
+ # marith
syn keyword mpVardef Mabs Meform Mexp Mexp_str Mlog Mlog_Str Mlog_str
syn keyword mpPrimaryDef Mdiv Mmul
syn keyword mpSecondaryDef Madd Msub
syn keyword mpTertiaryDef Mleq
syn keyword mpNewInternal Mten Mzero
- " sarith
+ # sarith
syn keyword mpVardef Sabs Scvnum
syn keyword mpPrimaryDef Sdiv Smul
syn keyword mpSecondaryDef Sadd Ssub
syn keyword mpTertiaryDef Sleq Sneq
- " string
+ # string
syn keyword mpVardef cspan isdigit loptok
- " TEX
+ # TEX
syn keyword mpVardef TEX TEXPOST TEXPRE
endif
-" Up to date as of 23-Sep-2016.
-if get(b:, 'mp_metafun_macros', get(g:, 'mp_metafun_macros', 0))
- " Highlight TeX keywords (for use in ConTeXt documents)
+if get(b:, "mp_metafun", get(g:, "mp_metafun", 0))
+ # MetaFun additions to MetaPost base file
+ syn keyword mpConstant cyan magenta yellow
+ syn keyword mpConstant penspec
+ syn keyword mpNumExp graypart greycolor graycolor
+
+ # Highlight TeX keywords (for MetaPost embedded in ConTeXt documents)
syn match mpTeXKeyword '\\[a-zA-Z@]\+'
- " These keywords have been added manually.
syn keyword mpPrimitive runscript
- " The following MetaFun keywords have been extracted automatically from
- " ConTeXt source code. They include all "public" macros (where a macro is
- " considered public if and only if it does not start with _, mfun_, mlib_, or
- " do_, and it does not end with _), all "public" unsaved variables, and all
- " `let` statements.
+ runtime! syntax/shared/context-data-metafun.vim
- " mp-abck.mpiv
- syn keyword mpDef abck_grid_line anchor_box box_found boxfilloptions
- syn keyword mpDef boxgridoptions boxlineoptions draw_multi_pars
- syn keyword mpDef draw_multi_side draw_multi_side_path freeze_box
- syn keyword mpDef initialize_box initialize_box_pos
- syn keyword mpDef multi_side_draw_options show_multi_kind
- syn keyword mpDef show_multi_pars
- syn keyword mpVardef abck_baseline_grid abck_draw_path abck_graphic_grid
- syn keyword mpVariable boxdashtype boxfilloffset boxfilltype
- syn keyword mpVariable boxgriddirection boxgriddistance boxgridshift
- syn keyword mpVariable boxgridtype boxgridwidth boxlineoffset
- syn keyword mpVariable boxlineradius boxlinetype boxlinewidth multikind
- syn keyword mpConstant context_abck
- " mp-apos.mpiv
- syn keyword mpDef anch_sidebars_draw boxfilloptions boxlineoptions
- syn keyword mpDef connect_positions
- syn keyword mpConstant context_apos
- " mp-asn