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