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