| |
1 " Vim syntax file |
| |
2 " Language: haxe |
| |
3 |
| |
4 " Please check :help haxe.vim for comments on some of the options available. |
| |
5 |
| |
6 "set errorformat=%f\:%l\:\ characters\ %c-%*[^\ ]\ %m,%f\:%l\:\ %m |
| |
7 set errorformat=%f\:%l\:\ characters\ %c-%*[^\ ]\ %m,%f\:%l\:\ %m |
| |
8 |
| |
9 " Quit when a syntax file was already loaded |
| |
10 if !exists("main_syntax") |
| |
11 if version < 600 |
| |
12 syntax clear |
| |
13 elseif exists("b:current_syntax") |
| |
14 finish |
| |
15 endif |
| |
16 " we define it here so that included files can test for it |
| |
17 let main_syntax='haxe' |
| |
18 endif |
| |
19 |
| |
20 " don't use standard HiLink, it will not work with included syntax files |
| |
21 if version < 508 |
| |
22 command! -nargs=+ HaxeHiLink hi link <args> |
| |
23 else |
| |
24 command! -nargs=+ HaxeHiLink hi def link <args> |
| |
25 endif |
| |
26 |
| |
27 " some characters that cannot be in a haxe program (outside a string) |
| |
28 syn match haxeError "[\\@`]" |
| |
29 syn match haxeError "<<<\|=>\|<>\|||=\|&&=\|\*\/" |
| |
30 |
| |
31 " use separate name so that it can be deleted in haxecc.vim |
| |
32 syn match haxeError2 "#\|=<" |
| |
33 HaxeHiLink haxeError2 haxeError |
| |
34 |
| |
35 |
| |
36 " keyword definitions |
| |
37 syn keyword haxeExternal import extern package |
| |
38 syn keyword haxeConditional if else switch |
| |
39 syn keyword haxeRepeat while for do in |
| |
40 syn keyword haxeBoolean true false |
| |
41 syn keyword haxeConstant null |
| |
42 syn keyword haxeTypedef this super |
| |
43 syn keyword haxeOperator new cast |
| |
44 syn keyword haxeType Void Bool Int Float Dynamic |
| |
45 syn keyword haxeStatement return |
| |
46 syn keyword haxeStorageClass function var final typedef enum |
| |
47 " syn keyword haxeStatic |
| |
48 syn keyword haxeExceptions throw try catch finally untyped |
| |
49 syn keyword haxeAssert assert |
| |
50 syn keyword haxeMethodDecl synchronized throws |
| |
51 syn keyword haxeClassDecl extends implements interface |
| |
52 syn match haxeOperator "\.\.\." |
| |
53 " to differentiate the keyword class from MyClass.class we use a match here |
| |
54 syn match haxeTypedef "\.\s*\<class\>"ms=s+1 |
| |
55 syn match haxeClassDecl "^class\>" |
| |
56 syn match haxeClassDecl "[^.]\s*\<class\>"ms=s+1 |
| |
57 syn keyword haxeBranch break continue nextgroup=haxeUserLabelRef skipwhite |
| |
58 syn match haxeUserLabelRef "\k\+" contained |
| |
59 syn keyword haxeScopeDecl static public protected private abstract override |
| |
60 |
| |
61 " haxe.lang.* |
| |
62 syn match haxeLangClass "\<System\>" |
| |
63 syn keyword haxeLangClass Array BasicType Class Date DateTools EReg Hash IntHash IntIter Iterator Lambda List Math Md5 Reflect Std String StringBuf StringTools Xml XmlType |
| |
64 HaxeHiLink haxeLangClass haxeConstant |
| |
65 HaxeHiLink haxeLangObject haxeConstant |
| |
66 syn cluster haxeTop add=haxeLangObject,haxeLangClass |
| |
67 syn cluster haxeClasses add=haxeLangClass |
| |
68 |
| |
69 if filereadable(expand("<sfile>:p:h")."/haxeid.vim") |
| |
70 source <sfile>:p:h/haxeid.vim |
| |
71 endif |
| |
72 |
| |
73 if exists("haxe_space_errors") |
| |
74 if !exists("haxe_no_trail_space_error") |
| |
75 syn match haxeSpaceError "\s\+$" |
| |
76 endif |
| |
77 if !exists("haxe_no_tab_space_error") |
| |
78 syn match haxeSpaceError " \+\t"me=e-1 |
| |
79 endif |
| |
80 endif |
| |
81 |
| |
82 syn region haxeLabelRegion transparent matchgroup=haxeLabel start="\<case\>" matchgroup=NONE end=":" contains=haxeNumber,haxeCharacter |
| |
83 syn match haxeUserLabel "^\s*[_$a-zA-Z][_$a-zA-Z0-9_]*\s*:"he=e-1 contains=haxeLabel |
| |
84 syn keyword haxeLabel default |
| |
85 |
| |
86 " The following cluster contains all haxe groups except the contained ones |
| |
87 syn cluster haxeTop add=haxeExternal,haxeError,haxeError,haxeBranch,haxeLabelRegion,haxeLabel,haxeConditional,haxeRepeat,haxeBoolean,haxeConstant,haxeTypedef,haxeOperator,haxeType,haxeType,haxeStatement,haxeStorageClass,haxeAssert,haxeExceptions,haxeMethodDecl,haxeClassDecl,haxeClassDecl,haxeClassDecl,haxeScopeDecl,haxeError,haxeError2,haxeUserLabel,haxeLangObject |
| |
88 |
| |
89 |
| |
90 " Comments |
| |
91 syn keyword haxeTodo contained TODO FIXME XXX |
| |
92 if exists("haxe_comment_strings") |
| |
93 syn region haxeCommentString contained start=+"+ end=+"+ end=+$+ end=+\*/+me=s-1,he=s-1 contains=haxeSpecial,haxeCommentStar,haxeSpecialChar,@Spell |
| |
94 syn region haxeComment2String contained start=+"+ end=+$\|"+ contains=haxeSpecial,haxeSpecialChar,@Spell |
| |
95 syn match haxeCommentCharacter contained "'\\[^']\{1,6\}'" contains=haxeSpecialChar |
| |
96 syn match haxeCommentCharacter contained "'\\''" contains=haxeSpecialChar |
| |
97 syn match haxeCommentCharacter contained "'[^\\]'" |
| |
98 syn cluster haxeCommentSpecial add=haxeCommentString,haxeCommentCharacter,haxeNumber |
| |
99 syn cluster haxeCommentSpecial2 add=haxeComment2String,haxeCommentCharacter,haxeNumber |
| |
100 endif |
| |
101 syn region haxeComment start="/\*" end="\*/" contains=@haxeCommentSpecial,haxeTodo,@Spell |
| |
102 syn match haxeCommentStar contained "^\s*\*[^/]"me=e-1 |
| |
103 syn match haxeCommentStar contained "^\s*\*$" |
| |
104 syn match haxeLineComment "//.*" contains=@haxeCommentSpecial2,haxeTodo,@Spell |
| |
105 HaxeHiLink haxeCommentString haxeString |
| |
106 HaxeHiLink haxeComment2String haxeString |
| |
107 HaxeHiLink haxeCommentCharacter haxeCharacter |
| |
108 |
| |
109 syn cluster haxeTop add=haxeComment,haxeLineComment |
| |
110 |
| |
111 if exists("haxe_haxedoc") || main_syntax == 'jsp' |
| |
112 syntax case ignore |
| |
113 " syntax coloring for haxedoc comments (HTML) |
| |
114 " syntax include @haxeHtml <sfile>:p:h/html.vim |
| |
115 " unlet b:current_syntax |
| |
116 syn region haxeDocComment start="/\*\*" end="\*/" keepend contains=haxeCommentTitle,@haxeHtml,haxeDocTags,haxeTodo,@Spell |
| |
117 syn region haxeCommentTitle contained matchgroup=haxeDocComment start="/\*\*" matchgroup=haxeCommentTitle keepend end="\.$" end="\.[ \t\r<&]"me=e-1 end="[^{]@"me=s-2,he=s-1 end="\*/"me=s-1,he=s-1 contains=@haxeHtml,haxeCommentStar,haxeTodo,@Spell,haxeDocTags |
| |
118 |
| |
119 syn region haxeDocTags contained start="{@\(link\|linkplain\|inherit[Dd]oc\|doc[rR]oot\|value\)" end="}" |
| |
120 syn match haxeDocTags contained "@\(see\|param\|exception\|throws\|since\)\s\+\S\+" contains=haxeDocParam |
| |
121 syn match haxeDocParam contained "\s\S\+" |
| |
122 syn match haxeDocTags contained "@\(version\|author\|return\|deprecated\|serial\|serialField\|serialData\)\>" |
| |
123 syntax case match |
| |
124 endif |
| |
125 |
| |
126 " match the special comment /**/ |
| |
127 syn match haxeComment "/\*\*/" |
| |
128 |
| |
129 " Strings and constants |
| |
130 syn match haxeSpecialError contained "\\." |
| |
131 syn match haxeSpecialCharError contained "[^']" |
| |
132 syn match haxeSpecialChar contained "\\\([4-9]\d\|[0-3]\d\d\|[\"\\'ntbrf]\|u\x\{4\}\)" |
| |
133 syn match haxeEregEscape contained "\(\\\\\|\\/\)" |
| |
134 syn region haxeEreg start=+\~\/+ end=+\/[gims]*+ contains=haxeEregEscape |
| |
135 |
| |
136 syn region haxeString start=+"+ end=+"+ contains=haxeSpecialChar,haxeSpecialError,@Spell |
| |
137 syn region haxeSingleString start=+'+ end=+'+ |
| |
138 " next line disabled, it can cause a crash for a long line |
| |
139 "syn match haxeStringError +"\([^"\\]\|\\.\)*$+ |
| |
140 syn match haxeCharacter "'[^']*'" contains=haxeSpecialChar,haxeSpecialCharError |
| |
141 syn match haxeCharacter "'\\''" contains=haxeSpecialChar |
| |
142 syn match haxeCharacter "'[^\\]'" |
| |
143 syn match haxeNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>" |
| |
144 "syn match haxeNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\=" |
| |
145 syn match haxeNumber "\(\<\d\+\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\=" |
| |
146 syn match haxeNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>" |
| |
147 syn match haxeNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>" |
| |
148 |
| |
149 |
| |
150 syn region haxeCondIf start="#if \+!\?" end="\W" skip="([A-Za-z0-9_ |&!]\+)" |
| |
151 syn region haxeCondElse start="#else \+!\?" end="\W" skip="([A-Za-z0-9_ |&!]\+)" |
| |
152 syn match haxeCondEnd "#end" |
| |
153 syn match haxeCondError "#else *$" |
| |
154 |
| |
155 " unicode characters |
| |
156 syn match haxeSpecial "\\u\d\{4\}" |
| |
157 |
| |
158 syn cluster haxeTop add=haxeString,haxeCharacter,haxeNumber,haxeSpecial,haxeStringError |
| |
159 |
| |
160 if exists("haxe_highlight_functions") |
| |
161 if haxe_highlight_functions == "indent" |
| |
162 syn match haxeFuncDef "^\(\t\| \{8\}\)[_$a-zA-Z][_$a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=haxeScopeDecl,haxeType,haxeStorageClass,@haxeClasses |
| |
163 syn region haxeFuncDef start=+^\(\t\| \{8\}\)[$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=haxeScopeDecl,haxeType,haxeStorageClass,@haxeClasses |
| |
164 syn match haxeFuncDef "^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=haxeScopeDecl,haxeType,haxeStorageClass,@haxeClasses |
| |
165 syn region haxeFuncDef start=+^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=haxeScopeDecl,haxeType,haxeStorageClass,@haxeClasses |
| |
166 else |
| |
167 " This line catches method declarations at any indentation>0, but it assumes |
| |
168 " two things: |
| |
169 " 1. class names are always capitalized (ie: Button) |
| |
170 " 2. method names are never capitalized (except constructors, of course) |
| |
171 syn region haxeFuncDef start=+^\s\+\(\(public\|protected\|private\|static\|abstract\|override\|final\|native\|synchronized\)\s\+\)*\(\(void\|boolean\|char\|byte\|short\|int\|long\|float\|double\|\([A-Za-z_][A-Za-z0-9_$]*\.\)*[A-Z][A-Za-z0-9_$]*\)\(\[\]\)*\s\+[a-z][A-Za-z0-9_$]*\|[A-Z][A-Za-z0-9_$]*\)\s*(+ end=+)+ contains=haxeScopeDecl,haxeType,haxeStorageClass,haxeComment,haxeLineComment,@haxeClasses |
| |
172 endif |
| |
173 syn match haxeBraces "[{}]" |
| |
174 syn cluster haxeTop add=haxeFuncDef,haxeBraces |
| |
175 endif |
| |
176 |
| |
177 if exists("haxe_mark_braces_in_parens_as_errors") |
| |
178 syn match haxeInParen contained "[{}]" |
| |
179 HaxeHiLink haxeInParen haxeError |
| |
180 syn cluster haxeTop add=haxeInParen |
| |
181 endif |
| |
182 |
| |
183 " catch errors caused by wrong parenthesis |
| |
184 syn region haxeParenT transparent matchgroup=haxeParen start="(" end=")" contains=@haxeTop,haxeParenT1 |
| |
185 syn region haxeParenT1 transparent matchgroup=haxeParen1 start="(" end=")" contains=@haxeTop,haxeParenT2 contained |
| |
186 syn region haxeParenT2 transparent matchgroup=haxeParen2 start="(" end=")" contains=@haxeTop,haxeParenT contained |
| |
187 syn match haxeParenError ")" |
| |
188 HaxeHiLink haxeParenError haxeError |
| |
189 |
| |
190 if !exists("haxe_minlines") |
| |
191 let haxe_minlines = 10 |
| |
192 endif |
| |
193 exec "syn sync ccomment haxeComment minlines=" . haxe_minlines |
| |
194 |
| |
195 " The default highlighting. |
| |
196 if version >= 508 || !exists("did_haxe_syn_inits") |
| |
197 if version < 508 |
| |
198 let did_haxe_syn_inits = 1 |
| |
199 endif |
| |
200 HaxeHiLink haxeFuncDef Function |
| |
201 HaxeHiLink haxeBraces Function |
| |
202 HaxeHiLink haxeBranch Conditional |
| |
203 HaxeHiLink haxeUserLabelRef haxeUserLabel |
| |
204 HaxeHiLink haxeLabel Label |
| |
205 HaxeHiLink haxeUserLabel Label |
| |
206 HaxeHiLink haxeConditional Conditional |
| |
207 HaxeHiLink haxeRepeat Repeat |
| |
208 HaxeHiLink haxeExceptions Exception |
| |
209 HaxeHiLink haxeAssert Statement |
| |
210 HaxeHiLink haxeStatic MoreMsg |
| |
211 HaxeHiLink haxeStorageClass StorageClass |
| |
212 HaxeHiLink haxeMethodDecl haxeStorageClass |
| |
213 HaxeHiLink haxeClassDecl haxeStorageClass |
| |
214 HaxeHiLink haxeScopeDecl haxeStorageClass |
| |
215 HaxeHiLink haxeBoolean Boolean |
| |
216 HaxeHiLink haxeSpecial Special |
| |
217 HaxeHiLink haxeSpecialError Error |
| |
218 HaxeHiLink haxeSpecialCharError Error |
| |
219 HaxeHiLink haxeString String |
| |
220 HaxeHiLink haxeSingleString String |
| |
221 HaxeHiLink haxeEreg Special |
| |
222 HaxeHiLink haxeEregEscape Special |
| |
223 HaxeHiLink haxeCharacter Character |
| |
224 HaxeHiLink haxeSpecialChar SpecialChar |
| |
225 HaxeHiLink haxeNumber Number |
| |
226 HaxeHiLink haxeError Error |
| |
227 HaxeHiLink haxeStringError Error |
| |
228 HaxeHiLink haxeStatement Statement |
| |
229 HaxeHiLink haxeOperator Operator |
| |
230 HaxeHiLink haxeComment Comment |
| |
231 HaxeHiLink haxeDocComment Comment |
| |
232 HaxeHiLink haxeLineComment Comment |
| |
233 HaxeHiLink haxeConstant Constant |
| |
234 HaxeHiLink haxeTypedef Typedef |
| |
235 HaxeHiLink haxeTodo Todo |
| |
236 |
| |
237 HaxeHiLink haxeCommentTitle SpecialComment |
| |
238 HaxeHiLink haxeDocTags Special |
| |
239 HaxeHiLink haxeDocParam Function |
| |
240 HaxeHiLink haxeCommentStar haxeComment |
| |
241 |
| |
242 HaxeHiLink haxeType Type |
| |
243 HaxeHiLink haxeExternal Include |
| |
244 |
| |
245 HaxeHiLink htmlComment Special |
| |
246 HaxeHiLink htmlCommentPart Special |
| |
247 HaxeHiLink haxeSpaceError Error |
| |
248 |
| |
249 HaxeHiLink haxeCondIf Macro |
| |
250 HaxeHiLink haxeCondElse Macro |
| |
251 HaxeHiLink haxeCondEnd Macro |
| |
252 HaxeHiLink haxeCondError Error |
| |
253 endif |
| |
254 |
| |
255 delcommand HaxeHiLink |
| |
256 |
| |
257 let b:current_syntax = "haxe" |
| |
258 |
| |
259 if main_syntax == 'haxe' |
| |
260 unlet main_syntax |
| |
261 endif |
| |
262 |
| |
263 let b:spell_options="contained" |
| |
264 |
| |
265 " vim: ts=8 |