blob: d1faa1913ef1fa80dd721653f71e9b0b0341b06f [file] [log] [blame]
Bram Moolenaare1f3fd12022-08-15 18:51:32 +01001vim9script
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: 2022 Aug 12
Bram Moolenaar071d4272004-06-13 20:20:40 +00008
Bram Moolenaar89bcfda2016-08-30 23:26:57 +02009if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000010 finish
11endif
12
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010013# Deprecation warnings: to be removed eventually
14if exists("g:plain_mf_macros")
15 echomsg "[mf] g:plain_mf_macros is deprecated: use g:mf_plain_macros instead."
16endif
17if exists("g:plain_mf_modes")
18 echomsg "[mf] g:plain_mf_modes is deprecated: use g:mf_plain_modes instead."
19endif
20if exists("g:other_mf_macros")
21 echomsg "[mf] g:other_mf_macros is deprecated: use g:mf_other_macros instead."
22endif
23
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020024syn iskeyword @,_
25
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010026# METAFONT 'primitives' as defined in chapter 25 of 'The METAFONTbook'
27# Page 210: 'boolean expressions'
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020028syn keyword mfBoolExp and charexists false known not odd or true unknown
Bram Moolenaar071d4272004-06-13 20:20:40 +000029
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010030# Page 210: 'numeric expression'
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020031syn keyword mfNumExp ASCII angle cosd directiontime floor hex length
32syn keyword mfNumExp mexp mlog normaldeviate oct sind sqrt totalweight
33syn keyword mfNumExp turningnumber uniformdeviate xpart xxpart xypart
34syn keyword mfNumExp ypart yxpart yypart
Bram Moolenaar071d4272004-06-13 20:20:40 +000035
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010036# Page 211: 'internal quantities'
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020037syn keyword mfInternal autorounding boundarychar charcode chardp chardx
38syn keyword mfInternal chardy charext charht charic charwd day designsize
39syn keyword mfInternal fillin fontmaking granularity hppp jobname month
40syn keyword mfInternal pausing proofing showstopping smoothing time
41syn keyword mfInternal tracingcapsules tracingchoices tracingcommands
42syn keyword mfInternal tracingedges tracingequations tracingmacros
43syn keyword mfInternal tracingonline tracingoutput tracingpens
44syn keyword mfInternal tracingrestores tracingspecs tracingstats
45syn keyword mfInternal tracingtitles turningcheck vppp warningcheck
46syn keyword mfInternal xoffset year yoffset
Bram Moolenaar071d4272004-06-13 20:20:40 +000047
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010048# Page 212: 'pair expressions'
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020049syn keyword mfPairExp of penoffset point postcontrol precontrol rotated
50syn keyword mfPairExp scaled shifted slanted transformed xscaled yscaled
51syn keyword mfPairExp zscaled
Bram Moolenaar071d4272004-06-13 20:20:40 +000052
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010053# Page 213: 'path expressions'
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020054syn keyword mfPathExp atleast controls curl cycle makepath reverse
55syn keyword mfPathExp subpath tension
Bram Moolenaar071d4272004-06-13 20:20:40 +000056
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010057# Page 214: 'pen expressions'
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020058syn keyword mfPenExp makepen nullpen pencircle
Bram Moolenaar071d4272004-06-13 20:20:40 +000059
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010060# Page 214: 'picture expressions'
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020061syn keyword mfPicExp nullpicture
Bram Moolenaar071d4272004-06-13 20:20:40 +000062
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010063# Page 214: 'string expressions'
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020064syn keyword mfStringExp char decimal readstring str substring
Bram Moolenaar071d4272004-06-13 20:20:40 +000065
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010066# Page 217: 'commands and statements'
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020067syn keyword mfCommand addto also at batchmode contour cull delimiters
68syn keyword mfCommand display doublepath dropping dump end errhelp
69syn keyword mfCommand errmessage errorstopmode everyjob from interim
70syn keyword mfCommand inwindow keeping let message newinternal
71syn keyword mfCommand nonstopmode numspecial openwindow outer randomseed
72syn keyword mfCommand save scrollmode shipout show showdependencies
73syn keyword mfCommand showstats showtoken showvariable special to withpen
74syn keyword mfCommand withweight
Bram Moolenaar071d4272004-06-13 20:20:40 +000075
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010076# Page 56: 'types'
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020077syn keyword mfType boolean numeric pair path pen picture string
78syn keyword mfType transform
Bram Moolenaar071d4272004-06-13 20:20:40 +000079
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010080# Page 155: 'grouping'
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020081syn keyword mfStatement begingroup endgroup
Bram Moolenaar071d4272004-06-13 20:20:40 +000082
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010083# Page 165: 'definitions'
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020084syn keyword mfDefinition def enddef expr primary primarydef secondary
85syn keyword mfDefinition secondarydef suffix tertiary tertiarydef text
86syn keyword mfDefinition vardef
Bram Moolenaar071d4272004-06-13 20:20:40 +000087
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010088# Page 169: 'conditions and loops'
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020089syn keyword mfCondition else elseif endfor exitif fi for forever
90syn keyword mfCondition forsuffixes if step until
Bram Moolenaar071d4272004-06-13 20:20:40 +000091
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010092# Other primitives listed in the index
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020093syn keyword mfPrimitive charlist endinput expandafter extensible fontdimen
94syn keyword mfPrimitive headerbyte inner input intersectiontimes kern
95syn keyword mfPrimitive ligtable quote scantokens skipto
96
Bram Moolenaare1f3fd12022-08-15 18:51:32 +010097# Implicit suffix parameters
Bram Moolenaar2ec618c2016-10-01 14:47:05 +020098syn match mfSuffixParam "@#\|#@\|@"
99
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100100# These are just tags, but given their special status, we
101# highlight them as variables
Bram Moolenaar2ec618c2016-10-01 14:47:05 +0200102syn keyword mfVariable x y
Bram Moolenaar071d4272004-06-13 20:20:40 +0000103
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100104# Keywords defined by plain.mf (defined on pp.262-278)
105if get(g:, "mf_plain_macros", get(g:, "plain_mf_macros", 1))
Bram Moolenaar2ec618c2016-10-01 14:47:05 +0200106 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
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100133 # Note: nodot is not a vardef, it is used as in makelabel.lft.nodot("5",z5)
134 # (METAFONT only)
Bram Moolenaar2ec618c2016-10-01 14:47:05 +0200135 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
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100146 # Predefined constants
Bram Moolenaar2ec618c2016-10-01 14:47:05 +0200147 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
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100151 # Other predefined variables
Bram Moolenaar2ec618c2016-10-01 14:47:05 +0200152 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
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100156 # let statements:
Bram Moolenaar2ec618c2016-10-01 14:47:05 +0200157 syn keyword mfnumExp abs
158 syn keyword mfPairExp rotatedabout
159 syn keyword mfCommand bye relax
Bram Moolenaar071d4272004-06-13 20:20:40 +0000160endif
Bram Moolenaar2ec618c2016-10-01 14:47:05 +0200161
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100162# By default, METAFONT loads modes.mf, too
163if get(g:, "plain_mf_modes", get(g:, "mf_plain_modes", 1))
Bram Moolenaar2ec618c2016-10-01 14:47:05 +0200164 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000242endif
243
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100244# Some other basic macro names, e.g., from cmbase, logo, etc.
245if get(g:, "mf_other_macros", get(g:, "other_mf_macros", 1))
Bram Moolenaar2ec618c2016-10-01 14:47:05 +0200246 syn keyword mfDef beginlogochar
247 syn keyword mfDef font_setup
248 syn keyword mfPrimitive generate
Bram Moolenaar071d4272004-06-13 20:20:40 +0000249endif
250
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100251# Numeric tokens
Bram Moolenaar2ec618c2016-10-01 14:47:05 +0200252syn match mfNumeric "[-]\=\d\+"
253syn match mfNumeric "[-]\=\.\d\+"
254syn match mfNumeric "[-]\=\d\+\.\d\+"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000255
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100256# METAFONT lengths
Bram Moolenaar2ec618c2016-10-01 14:47:05 +0200257syn match mfLength "\<\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\>"
258syn match mfLength "[-]\=\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\="
259syn match mfLength "[-]\=\.\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\="
260syn match mfLength "[-]\=\d\+\.\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\="
Bram Moolenaar071d4272004-06-13 20:20:40 +0000261
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100262# String constants
Bram Moolenaar2ec618c2016-10-01 14:47:05 +0200263syn match mfOpenString /"[^"]*/
264syn region mfString oneline keepend start=+"+ end=+"+
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100266# Comments:
Bram Moolenaar2ec618c2016-10-01 14:47:05 +0200267syn keyword mfTodoComment contained TODO FIXME XXX DEBUG NOTE
268syn match mfComment "%.*$" contains=mfTodoComment,@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000269
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100270# synchronizing
271syn sync maxlines=100
Bram Moolenaar071d4272004-06-13 20:20:40 +0000272
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100273# Define the default highlighting
Bram Moolenaar2ec618c2016-10-01 14:47:05 +0200274hi def link mfBoolExp Statement
275hi def link mfNumExp Statement
276hi def link mfPairExp Statement
277hi def link mfPathExp Statement
278hi def link mfPenExp Statement
279hi def link mfPicExp Statement
280hi def link mfStringExp Statement
281hi def link mfInternal Identifier
282hi def link mfCommand Statement
283hi def link mfType Type
284hi def link mfStatement Statement
285hi def link mfDefinition Statement
286hi def link mfCondition Conditional
287hi def link mfPrimitive Statement
288hi def link mfDef Function
289hi def link mfVardef mfDef
290hi def link mfPrimaryDef mfDef
291hi def link mfSecondaryDef mfDef
292hi def link mfTertiaryDef mfDef
293hi def link mfCoord Identifier
294hi def link mfPoint Identifier
295hi def link mfNumeric Number
296hi def link mfLength Number
297hi def link mfComment Comment
298hi def link mfString String
299hi def link mfOpenString Todo
300hi def link mfSuffixParam Label
301hi def link mfNewInternal mfInternal
302hi def link mfVariable Identifier
303hi def link mfConstant Constant
304hi def link mfTodoComment Todo
Bram Moolenaar071d4272004-06-13 20:20:40 +0000305
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100306b:current_syntax = "mf"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000307
Bram Moolenaare1f3fd12022-08-15 18:51:32 +0100308# vim: sw=2 fdm=marker