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