codekingpro/portable-devtools
114k
1vim9script2 3# Vim syntax file4# Language: MetaPost5# Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>6# Former Maintainers: Andreas Scherer <andreas.scherer@pobox.com>7# Latest Revision: 2026 Jan 108 9if exists("b:current_syntax")10 finish11endif12 13# Deprecation warnings: to be removed eventually14if exists("g:plain_mp_macros")15 echomsg "[mp] g:plain_mp_macros is deprecated: use g:mp_plain_macros instead."16endif17if exists("mfplain_mp_macros")18 echomsg "[mp] g:mfplain_mp_macros is deprecated: use g:mp_mfplain_macros instead."19endif20if exists("other_mp_macros")21 echomsg "[mp] g:other_mp_macros is deprecated: use g:mp_other_macros instead."22endif23 24# Store the current values of METAFONT global options25const mf_plain_macros = get(g:, "mf_plain_macros", get(g:, "plain_mf_macros", -1))26const mf_plain_modes = get(g:, "mf_plain_modes", get(g:, "plain_mf_modes", -1))27const mf_other_macros = get(g:, "mf_other_macros", get(g:, "other_mf_macros", -1))28 29g:mf_plain_macros = 0 # plain.mf has no special meaning for MetaPost30g:mf_plain_modes = 0 # No METAFONT modes31g:mf_other_macros = 0 # cmbase.mf, logo.mf, ... neither32 33# Read the METAFONT syntax to start with34runtime! syntax/mf.vim35unlet b:current_syntax # Necessary for syn include below36 37# Restore the value of existing global variables38if mf_plain_macros == -139 unlet g:mf_plain_macros40else41 g:plain_mf_macros = mf_plain_macros42endif43if mf_plain_modes == -144 unlet g:mf_plain_modes45else46 g:mf_plain_modes = mf_plain_modes47endif48if mf_other_macros == -149 unlet g:mf_other_macros50else51 g:mf_other_macros = mf_other_macros52endif53 54# Use TeX highlighting inside verbatimtex/btex... etex55syn include @MPTeX syntax/tex.vim56unlet b:current_syntax57# These are defined as keywords rather than using matchgroup58# in order to make them available to syntaxcomplete.59syn keyword mpTeXdelim btex etex verbatimtex contained60syn region mpTeXinsert matchgroup=mpTeXdelim start=/\<verbatimtex\>\|\<btex\>/ end=/\<etex\>/ keepend contains=@MPTeX,mpTeXdelim61 62# iskeyword must be set after the syn include above, because tex.vim sets `syn63# iskeyword`. Note that keywords do not contain numbers (numbers are64# subscripts)65syntax iskeyword @,_66 67# MetaPost primitives not found in METAFONT68syn keyword mpBoolExp bounded clipped filled stroked textual arclength69syn keyword mpNumExp arctime blackpart bluepart colormodel cyanpart70syn keyword mpNumExp fontsize greenpart greypart magentapart redpart71syn keyword mpPairExp yellowpart llcorner lrcorner ulcorner urcorner72syn keyword mpPathExp envelope pathpart73syn keyword mpPenExp penpart74syn keyword mpPicExp dashpart glyph infont75syn keyword mpStringExp fontpart readfrom textpart76syn keyword mpType cmykcolor color rgbcolor77# Other MetaPost primitives listed in the manual78syn keyword mpPrimitive mpxbreak within79# Internal quantities not found in METAFONT80# (Table 6 in MetaPost: A User's Manual)81syn keyword mpInternal defaultcolormodel hour minute linecap linejoin82syn keyword mpInternal miterlimit mpprocset mpversion numberprecision83syn keyword mpInternal numbersystem outputfilename outputformat84syn keyword mpInternal outputformatoptions outputtemplate prologues85syn keyword mpInternal restoreclipcolor tracinglostchars troffmode86syn keyword mpInternal truecorners87# List of commands not found in METAFONT (from MetaPost: A User's Manual)88syn keyword mpCommand clip closefrom dashed filenametemplate fontmapfile89syn keyword mpCommand fontmapline setbounds withcmykcolor withcolor90syn keyword mpCommand withgreyscale withoutcolor withpostscript91syn keyword mpCommand withprescript withrgbcolor write92# METAFONT internal variables not found in MetaPost93syn keyword notDefined autorounding chardx chardy fillin granularity94syn keyword notDefined proofing smoothing tracingedges tracingpens95syn keyword notDefined turningcheck xoffset yoffset96# Suffix defined only in METAFONT:97syn keyword notDefined nodot98# Other not implemented primitives (see MetaPost: A User's Manual, §C.1)99syn keyword notDefined cull display openwindow numspecial totalweight100syn keyword notDefined withweight101 102# Keywords defined by plain.mp103if get(g:, "mp_plain_macros", get(g:, "plain_mp_macros", 1)) || get(b:, "mp_metafun", get(g:, "mp_metafun", 0))104 syn keyword mpDef beginfig clear_pen_memory clearit clearpen clearpen105 syn keyword mpDef clearxy colorpart cutdraw downto draw drawarrow106 syn keyword mpDef drawdblarrow drawdot drawoptions endfig erase107 syn keyword mpDef exitunless fill filldraw flex gobble hide interact108 syn keyword mpDef label loggingall makelabel numtok penstroke pickup109 syn keyword mpDef range reflectedabout rotatedaround shipit110 syn keyword mpDef stop superellipse takepower tracingall tracingnone111 syn keyword mpDef undraw undrawdot unfill unfilldraw upto112 syn match mpDef "???"113 syn keyword mpVardef arrowhead bbox bot buildcycle byte ceiling center114 syn keyword mpVardef counterclockwise decr dir direction directionpoint115 syn keyword mpVardef dotlabel dotlabels image incr interpath inverse116 syn keyword mpVardef labels lft magstep max min penlabels penpos round117 syn keyword mpVardef rt savepen solve tensepath thelabel top unitvector118 syn keyword mpVardef whatever z119 syn keyword mpPrimaryDef div dotprod gobbled mod120 syn keyword mpSecondaryDef intersectionpoint121 syn keyword mpTertiaryDef cutafter cutbefore softjoin thru122 syn keyword mpNewInternal ahangle ahlength bboxmargin beveled butt defaultpen123 syn keyword mpNewInternal defaultscale dotlabeldiam eps epsilon infinity124 syn keyword mpNewInternal join_radius labeloffset mitered pen_bot pen_lft125 syn keyword mpNewInternal pen_rt pen_top rounded squared tolerance126 # Predefined constants127 syn keyword mpConstant EOF background base_name base_version black128 syn keyword mpConstant blankpicture blue ditto down evenly fullcircle129 syn keyword mpConstant green halfcircle identity left origin penrazor130 syn keyword mpConstant penspeck pensquare quartercircle red right131 syn keyword mpConstant unitsquare up white withdots132 # Other predefined variables133 syn keyword mpVariable currentpen currentpen_path currentpicture cuttings134 syn keyword mpVariable defaultfont extra_beginfig extra_endfig135 syn keyword mpVariable laboff labxf labyf laboff labxf labyf136 syn match mpVariable /\.\%(lft\|rt\|bot\|top\|ulft\|urt\|llft\|lrt\)\>/137 # let statements:138 syn keyword mpnumExp abs139 syn keyword mpDef rotatedabout140 syn keyword mpCommand bye relax141 # on and off are not technically keywords, but it is nice to highlight them142 # inside dashpattern().143 syn keyword mpOnOff off on contained144 syn keyword mpDash dashpattern contained145 syn region mpDashPattern start="dashpattern\s*" end=")"he=e-1 contains=mfNumeric,mfLength,mpOnOff,mpDash146endif147 148# Keywords defined by mfplain.mp149if get(g:, "mp_mfplain_macros", get(g:, "mfplain_mp_macros", 0))150 syn keyword mpDef beginchar capsule_def change_width151 syn keyword mpDef define_blacker_pixels define_corrected_pixels152 syn keyword mpDef define_good_x_pixels define_good_y_pixels153 syn keyword mpDef define_horizontal_corrected_pixels define_pixels154 syn keyword mpDef define_whole_blacker_pixels define_whole_pixels155 syn keyword mpDef define_whole_vertical_blacker_pixels156 syn keyword mpDef define_whole_vertical_pixels endchar157 syn keyword mpDef font_coding_scheme font_extra_space font_identifier158 syn keyword mpDef font_normal_shrink font_normal_space159 syn keyword mpDef font_normal_stretch font_quad font_size font_slant160 syn keyword mpDef font_x_height italcorr labelfont lowres_fix makebox161 syn keyword mpDef makegrid maketicks mode_def mode_setup proofrule162 syn keyword mpDef smode163 syn keyword mpVardef hround proofrulethickness vround164 syn keyword mpNewInternal blacker o_correction165 syn keyword mpVariable extra_beginchar extra_endchar extra_setup rulepen166 # plus some no-ops, also from mfplain.mp167 syn keyword mpDef cull cullit gfcorners imagerules nodisplays168 syn keyword mpDef notransforms openit proofoffset screenchars169 syn keyword mpDef screenrule screenstrokes showit170 syn keyword mpVardef grayfont slantfont titlefont171 syn keyword mpVariable currenttransform172 syn keyword mpConstant unitpixel173 # These are not listed in the MetaPost manual, and some are ignored by174 # MetaPost, but are nonetheless defined in mfplain.mp175 syn keyword mpDef killtext176 syn match mpVardef "\<good\.\%(x\|y\|lft\|rt\|top\|bot\)\>"177 syn keyword mpVariable aspect_ratio localfont mag mode mode_name178 syn keyword mpVariable proofcolor179 syn keyword mpConstant lowres proof smoke180 syn keyword mpNewInternal autorounding bp_per_pixel granularity181 syn keyword mpNewInternal number_of_modes proofing smoothing turningcheck182endif183 184# Keywords defined by all base macro packages:185# - (r)boxes.mp186# - format.mp187# - graph.mp188# - marith.mp189# - sarith.mp190# - string.mp191# - TEX.mp192if get(g:, "mp_other_macros", get(g:, "other_mp_macros", 1))193 # boxes and rboxes194 syn keyword mpDef boxjoin drawboxed drawboxes drawunboxed195 syn keyword mpNewInternal circmargin defaultdx defaultdy rbox_radius196 syn keyword mpVardef boxit bpath circleit fixpos fixsize generic_declare197 syn keyword mpVardef generic_redeclare generisize pic rboxit str_prefix198 # format199 syn keyword mpVardef Mformat format init_numbers roundd200 syn keyword mpVariable Fe_base Fe_plus201 syn keyword mpConstant Ten_to202 # graph203 syn keyword mpDef Gfor Gxyscale OUT auto begingraph endgraph gdata204 syn keyword mpDef gdraw gdrawarrow gdrawdblarrow gfill plot205 syn keyword mpVardef augment autogrid frame gdotlabel glabel grid itick206 syn keyword mpVardef otick207 syn keyword mpVardef Mreadpath setcoords setrange208 syn keyword mpNewInternal Gmarks Gminlog Gpaths linear log209 syn keyword mpVariable Autoform Gemarks Glmarks Gumarks210 syn keyword mpConstant Gtemplate211 syn match mpVariable /Gmargin\.\%(low\|high\)/212 # marith213 syn keyword mpVardef Mabs Meform Mexp Mexp_str Mlog Mlog_Str Mlog_str214 syn keyword mpPrimaryDef Mdiv Mmul215 syn keyword mpSecondaryDef Madd Msub216 syn keyword mpTertiaryDef Mleq217 syn keyword mpNewInternal Mten Mzero218 # sarith219 syn keyword mpVardef Sabs Scvnum220 syn keyword mpPrimaryDef Sdiv Smul221 syn keyword mpSecondaryDef Sadd Ssub222 syn keyword mpTertiaryDef Sleq Sneq223 # string224 syn keyword mpVardef cspan isdigit loptok225 # TEX226 syn keyword mpVardef TEX TEXPOST TEXPRE227endif228 229if get(b:, "mp_metafun", get(g:, "mp_metafun", 0))230 # MetaFun additions to MetaPost base file231 syn keyword mpConstant cyan magenta yellow232 syn keyword mpConstant penspec233 syn keyword mpNumExp graypart greycolor graycolor234 235 # Highlight TeX keywords (for MetaPost embedded in ConTeXt documents)236 syn match mpTeXKeyword '\\[a-zA-Z@]\+'237 238 syn keyword mpPrimitive runscript239 240 runtime! syntax/shared/context-data-metafun.vim241 242 hi def link metafunCommands Statement243 hi def link metafunInternals Identifier244endif245 246# Define the default highlighting247hi def link mpTeXdelim mpPrimitive248hi def link mpBoolExp mfBoolExp249hi def link mpNumExp mfNumExp250hi def link mpPairExp mfPairExp251hi def link mpPathExp mfPathExp252hi def link mpPenExp mfPenExp253hi def link mpPicExp mfPicExp254hi def link mpStringExp mfStringExp255hi def link mpInternal mfInternal256hi def link mpCommand mfCommand257hi def link mpType mfType258hi def link mpPrimitive mfPrimitive259hi def link mpDef mfDef260hi def link mpVardef mpDef261hi def link mpPrimaryDef mpDef262hi def link mpSecondaryDef mpDef263hi def link mpTertiaryDef mpDef264hi def link mpNewInternal mpInternal265hi def link mpVariable mfVariable266hi def link mpConstant mfConstant267hi def link mpOnOff mpPrimitive268hi def link mpDash mpPrimitive269hi def link mpTeXKeyword Identifier270 271b:current_syntax = "mp"272 273# vim: sw=2 fdm=marker274 