Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Metafont |
| 3 | " Maintainer: Andreas Scherer <andreas.scherer@pobox.com> |
| 4 | " Last Change: April 25, 2001 |
| 5 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 6 | " quit when a syntax file was already loaded |
| 7 | if exists("b:current_syntax") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8 | finish |
| 9 | endif |
| 10 | |
| 11 | " Metafont 'primitives' as defined in chapter 25 of 'The METAFONTbook' |
| 12 | " Page 210: 'boolean expressions' |
| 13 | syn keyword mfBoolExp true false known unknown odd charexists not and or |
| 14 | |
| 15 | " Page 210: 'numeric expression' |
| 16 | syn keyword mfNumExp normaldeviate length ASCII oct hex angle turningnumber |
| 17 | syn keyword mfNumExp totalweight directiontime xpart ypart xxpart xypart |
| 18 | syn keyword mfNumExp yxpart yypart sqrt sind cosd mlog mexp floor |
| 19 | syn keyword mfNumExp uniformdeviate |
| 20 | |
| 21 | " Page 211: 'internal quantities' |
| 22 | syn keyword mfInternal tracingtitles tracingequations tracingcapsules |
| 23 | syn keyword mfInternal tracingchoices tracingspecs tracingpens |
| 24 | syn keyword mfInternal tracingcommands tracingrestores tracingmacros |
| 25 | syn keyword mfInternal tracingedges tracingoutput tracingonline tracingstats |
| 26 | syn keyword mfInternal pausing showstopping fontmaking proofing |
| 27 | syn keyword mfInternal turningcheck warningcheck smoothing autorounding |
| 28 | syn keyword mfInternal granularity fillin year month day time |
| 29 | syn keyword mfInternal charcode charext charwd charht chardp charic |
| 30 | syn keyword mfInternal chardx chardy designsize hppp vppp xoffset yoffset |
| 31 | syn keyword mfInternal boundarychar |
| 32 | |
| 33 | " Page 212: 'pair expressions' |
| 34 | syn keyword mfPairExp point of precontrol postcontrol penoffset rotated |
| 35 | syn keyword mfPairExp scaled shifted slanted transformed xscaled yscaled |
| 36 | syn keyword mfPairExp zscaled |
| 37 | |
| 38 | " Page 213: 'path expressions' |
| 39 | syn keyword mfPathExp makepath reverse subpath curl tension atleast |
| 40 | syn keyword mfPathExp controls cycle |
| 41 | |
| 42 | " Page 214: 'pen expressions' |
| 43 | syn keyword mfPenExp nullpen pencircle makepen |
| 44 | |
| 45 | " Page 214: 'picutre expressions' |
| 46 | syn keyword mfPicExp nullpicture |
| 47 | |
| 48 | " Page 214: 'string expressions' |
| 49 | syn keyword mfStringExp jobname readstring str char decimal substring |
| 50 | |
| 51 | " Page 217: 'commands and statements' |
| 52 | syn keyword mfCommand end dump save interim newinternal randomseed let |
| 53 | syn keyword mfCommand delimiters outer everyjob show showvariable showtoken |
| 54 | syn keyword mfCommand showdependencies showstats message errmessage errhelp |
| 55 | syn keyword mfCommand batchmode nonstopmode scrollmode errorstopmode |
| 56 | syn keyword mfCommand addto also contour doublepath withpen withweight cull |
| 57 | syn keyword mfCommand keeping dropping display inwindow openwindow at from to |
| 58 | syn keyword mfCommand shipout special numspecial |
| 59 | |
| 60 | " Page 56: 'types' |
| 61 | syn keyword mfType boolean numeric pair path pen picture string transform |
| 62 | |
| 63 | " Page 155: 'grouping' |
| 64 | syn keyword mfStatement begingroup endgroup |
| 65 | |
| 66 | " Page 165: 'definitions' |
| 67 | syn keyword mfDefinition enddef def expr suffix text primary secondary |
| 68 | syn keyword mfDefinition tertiary vardef primarydef secondarydef tertiarydef |
| 69 | |
| 70 | " Page 169: 'conditions and loops' |
| 71 | syn keyword mfCondition if fi else elseif endfor for forsuffixes forever |
| 72 | syn keyword mfCondition step until exitif |
| 73 | |
| 74 | " Other primitives listed in the index |
| 75 | syn keyword mfPrimitive charlist endinput expandafter extensible |
| 76 | syn keyword mfPrimitive fontdimen headerbyte inner input intersectiontimes |
| 77 | syn keyword mfPrimitive kern ligtable quote scantokens skipto |
| 78 | |
| 79 | " Keywords defined by plain.mf (defined on pp.262-278) |
| 80 | if !exists("plain_mf_macros") |
| 81 | let plain_mf_macros = 1 " Set this to '0' if your source gets too colourful |
| 82 | " metapost.vim does so to turn off Metafont macros |
| 83 | endif |
| 84 | if plain_mf_macros |
| 85 | syn keyword mfMacro abs addto_currentpicture aspect_ratio base_name |
| 86 | syn keyword mfMacro base_version beginchar blacker blankpicture bot bye byte |
| 87 | syn keyword mfMacro capsule_def ceiling change_width clear_pen_memory clearit |
| 88 | syn keyword mfMacro clearpen clearxy counterclockwise culldraw cullit |
| 89 | syn keyword mfMacro currentpen currentpen_path currentpicture |
| 90 | syn keyword mfMacro currenttransform currentwindow cutdraw cutoff d decr |
| 91 | syn keyword mfMacro define_blacker_pixels define_corrected_pixels |
| 92 | syn keyword mfMacro define_good_x_pixels define_good_y_pixels |
| 93 | syn keyword mfMacro define_horizontal_corrected_pixels define_pixels |
| 94 | syn keyword mfMacro define_whole_blacker_pixels define_whole_pixels |
| 95 | syn keyword mfMacro define_whole_vertical_blacker_pixels |
| 96 | syn keyword mfMacro define_whole_vertical_pixels dir direction directionpoint |
| 97 | syn keyword mfMacro displaying ditto div dotprod down downto draw drawdot |
| 98 | syn keyword mfMacro endchar eps epsilon extra_beginchar extra_endchar |
| 99 | syn keyword mfMacro extra_setup erase exitunless fill filldraw fix_units flex |
| 100 | syn keyword mfMacro font_coding_scheme font_extra_space font_identifier |
| 101 | syn keyword mfMacro font_normal_shrink font_normal_space font_normal_stretch |
| 102 | syn keyword mfMacro font_quad font_setup font_size font_slant font_x_height |
| 103 | syn keyword mfMacro fullcircle generate gfcorners gobble gobbled grayfont h |
| 104 | syn keyword mfMacro halfcircle hide hround identity image_rules incr infinity |
| 105 | syn keyword mfMacro interact interpath intersectionpoint inverse italcorr |
| 106 | syn keyword mfMacro join_radius killtext labelfont labels left lft localfont |
| 107 | syn keyword mfMacro loggingall lowres lowres_fix mag magstep makebox makegrid |
| 108 | syn keyword mfMacro makelabel maketicks max min mod mode mode_def mode_name |
| 109 | syn keyword mfMacro mode_setup nodisplays notransforms number_of_modes numtok |
| 110 | syn keyword mfMacro o_correction openit origin pen_bot pen_lft pen_rt pen_top |
| 111 | syn keyword mfMacro penlabels penpos penrazor penspeck pensquare penstroke |
| 112 | syn keyword mfMacro pickup pixels_per_inch proof proofoffset proofrule |
| 113 | syn keyword mfMacro proofrulethickness quartercircle range reflectedabout |
| 114 | syn keyword mfMacro relax right rotatedabout rotatedaround round rt rulepen |
| 115 | syn keyword mfMacro savepen screenchars screen_rows screen_cols screenrule |
| 116 | syn keyword mfMacro screenstrokes shipit showit slantfont smode smoke softjoin |
| 117 | syn keyword mfMacro solve stop superellipse takepower tensepath titlefont |
| 118 | syn keyword mfMacro tolerance top tracingall tracingnone undraw undrawdot |
| 119 | syn keyword mfMacro unfill unfilldraw unitpixel unitsquare unitvector up upto |
| 120 | syn keyword mfMacro vround w whatever |
| 121 | endif |
| 122 | |
| 123 | " Some other basic macro names, e.g., from cmbase, logo, etc. |
| 124 | if !exists("other_mf_macros") |
| 125 | let other_mf_macros = 1 " Set this to '0' if your code gets too colourful |
| 126 | " metapost.vim does so to turn off Metafont macros |
| 127 | endif |
| 128 | if other_mf_macros |
| 129 | syn keyword mfMacro beginlogochar |
| 130 | endif |
| 131 | |
| 132 | " Numeric tokens |
| 133 | syn match mfNumeric "[-]\=\d\+" |
| 134 | syn match mfNumeric "[-]\=\.\d\+" |
| 135 | syn match mfNumeric "[-]\=\d\+\.\d\+" |
| 136 | |
| 137 | " Metafont lengths |
| 138 | syn match mfLength "\<\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\>" |
| 139 | syn match mfLength "\<[-]\=\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\=\>" |
| 140 | syn match mfLength "\<[-]\=\.\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\=\>" |
| 141 | syn match mfLength "\<[-]\=\d\+\.\d\+\(bp\|cc\|cm\|dd\|in\|mm\|pc\|pt\)\#\=\>" |
| 142 | |
| 143 | " Metafont coordinates and points |
| 144 | syn match mfCoord "\<[xy]\d\+\>" |
| 145 | syn match mfPoint "\<z\d\+\>" |
| 146 | |
| 147 | " String constants |
| 148 | syn region mfString start=+"+ end=+"+ |
| 149 | |
| 150 | " Comments: |
| 151 | syn match mfComment "%.*$" |
| 152 | |
| 153 | " synchronizing |
| 154 | syn sync maxlines=50 |
| 155 | |
| 156 | " Define the default highlighting |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 157 | " Only when an item doesn't have highlighting yet |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 158 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 159 | hi def link mfBoolExp Statement |
| 160 | hi def link mfNumExp Statement |
| 161 | hi def link mfInternal Identifier |
| 162 | hi def link mfPairExp Statement |
| 163 | hi def link mfPathExp Statement |
| 164 | hi def link mfPenExp Statement |
| 165 | hi def link mfPicExp Statement |
| 166 | hi def link mfStringExp Statement |
| 167 | hi def link mfCommand Statement |
| 168 | hi def link mfType Type |
| 169 | hi def link mfStatement Statement |
| 170 | hi def link mfDefinition Statement |
| 171 | hi def link mfCondition Conditional |
| 172 | hi def link mfPrimitive Statement |
| 173 | hi def link mfMacro Macro |
| 174 | hi def link mfCoord Identifier |
| 175 | hi def link mfPoint Identifier |
| 176 | hi def link mfNumeric Number |
| 177 | hi def link mfLength Number |
| 178 | hi def link mfComment Comment |
| 179 | hi def link mfString String |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 180 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 181 | |
| 182 | let b:current_syntax = "mf" |
| 183 | |
| 184 | " vim: ts=8 |