blob: de17d925d0a642f8bcf509bc560c7dd3f0869c3e [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
Eisuke Kawashimafbbaa6e2025-04-16 18:20:59 +02006" 2025 Apr 16 by Vim Project (set 'cpoptions' for line continuation, #17121)
AvidSeeker3088ef02024-07-16 21:39:07 +02007
8" Hacked together from Bram Moolenaar's C syntax file, and Claudio Fleiner's
9" Java syntax file.
10
11if exists("b:current_syntax")
12 finish
13endif
14
Eisuke Kawashimafbbaa6e2025-04-16 18:20:59 +020015let s:cpo_save = &cpo
16set cpo&vim
17
AvidSeeker3088ef02024-07-16 21:39:07 +020018" 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")
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
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 ccomment asyComment 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 :-(
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
187else
188 syn region asyCommentL start="//" skip="\\$" end="$" keepend
189 \ contains=asyTodo
190 syn 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-1 contained
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"
Eisuke Kawashimafbbaa6e2025-04-16 18:20:59 +0200248let &cpo = s:cpo_save
249unlet s:cpo_save