vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

mf.vim (15929B)


      1 vim9script
      2 
      3 # Vim syntax file
      4 # Language:           METAFONT
      5 # Maintainer:         Nicola Vitacolonna <nvitacolonna@gmail.com>
      6 # Former Maintainers: Andreas Scherer <andreas.scherer@pobox.com>
      7 # Latest Revision:    2026 Jan 10
      8 
      9 if exists("b:current_syntax")
     10   finish
     11 endif
     12 
     13 # Deprecation warnings: to be removed eventually
     14 if exists("g:plain_mf_macros")
     15   echomsg "[mf] g:plain_mf_macros is deprecated: use g:mf_plain_macros instead."
     16 endif
     17 if exists("g:plain_mf_modes")
     18   echomsg "[mf] g:plain_mf_modes is deprecated: use g:mf_plain_modes instead."
     19 endif
     20 if exists("g:other_mf_macros")
     21   echomsg "[mf] g:other_mf_macros is deprecated: use g:mf_other_macros instead."
     22 endif
     23 
     24 syn iskeyword @,_
     25 
     26 # METAFONT 'primitives' as defined in chapter 25 of 'The METAFONTbook'
     27 # Page 210: 'boolean expressions'
     28 syn keyword mfBoolExp        and charexists false known not odd or true unknown
     29 
     30 # Page 210: 'numeric expression'
     31 syn keyword mfNumExp         ASCII angle cosd directiontime floor hex length
     32 syn keyword mfNumExp         mexp mlog normaldeviate oct sind sqrt totalweight
     33 syn keyword mfNumExp         turningnumber uniformdeviate xpart xxpart xypart
     34 syn keyword mfNumExp         ypart yxpart yypart
     35 
     36 # Page 211: 'internal quantities'
     37 syn keyword mfInternal       autorounding boundarychar charcode chardp chardx
     38 syn keyword mfInternal       chardy charext charht charic charwd day designsize
     39 syn keyword mfInternal       fillin fontmaking granularity hppp jobname month
     40 syn keyword mfInternal       pausing proofing showstopping smoothing time
     41 syn keyword mfInternal       tracingcapsules tracingchoices tracingcommands
     42 syn keyword mfInternal       tracingedges tracingequations tracingmacros
     43 syn keyword mfInternal       tracingonline tracingoutput tracingpens
     44 syn keyword mfInternal       tracingrestores tracingspecs tracingstats
     45 syn keyword mfInternal       tracingtitles turningcheck vppp warningcheck
     46 syn keyword mfInternal       xoffset year yoffset
     47 
     48 # Page 212: 'pair expressions'
     49 syn keyword mfPairExp        of penoffset point postcontrol precontrol rotated
     50 syn keyword mfPairExp        scaled shifted slanted transformed xscaled yscaled
     51 syn keyword mfPairExp        zscaled
     52 
     53 # Page 213: 'path expressions'
     54 syn keyword mfPathExp        atleast controls curl cycle makepath reverse
     55 syn keyword mfPathExp        subpath tension
     56 
     57 # Page 214: 'pen expressions'
     58 syn keyword mfPenExp         makepen nullpen pencircle
     59 
     60 # Page 214: 'picture expressions'
     61 syn keyword mfPicExp         nullpicture
     62 
     63 # Page 214: 'string expressions'
     64 syn keyword mfStringExp      char decimal readstring str substring
     65 
     66 # Page 217: 'commands and statements'
     67 syn keyword mfCommand        addto also at batchmode contour cull delimiters
     68 syn keyword mfCommand        display doublepath dropping dump end errhelp
     69 syn keyword mfCommand        errmessage errorstopmode everyjob from interim
     70 syn keyword mfCommand        inwindow keeping let message newinternal
     71 syn keyword mfCommand        nonstopmode numspecial openwindow outer randomseed
     72 syn keyword mfCommand        save scrollmode shipout show showdependencies
     73 syn keyword mfCommand        showstats showtoken showvariable special to withpen
     74 syn keyword mfCommand        withweight
     75 
     76 # Page 56: 'types'
     77 syn keyword mfType           boolean numeric pair path pen picture string
     78 syn keyword mfType           transform
     79 
     80 # Page 155: 'grouping'
     81 syn keyword mfStatement      begingroup endgroup
     82 
     83 # Page 165: 'definitions'
     84 syn keyword mfDefinition     def enddef expr primary primarydef secondary
     85 syn keyword mfDefinition     secondarydef suffix tertiary tertiarydef text
     86 syn keyword mfDefinition     vardef
     87 
     88 # Page 169: 'conditions and loops'
     89 syn keyword mfCondition      else elseif endfor exitif fi for forever
     90 syn keyword mfCondition      forsuffixes if step until
     91 
     92 # Other primitives listed in the index
     93 syn keyword mfPrimitive      charlist endinput expandafter extensible fontdimen
     94 syn keyword mfPrimitive      headerbyte inner input intersectiontimes kern
     95 syn keyword mfPrimitive      ligtable quote scantokens skipto
     96 
     97 # Implicit suffix parameters
     98 syn match   mfSuffixParam    "@#\|#@\|@"
     99 
    100 # These are just tags, but given their special status, we
    101 # highlight them as variables
    102 syn keyword mfVariable       x y
    103 
    104 # Keywords defined by plain.mf (defined on pp.262-278)
    105 if get(g:, "mf_plain_macros", get(g:, "plain_mf_macros", 1))
    106   syn keyword mfDef          addto_currentpicture beginchar capsule_def
    107   syn keyword mfDef          change_width clear_pen_memory clearit clearpen
    108   syn keyword mfDef          clearxy culldraw cullit cutdraw
    109   syn keyword mfDef          define_blacker_pixels define_corrected_pixels
    110   syn keyword mfDef          define_good_x_pixels define_good_y_pixels
    111   syn keyword mfDef          define_horizontal_corrected_pixels define_pixels
    112   syn keyword mfDef          define_whole_blacker_pixels define_whole_pixels
    113   syn keyword mfDef          define_whole_vertical_blacker_pixels
    114   syn keyword mfDef          define_whole_vertical_pixels downto draw drawdot
    115   syn keyword mfDef          endchar erase exitunless fill filldraw fix_units
    116   syn keyword mfDef          flex font_coding_scheme font_extra_space
    117   syn keyword mfDef          font_identifier font_normal_shrink
    118   syn keyword mfDef          font_normal_space font_normal_stretch font_quad
    119   syn keyword mfDef          font_size font_slant font_x_height gfcorners gobble
    120   syn keyword mfDef          hide imagerules interact italcorr killtext
    121   syn keyword mfDef          loggingall lowres_fix makebox makegrid maketicks
    122   syn keyword mfDef          mode_def mode_setup nodisplays notransforms numtok
    123   syn keyword mfDef          openit penrazor pensquare penstroke pickup
    124   syn keyword mfDef          proofoffset proofrule range reflectedabout
    125   syn keyword mfDef          rotatedaround screenchars screenrule screenstrokes
    126   syn keyword mfDef          shipit showit smode stop superellipse takepower
    127   syn keyword mfDef          tracingall tracingnone undraw undrawdot unfill
    128   syn keyword mfDef          unfilldraw upto z
    129   syn match   mfDef          "???"
    130   syn keyword mfVardef       bot byte ceiling counterclockwise cutoff decr dir
    131   syn keyword mfVardef       direction directionpoint grayfont hround incr
    132   syn keyword mfVardef       interpath inverse labelfont labels lft magstep
    133   # Note: nodot is not a vardef, it is used as in makelabel.lft.nodot("5",z5)
    134   # (METAFONT only)
    135   syn keyword mfVardef       makelabel max min nodot penlabels penpos
    136   syn keyword mfVardef       proofrulethickness round rt savepen slantfont solve
    137   syn keyword mfVardef       tensepath titlefont top unitvector vround whatever
    138   syn match   mpVardef       "\<good\.\%(x\|y\|lft\|rt\|top\|bot\)\>"
    139   syn keyword mfPrimaryDef   div dotprod gobbled mod
    140   syn keyword mfSecondaryDef intersectionpoint
    141   syn keyword mfTertiaryDef  softjoin thru
    142   syn keyword mfNewInternal  blacker currentwindow displaying eps epsilon
    143   syn keyword mfNewInternal  infinity join_radius number_of_modes o_correction
    144   syn keyword mfNewInternal  pen_bot pen_lft pen_rt pen_top pixels_per_inch
    145   syn keyword mfNewInternal  screen_cols screen_rows tolerance
    146   # Predefined constants
    147   syn keyword mfConstant     base_name base_version blankpicture ditto down
    148   syn keyword mfConstant     fullcircle halfcircle identity left lowres origin
    149   syn keyword mfConstant     penspeck proof quartercircle right rulepen smoke
    150   syn keyword mfConstant     unitpixel unitsquare up
    151   # Other predefined variables
    152   syn keyword mfVariable     aspect_ratio currentpen extra_beginchar
    153   syn keyword mfVariable     extra_endchar currentpen_path currentpicture
    154   syn keyword mfVariable     currenttransform d extra_setup h localfont mag mode
    155   syn keyword mfVariable     mode_name w
    156   # let statements:
    157   syn keyword mfnumExp       abs
    158   syn keyword mfPairExp      rotatedabout
    159   syn keyword mfCommand      bye relax
    160 endif
    161 
    162 # By default, METAFONT loads modes.mf, too
    163 if get(g:, "plain_mf_modes", get(g:, "mf_plain_modes", 1))
    164   syn keyword mfConstant     APSSixMed AgfaFourZeroZero AgfaThreeFourZeroZero
    165   syn keyword mfConstant     AtariNineFive AtariNineSix AtariSLMEightZeroFour
    166   syn keyword mfConstant     AtariSMOneTwoFour CItohEightFiveOneZero
    167   syn keyword mfConstant     CItohThreeOneZero CanonBJCSixZeroZero CanonCX
    168   syn keyword mfConstant     CanonEX CanonLBPLX CanonLBPTen CanonSX ChelgraphIBX
    169   syn keyword mfConstant     CompugraphicEightSixZeroZero
    170   syn keyword mfConstant     CompugraphicNineSixZeroZero DD DEClarge DECsmall
    171   syn keyword mfConstant     DataDiscNew EightThree EpsonAction
    172   syn keyword mfConstant     EpsonLQFiveZeroZeroLo EpsonLQFiveZeroZeroMed
    173   syn keyword mfConstant     EpsonMXFX EpsonSQEightSevenZero EpsonStylusPro
    174   syn keyword mfConstant     EpsonStylusProHigh EpsonStylusProLow
    175   syn keyword mfConstant     EpsonStylusProMed FourFour GThreefax HPDeskJet
    176   syn keyword mfConstant     HPLaserJetIIISi IBMFourTwoFiveZero IBMFourTwoOneSix
    177   syn keyword mfConstant     IBMFourTwoThreeZero IBMFourZeroOneNine
    178   syn keyword mfConstant     IBMFourZeroThreeNine IBMFourZeroTwoNine
    179   syn keyword mfConstant     IBMProPrinter IBMSixOneFiveFour IBMSixSixSevenZero
    180   syn keyword mfConstant     IBMThreeEightOneTwo IBMThreeEightTwoZero
    181   syn keyword mfConstant     IBMThreeOneNineThree IBMThreeOneSevenNine
    182   syn keyword mfConstant     IBMUlfHolleberg LASevenFive LNOthreR LNOthree
    183   syn keyword mfConstant     LNZeroOne LNZeroThree LPSFourZero LPSTwoZero
    184   syn keyword mfConstant     LexmarkFourZeroThreeNine LexmarkOptraR
    185   syn keyword mfConstant     LexmarkOptraS LinotypeLThreeThreeZero
    186   syn keyword mfConstant     LinotypeOneZeroZero LinotypeOneZeroZeroLo
    187   syn keyword mfConstant     LinotypeThreeZeroZeroHi MacTrueSize NeXTprinter
    188   syn keyword mfConstant     NeXTscreen NecTwoZeroOne Newgen NineOne
    189   syn keyword mfConstant     OCESixSevenFiveZeroPS OneTwoZero OneZeroZero
    190   syn keyword mfConstant     PrintwareSevenTwoZeroIQ Prism QMSOneSevenTwoFive
    191   syn keyword mfConstant     QMSOneSevenZeroZero QMSTwoFourTwoFive RicohA
    192   syn keyword mfConstant     RicohFortyEighty RicohFourZeroEightZero RicohLP
    193   syn keyword mfConstant     SparcPrinter StarNLOneZero VAXstation VTSix
    194   syn keyword mfConstant     VarityperFiveZeroSixZeroW
    195   syn keyword mfConstant     VarityperFourThreeZeroZeroHi
    196   syn keyword mfConstant     VarityperFourThreeZeroZeroLo
    197   syn keyword mfConstant     VarityperFourTwoZeroZero VarityperSixZeroZero
    198   syn keyword mfConstant     XeroxDocutech XeroxEightSevenNineZero
    199   syn keyword mfConstant     XeroxFourZeroFiveZero XeroxNineSevenZeroZero
    200   syn keyword mfConstant     XeroxPhaserSixTwoZeroZeroDP XeroxThreeSevenZeroZero
    201   syn keyword mfConstant     Xerox_world agfafzz agfatfzz amiga aps apssixhi
    202   syn keyword mfConstant     aselect atariezf atarinf atarins atariotf bitgraph
    203   syn keyword mfConstant     bjtenex bjtzzex bjtzzl bjtzzs boise canonbjc
    204   syn keyword mfConstant     canonex canonlbp cg cgl cgnszz citohtoz corona crs
    205   syn keyword mfConstant     cthreeten cx datadisc declarge decsmall deskjet
    206   syn keyword mfConstant     docutech dover dp dpdfezzz eighthre elvira epscszz
    207   syn keyword mfConstant     epsdraft epsdrft epsdrftl epsfast epsfastl epshi
    208   syn keyword mfConstant     epslo epsmed epsmedl epson epsonact epsonfx epsonl
    209   syn keyword mfConstant     epsonlo epsonlol epsonlq epsonsq epstylus epstylwr
    210   syn keyword mfConstant     epstyplo epstypmd epstypml epstypro epswlo epswlol
    211   syn keyword mfConstant     esphi fourfour gpx gtfax gtfaxhi gtfaxl gtfaxlo
    212   syn keyword mfConstant     gtfaxlol help hifax highfax hplaser hprugged ibm_a
    213   syn keyword mfConstant     ibmd ibmega ibmegal ibmfzon ibmfztn ibmpp ibmppl
    214   syn keyword mfConstant     ibmsoff ibmteot ibmtetz ibmtont ibmtosn ibmtosnl
    215   syn keyword mfConstant     ibmvga ibx imagen imagewriter itoh itohl itohtoz
    216   syn keyword mfConstant     itohtozl iw jetiiisi kyocera laserjet laserjetfive
    217   syn keyword mfConstant     laserjetfivemp laserjetfour laserjetfourthousand
    218   syn keyword mfConstant     laserjetfourzerozerozero laserjethi laserjetlo
    219   syn keyword mfConstant     laserjettwoonezerozero
    220   syn keyword mfConstant     laserjettwoonezerozerofastres lasermaster
    221   syn keyword mfConstant     laserwriter lasf lexmarkr lexmarks lexmarku
    222   syn keyword mfConstant     linohalf linohi linolo linolttz linoone linosuper
    223   syn keyword mfConstant     linothree linothreelo linotzzh ljfive ljfivemp
    224   syn keyword mfConstant     ljfour ljfzzz ljfzzzfr ljlo ljtozz ljtozzfr lmaster
    225   syn keyword mfConstant     lnotr lnzo lps lpstz lqhires lqlores lqmed lqmedl
    226   syn keyword mfConstant     lqmedres lview lviewl lwpro macmag mactrue modes_mf
    227   syn keyword mfConstant     ncd nec nechi neclm nectzo newdd newddl nexthi
    228   syn keyword mfConstant     nextscreen nextscrn nineone nullmode ocessfz
    229   syn keyword mfConstant     okidata okidatal okifourten okifte okihi onetz
    230   syn keyword mfConstant     onezz pcprevw pcscreen phaser phaserfs phasertf
    231   syn keyword mfConstant     phasertfl phasertl pixpt printware prntware
    232   syn keyword mfConstant     proprinter qms qmsesz qmsostf qmsoszz qmstftf ricoh
    233   syn keyword mfConstant     ricoha ricohlp ricohsp sherpa sparcptr starnlt
    234   syn keyword mfConstant     starnltl styletwo stylewr stylewri stylewriter sun
    235   syn keyword mfConstant     supre swtwo toshiba ultre varityper vs vtftzz
    236   syn keyword mfConstant     vtftzzhi vtftzzlo vtfzszw vtszz xpstzz xpstzzl
    237   syn keyword mfConstant     xrxesnz xrxfzfz xrxnszz xrxtszz
    238   syn keyword mfDef          BCPL_string coding_scheme font_face_byte
    239   syn keyword mfDef          font_family landscape
    240   syn keyword mfDef          mode_extra_info mode_help mode_param
    241   syn keyword mfNewInternal  blacker_min
    242 endif
    243 
    244 # Some other basic macro names, e.g., from cmbase, logo, etc.
    245 if get(g:, "mf_other_macros", get(g:, "other_mf_macros", 1))
    246   syn keyword mfDef          beginlogochar
    247   syn keyword mfDef          font_setup
    248   syn keyword mfPrimitive    generate
    249 endif
    250 
    251 # Numeric tokens
    252 syn match     mfNumeric      "[-]\=\d\+"
    253 syn match     mfNumeric      "[-]\=\.\d\+"
    254 syn match     mfNumeric      "[-]\=\d\+\.\d\+"
    255 
    256 # METAFONT lengths
    257 syn match     mfLength       "\<\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\>"
    258 syn match     mfLength       "[-]\=\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\="
    259 syn match     mfLength       "[-]\=\.\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\="
    260 syn match     mfLength       "[-]\=\d\+\.\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\="
    261 
    262 # String constants
    263 syn match     mfOpenString   /"[^"]*/
    264 syn region    mfString       oneline keepend start=+"+ end=+"+
    265 
    266 # Comments:
    267 syn keyword   mfTodoComment  contained TODO FIXME XXX DEBUG NOTE
    268 syn match     mfComment      "%.*$" contains=mfTodoComment,@Spell
    269 
    270 # synchronizing
    271 syn sync maxlines=100
    272 
    273 # Define the default highlighting
    274 hi def link mfBoolExp      Statement
    275 hi def link mfNumExp       Statement
    276 hi def link mfPairExp      Statement
    277 hi def link mfPathExp      Statement
    278 hi def link mfPenExp       Statement
    279 hi def link mfPicExp       Statement
    280 hi def link mfStringExp    Statement
    281 hi def link mfInternal     Identifier
    282 hi def link mfCommand      Statement
    283 hi def link mfType         Type
    284 hi def link mfStatement    Statement
    285 hi def link mfDefinition   Statement
    286 hi def link mfCondition    Conditional
    287 hi def link mfPrimitive    Statement
    288 hi def link mfDef          Function
    289 hi def link mfVardef       mfDef
    290 hi def link mfPrimaryDef   mfDef
    291 hi def link mfSecondaryDef mfDef
    292 hi def link mfTertiaryDef  mfDef
    293 hi def link mfCoord        Identifier
    294 hi def link mfPoint        Identifier
    295 hi def link mfNumeric      Number
    296 hi def link mfLength       Number
    297 hi def link mfComment      Comment
    298 hi def link mfString       String
    299 hi def link mfOpenString   Todo
    300 hi def link mfSuffixParam  Label
    301 hi def link mfNewInternal  mfInternal
    302 hi def link mfVariable     Identifier
    303 hi def link mfConstant     Constant
    304 hi def link mfTodoComment  Todo
    305 
    306 b:current_syntax = "mf"
    307 
    308 # vim: sw=2 fdm=marker