AvidSeeker | 3088ef0 | 2024-07-16 21:39:07 +0200 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Asymptote |
| 3 | " Maintainer: Avid Seeker <avidseeker7@protonmail.com> |
| 4 | " Andy Hammerlindl |
| 5 | " Last Change: 2022 Jan 05 |
Eisuke Kawashima | fbbaa6e | 2025-04-16 18:20:59 +0200 | [diff] [blame] | 6 | " 2025 Apr 16 by Vim Project (set 'cpoptions' for line continuation, #17121) |
AvidSeeker | 3088ef0 | 2024-07-16 21:39:07 +0200 | [diff] [blame] | 7 | |
| 8 | " Hacked together from Bram Moolenaar's C syntax file, and Claudio Fleiner's |
| 9 | " Java syntax file. |
| 10 | |
| 11 | if exists("b:current_syntax") |
| 12 | finish |
| 13 | endif |
| 14 | |
Eisuke Kawashima | fbbaa6e | 2025-04-16 18:20:59 +0200 | [diff] [blame] | 15 | let s:cpo_save = &cpo |
| 16 | set cpo&vim |
| 17 | |
AvidSeeker | 3088ef0 | 2024-07-16 21:39:07 +0200 | [diff] [blame] | 18 | " useful C/C++/Java keywords |
| 19 | syn keyword asyStatement break return continue unravel |
| 20 | syn keyword asyConditional if else |
| 21 | syn keyword asyRepeat while for do |
| 22 | syn keyword asyExternal access from import include |
| 23 | syn keyword asyOperator new operator |
| 24 | |
| 25 | " basic asymptote keywords |
| 26 | syn keyword asyConstant VERSION |
| 27 | syn keyword asyConstant true false default infinity inf nan |
| 28 | syn keyword asyConstant null nullframe nullpath nullpen |
| 29 | syn keyword asyConstant intMin intMax realMin realMax |
| 30 | syn keyword asyConstant realEpsilon realDigits |
| 31 | syn keyword asyPathSpec and cycle controls tension atleast curl |
| 32 | syn keyword asyStorageClass static public restricted private explicit |
| 33 | syn keyword asyStructure struct typedef |
| 34 | syn keyword asyType void bool bool3 int real string file |
| 35 | syn keyword asyType pair triple transform guide path pen frame |
| 36 | syn keyword asyType picture |
| 37 | |
| 38 | " module specific keywords |
| 39 | if exists("asy_syn_plain") |
| 40 | syn keyword asyConstant currentpicture currentpen defaultpen |
| 41 | syn keyword asyConstant inch inches cm mm bp pt up down right left |
| 42 | syn keyword asyConstant E NE N NW W SW S SE |
| 43 | syn keyword asyConstant ENE NNE NNW WNW WSW SSW SSE ESE |
| 44 | syn keyword asyConstant I pi twopi |
| 45 | syn keyword asyConstant CCW CW |
| 46 | syn keyword asyConstant undefined sqrtEpsilon Align mantissaBits |
| 47 | syn keyword asyConstant identity zeroTransform invert |
| 48 | syn keyword asyConstant stdin stdout |
| 49 | syn keyword asyConstant unitsquare unitcircle circleprecision |
| 50 | syn keyword asyConstant solid dotted Dotted dashed dashdotted |
| 51 | syn keyword asyConstant longdashed longdashdotted |
| 52 | syn keyword asyConstant squarecap roundcap extendcap |
| 53 | syn keyword asyConstant miterjoin roundjoin beveljoin |
| 54 | syn keyword asyConstant zerowinding evenodd basealign nobasealign |
| 55 | syn keyword asyConstant black white gray red green blue Cyan Magenta |
| 56 | syn keyword asyConstant Yellow Black cyan magenta yellow palered |
| 57 | syn keyword asyConstant palegreen paleblue palecyan palemagenta |
| 58 | syn keyword asyConstant paleyellow palegray lightred lightgreen |
| 59 | syn keyword asyConstant lightblue lightcyan lightmagenta lightyellow |
| 60 | syn keyword asyConstant lightgray mediumred mediumgreen mediumblue |
| 61 | syn keyword asyConstant mediumcyan mediummagenta mediumyellow |
| 62 | syn keyword asyConstant mediumgray heavyred heavygreen heavyblue |
| 63 | syn keyword asyConstant heavycyan heavymagenta lightolive heavygray |
| 64 | syn keyword asyConstant deepred deepgreen deepblue deepcyan |
| 65 | syn keyword asyConstant deepmagenta deepyellow deepgray darkred |
| 66 | syn keyword asyConstant darkgreen darkblue darkcyan darkmagenta |
| 67 | syn keyword asyConstant darkolive darkgray orange fuchsia chartreuse |
| 68 | syn keyword asyConstant springgreen purple royalblue salmon brown |
| 69 | syn keyword asyConstant olive darkbrown pink palegrey lightgrey |
| 70 | syn keyword asyConstant mediumgrey grey heavygrey deepgrey darkgrey |
| 71 | |
| 72 | if exists("asy_syn_texcolors") |
| 73 | syn keyword asyConstant GreenYellow Yellow Goldenrod Dandelion |
| 74 | syn keyword asyConstant Apricot Peach Melon YellowOrange Orange |
| 75 | syn keyword asyConstant BurntOrange Bittersweet RedOrange Mahogany |
| 76 | syn keyword asyConstant Maroon BrickRed Red OrangeRed RubineRed |
| 77 | syn keyword asyConstant WildStrawberry Salmon CarnationPink Magenta |
| 78 | syn keyword asyConstant VioletRed Rhodamine Mulberry RedViolet |
| 79 | syn keyword asyConstant Fuchsia Lavender Thistle Orchid DarkOrchid |
| 80 | syn keyword asyConstant Purple Plum Violet RoyalPurple BlueViolet |
| 81 | syn keyword asyConstant Periwinkle CadetBlue CornflowerBlue |
| 82 | syn keyword asyConstant MidnightBlue NavyBlue RoyalBlue Blue |
| 83 | syn keyword asyConstant Cerulean Cyan ProcessBlue SkyBlue Turquoise |
| 84 | syn keyword asyConstant TealBlue Aquamarine BlueGreen Emerald |
| 85 | syn keyword asyConstant JungleGreen SeaGreen Green ForestGreen |
| 86 | syn keyword asyConstant PineGreen LimeGreen YellowGreen SpringGreen |
| 87 | syn keyword asyConstant OliveGreen RawSienna Sepia Brown Tan Gray |
| 88 | syn keyword asyConstant Black White |
| 89 | endif |
| 90 | |
| 91 | if exists("asy_syn_x11colors") |
| 92 | syn keyword asyConstant AliceBlue AntiqueWhite Aqua Aquamarine Azure |
| 93 | syn keyword asyConstant Beige Bisque Black BlanchedAlmond Blue |
| 94 | syn keyword asyConstant BlueViolet Brown BurlyWood CadetBlue |
| 95 | syn keyword asyConstant Chartreuse Chocolate Coral CornflowerBlue |
| 96 | syn keyword asyConstant Cornsilk Crimson Cyan DarkBlue DarkCyan |
| 97 | syn keyword asyConstant DarkGoldenrod DarkGray DarkGreen DarkKhaki |
| 98 | syn keyword asyConstant DarkMagenta DarkOliveGreen DarkOrange |
| 99 | syn keyword asyConstant DarkOrchid DarkRed DarkSalmon DarkSeaGreen |
| 100 | syn keyword asyConstant DarkSlateBlue DarkSlateGray DarkTurquoise |
| 101 | syn keyword asyConstant DarkViolet DeepPink DeepSkyBlue DimGray |
| 102 | syn keyword asyConstant DodgerBlue FireBrick FloralWhite ForestGreen |
| 103 | syn keyword asyConstant Fuchsia Gainsboro GhostWhite Gold Goldenrod |
| 104 | syn keyword asyConstant Gray Green GreenYellow Honeydew HotPink |
| 105 | syn keyword asyConstant IndianRed Indigo Ivory Khaki Lavender |
| 106 | syn keyword asyConstant LavenderBlush LawnGreen LemonChiffon |
| 107 | syn keyword asyConstant LightBlue LightCoral LightCyan |
| 108 | syn keyword asyConstant LightGoldenrodYellow LightGreen LightGrey |
| 109 | syn keyword asyConstant LightPink LightSalmon LightSeaGreen |
| 110 | syn keyword asyConstant LightSkyBlue LightSlateGray LightSteelBlue |
| 111 | syn keyword asyConstant LightYellow Lime LimeGreen Linen Magenta |
| 112 | syn keyword asyConstant Maroon MediumAquamarine MediumBlue |
| 113 | syn keyword asyConstant MediumOrchid MediumPurple MediumSeaGreen |
| 114 | syn keyword asyConstant MediumSlateBlue MediumSpringGreen |
| 115 | syn keyword asyConstant MediumTurquoise MediumVioletRed MidnightBlue |
| 116 | syn keyword asyConstant MintCream MistyRose Moccasin NavajoWhite |
| 117 | syn keyword asyConstant Navy OldLace Olive OliveDrab Orange |
| 118 | syn keyword asyConstant OrangeRed Orchid PaleGoldenrod PaleGreen |
| 119 | syn keyword asyConstant PaleTurquoise PaleVioletRed PapayaWhip |
| 120 | syn keyword asyConstant PeachPuff Peru Pink Plum PowderBlue Purple |
| 121 | syn keyword asyConstant Red RosyBrown RoyalBlue SaddleBrown Salmon |
| 122 | syn keyword asyConstant SandyBrown SeaGreen Seashell Sienna Silver |
| 123 | syn keyword asyConstant SkyBlue SlateBlue SlateGray Snow SpringGreen |
| 124 | syn keyword asyConstant SteelBlue Tan Teal Thistle Tomato Turquoise |
| 125 | syn keyword asyConstant Violet Wheat White WhiteSmoke Yellow |
| 126 | syn keyword asyConstant YellowGreen |
| 127 | endif |
| 128 | |
| 129 | if exists("asy_syn_three") |
| 130 | syn keyword asyType path3 guide3 transform3 |
| 131 | syn keyword asyType projection light material patch surface tube |
| 132 | syn keyword asyConstant currentprojection currentlight defaultrender |
| 133 | syn keyword asyConstant identity4 O X Y Z |
| 134 | syn keyword asyConstant nolight nullpens |
| 135 | syn keyword asyConstant unitsphere unithemisphere unitplane octant1 |
| 136 | syn keyword asyConstant unitcone unitsolidcone unitcube unitcylinder |
| 137 | syn keyword asyConstant unitdisk unittube |
| 138 | endif |
| 139 | endif |
| 140 | |
| 141 | |
| 142 | " string constants |
| 143 | syn region asyCString start=+'+ end=+'+ skip=+\\\\\|\\'+ contains=asyCSpecial |
| 144 | syn match asyCSpecial display contained +\\\(['"?\\abfnrtv]\|\o\{1,3}\)+ |
| 145 | syn match asyCSpecial display contained +\\\(x[0-9A-F]\{1,2\}\|$\)+ |
| 146 | " double quoted strings only special character is \" |
| 147 | syn region asyString start=+"+ end=+"+ skip=+\\\\\|\\"+ contains=asySpecial |
| 148 | syn match asySpecial display contained +\(\\\)\@1<!\(\\\\\)*\zs\\"+ |
| 149 | |
| 150 | |
| 151 | " number constants |
| 152 | syn match asyNumbers display transparent "\<\d\|\.\d" |
| 153 | \ contains=asyNumber,asyNumberError |
| 154 | syn match asyNumber display contained "\d*\.\=\d*\(e[-+]\=\d\+\)\=" |
| 155 | " highlight number constants with two '.' or with '.' after an 'e' |
| 156 | syn match asyNumberError display contained "\d*\.\(\d\|e[-+]\=\)*\.[0-9.]*" |
| 157 | syn match asyNumberError display contained "\d*e[-+]\=\d*\.[0-9.]*" |
| 158 | syn match asyNumberError display contained "\d*e[-+]\=\(e[-+]\=\)*\.[0-9.]*" |
| 159 | |
| 160 | |
| 161 | " comments and comment strings |
| 162 | syn keyword asyTodo contained TODO FIXME XXX |
| 163 | syn sync ccomment asyComment minlines=15 |
| 164 | if exists("asy_comment_strings") |
| 165 | " A comment can contain asyString, asyCString, and asyNumber. But a "*/" |
| 166 | " inside a asy*String in a asyComment DOES end the comment! So we need to |
| 167 | " use a special type of asy*String: asyComment*String, which also ends on |
| 168 | " "*/", and sees a "*" at the start of the line as comment again. |
| 169 | " Unfortunately this doesn't very well work for // type of comments :-( |
| 170 | syn match asyCommentSkip contained "^\s*\*\($\|\s\+\)" |
| 171 | syn region asyCommentString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ |
| 172 | \ end=+\*/+me=s-1 |
| 173 | \ contains=asySpecial,asyCommentSkip |
| 174 | syn region asyCommentCString contained start=+'+ skip=+\\\\\|\\'+ end=+'+ |
| 175 | \ end=+\*/+me=s-1 |
| 176 | \ contains=asyCSpecial,asyCommentSkip |
| 177 | syn region asyCommentLString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ |
| 178 | \ end="$" contains=asySpecial |
| 179 | syn region asyCommentLCString contained start=+'+ skip=+\\\\\|\\'+ end=+'+ |
| 180 | \ end="$" contains=asyCSpecial |
| 181 | syn region asyCommentL start="//" skip="\\$" end="$" keepend |
| 182 | \ contains=asyTodo,asyCommentLString, |
| 183 | \ asyCommentLCString,asyNumbers |
| 184 | syn region asyComment matchgroup=asyComment start="/\*" end="\*/" |
| 185 | \ contains=asyTodo,asyCommentStartError, |
| 186 | \ asyCommentString,asyCommentCString,asyNumbers |
| 187 | else |
| 188 | syn region asyCommentL start="//" skip="\\$" end="$" keepend |
| 189 | \ contains=asyTodo |
| 190 | syn region asyComment matchgroup=asyComment start="/\*" end="\*/" |
| 191 | \ contains=asyTodo,asyCommentStartError |
| 192 | endif |
| 193 | |
| 194 | " highlight common errors when starting/ending C comments |
| 195 | syn match asyCommentError display "\*/" |
| 196 | syn match asyCommentStartError display "/\*"me=e-1 contained |
| 197 | |
| 198 | |
| 199 | " delimiter matching errors |
| 200 | syn region asyCurly transparent start='{' end='}' |
| 201 | \ contains=TOP,asyCurlyError |
| 202 | syn region asyBrack transparent start='\[' end='\]' matchgroup=asyError |
| 203 | \ end=';' contains=TOP,asyBrackError |
| 204 | syn region asyParen transparent start='(' end=')' matchgroup=asyError |
| 205 | \ end=';' contains=TOP,asyParenError |
| 206 | syn match asyCurlyError display '}' |
| 207 | syn match asyBrackError display '\]' |
| 208 | syn match asyParenError display ')' |
| 209 | " for (;;) constructs are exceptions that allow ; inside parenthesis |
| 210 | syn region asyParen transparent matchgroup=asyParen |
| 211 | \ start='\(for\s*\)\@<=(' end=')' |
| 212 | \ contains=TOP,asyParenError |
| 213 | |
| 214 | " Define the default highlighting. |
| 215 | hi def link asyCommentL asyComment |
| 216 | hi def link asyConditional Conditional |
| 217 | hi def link asyRepeat Repeat |
| 218 | hi def link asyNumber Number |
| 219 | hi def link asyNumberError asyError |
| 220 | hi def link asyCurlyError asyError |
| 221 | hi def link asyBracketError asyError |
| 222 | hi def link asyParenError asyError |
| 223 | hi def link asyCommentError asyError |
| 224 | hi def link asyCommentStartError asyError |
| 225 | hi def link asyOperator Operator |
| 226 | hi def link asyStructure Structure |
| 227 | hi def link asyStorageClass StorageClass |
| 228 | hi def link asyExternal Include |
| 229 | hi def link asyDefine Macro |
| 230 | hi def link asyError Error |
| 231 | hi def link asyStatement Statement |
| 232 | hi def link asyType Type |
| 233 | hi def link asyConstant Constant |
| 234 | hi def link asyCommentString asyString |
| 235 | hi def link asyCommentCString asyString |
| 236 | hi def link asyCommentLString asyString |
| 237 | hi def link asyCommentLCString asyString |
| 238 | hi def link asyCommentSkip asyComment |
| 239 | hi def link asyString String |
| 240 | hi def link asyCString String |
| 241 | hi def link asyComment Comment |
| 242 | hi def link asySpecial SpecialChar |
| 243 | hi def link asyCSpecial SpecialChar |
| 244 | hi def link asyTodo Todo |
| 245 | hi def link asyPathSpec Statement |
| 246 | |
| 247 | let b:current_syntax = "asy" |
Eisuke Kawashima | fbbaa6e | 2025-04-16 18:20:59 +0200 | [diff] [blame] | 248 | let &cpo = s:cpo_save |
| 249 | unlet s:cpo_save |