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