michael@112: " Vim syntax file michael@112: " Language: haxe michael@112: michael@112: " Please check :help haxe.vim for comments on some of the options available. michael@112: michael@112: "set errorformat=%f\:%l\:\ characters\ %c-%*[^\ ]\ %m,%f\:%l\:\ %m michael@112: set errorformat=%f\:%l\:\ characters\ %c-%*[^\ ]\ %m,%f\:%l\:\ %m michael@112: michael@112: " Quit when a syntax file was already loaded michael@112: if !exists("main_syntax") michael@112: if version < 600 michael@112: syntax clear michael@112: elseif exists("b:current_syntax") michael@112: finish michael@112: endif michael@112: " we define it here so that included files can test for it michael@112: let main_syntax='haxe' michael@112: endif michael@112: michael@112: " don't use standard HiLink, it will not work with included syntax files michael@112: if version < 508 michael@112: command! -nargs=+ HaxeHiLink hi link michael@112: else michael@112: command! -nargs=+ HaxeHiLink hi def link michael@112: endif michael@112: michael@112: " some characters that cannot be in a haxe program (outside a string) michael@112: syn match haxeError "[\\@`]" michael@112: syn match haxeError "<<<\|=>\|<>\|||=\|&&=\|\*\/" michael@112: michael@112: " use separate name so that it can be deleted in haxecc.vim michael@112: syn match haxeError2 "#\|=<" michael@112: HaxeHiLink haxeError2 haxeError michael@112: michael@112: michael@112: " keyword definitions michael@112: syn keyword haxeExternal import extern package michael@112: syn keyword haxeConditional if else switch michael@112: syn keyword haxeRepeat while for do in michael@112: syn keyword haxeBoolean true false michael@112: syn keyword haxeConstant null michael@112: syn keyword haxeTypedef this super michael@112: syn keyword haxeOperator new cast michael@112: syn keyword haxeType Void Bool Int Float Dynamic michael@112: syn keyword haxeStatement return michael@112: syn keyword haxeStorageClass function var final typedef enum michael@112: " syn keyword haxeStatic michael@112: syn keyword haxeExceptions throw try catch finally untyped michael@112: syn keyword haxeAssert assert michael@112: syn keyword haxeMethodDecl synchronized throws michael@112: syn keyword haxeClassDecl extends implements interface michael@112: syn match haxeOperator "\.\.\." michael@112: " to differentiate the keyword class from MyClass.class we use a match here michael@112: syn match haxeTypedef "\.\s*\"ms=s+1 michael@112: syn match haxeClassDecl "^class\>" michael@112: syn match haxeClassDecl "[^.]\s*\"ms=s+1 michael@112: syn keyword haxeBranch break continue nextgroup=haxeUserLabelRef skipwhite michael@112: syn match haxeUserLabelRef "\k\+" contained michael@112: syn keyword haxeScopeDecl static public protected private abstract override michael@112: michael@112: " haxe.lang.* michael@112: syn match haxeLangClass "\" michael@112: 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: HaxeHiLink haxeLangClass haxeConstant michael@112: HaxeHiLink haxeLangObject haxeConstant michael@112: syn cluster haxeTop add=haxeLangObject,haxeLangClass michael@112: syn cluster haxeClasses add=haxeLangClass michael@112: michael@112: if filereadable(expand(":p:h")."/haxeid.vim") michael@112: source :p:h/haxeid.vim michael@112: endif michael@112: michael@112: if exists("haxe_space_errors") michael@112: if !exists("haxe_no_trail_space_error") michael@112: syn match haxeSpaceError "\s\+$" michael@112: endif michael@112: if !exists("haxe_no_tab_space_error") michael@112: syn match haxeSpaceError " \+\t"me=e-1 michael@112: endif michael@112: endif michael@112: michael@112: syn region haxeLabelRegion transparent matchgroup=haxeLabel start="\" matchgroup=NONE end=":" contains=haxeNumber,haxeCharacter michael@112: syn match haxeUserLabel "^\s*[_$a-zA-Z][_$a-zA-Z0-9_]*\s*:"he=e-1 contains=haxeLabel michael@112: syn keyword haxeLabel default michael@112: michael@112: " The following cluster contains all haxe groups except the contained ones michael@112: 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: michael@112: michael@112: " Comments michael@112: syn keyword haxeTodo contained TODO FIXME XXX michael@112: if exists("haxe_comment_strings") michael@112: syn region haxeCommentString contained start=+"+ end=+"+ end=+$+ end=+\*/+me=s-1,he=s-1 contains=haxeSpecial,haxeCommentStar,haxeSpecialChar,@Spell michael@112: syn region haxeComment2String contained start=+"+ end=+$\|"+ contains=haxeSpecial,haxeSpecialChar,@Spell michael@112: syn match haxeCommentCharacter contained "'\\[^']\{1,6\}'" contains=haxeSpecialChar michael@112: syn match haxeCommentCharacter contained "'\\''" contains=haxeSpecialChar michael@112: syn match haxeCommentCharacter contained "'[^\\]'" michael@112: syn cluster haxeCommentSpecial add=haxeCommentString,haxeCommentCharacter,haxeNumber michael@112: syn cluster haxeCommentSpecial2 add=haxeComment2String,haxeCommentCharacter,haxeNumber michael@112: endif michael@112: syn region haxeComment start="/\*" end="\*/" contains=@haxeCommentSpecial,haxeTodo,@Spell michael@112: syn match haxeCommentStar contained "^\s*\*[^/]"me=e-1 michael@112: syn match haxeCommentStar contained "^\s*\*$" michael@112: syn match haxeLineComment "//.*" contains=@haxeCommentSpecial2,haxeTodo,@Spell michael@112: HaxeHiLink haxeCommentString haxeString michael@112: HaxeHiLink haxeComment2String haxeString michael@112: HaxeHiLink haxeCommentCharacter haxeCharacter michael@112: michael@112: syn cluster haxeTop add=haxeComment,haxeLineComment michael@112: michael@112: if exists("haxe_haxedoc") || main_syntax == 'jsp' michael@112: syntax case ignore michael@112: " syntax coloring for haxedoc comments (HTML) michael@112: " syntax include @haxeHtml :p:h/html.vim michael@112: " unlet b:current_syntax michael@112: syn region haxeDocComment start="/\*\*" end="\*/" keepend contains=haxeCommentTitle,@haxeHtml,haxeDocTags,haxeTodo,@Spell michael@112: 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: michael@112: syn region haxeDocTags contained start="{@\(link\|linkplain\|inherit[Dd]oc\|doc[rR]oot\|value\)" end="}" michael@112: syn match haxeDocTags contained "@\(see\|param\|exception\|throws\|since\)\s\+\S\+" contains=haxeDocParam michael@112: syn match haxeDocParam contained "\s\S\+" michael@112: syn match haxeDocTags contained "@\(version\|author\|return\|deprecated\|serial\|serialField\|serialData\)\>" michael@112: syntax case match michael@112: endif michael@112: michael@112: " match the special comment /**/ michael@112: syn match haxeComment "/\*\*/" michael@112: michael@112: " Strings and constants michael@112: syn match haxeSpecialError contained "\\." michael@112: syn match haxeSpecialCharError contained "[^']" michael@112: syn match haxeSpecialChar contained "\\\([4-9]\d\|[0-3]\d\d\|[\"\\'ntbrf]\|u\x\{4\}\)" michael@112: syn match haxeEregEscape contained "\(\\\\\|\\/\)" michael@112: syn region haxeEreg start=+\~\/+ end=+\/[gims]*+ contains=haxeEregEscape michael@112: michael@112: syn region haxeString start=+"+ end=+"+ contains=haxeSpecialChar,haxeSpecialError,@Spell michael@112: syn region haxeSingleString start=+'+ end=+'+ michael@112: " next line disabled, it can cause a crash for a long line michael@112: "syn match haxeStringError +"\([^"\\]\|\\.\)*$+ michael@112: syn match haxeCharacter "'[^']*'" contains=haxeSpecialChar,haxeSpecialCharError michael@112: syn match haxeCharacter "'\\''" contains=haxeSpecialChar michael@112: syn match haxeCharacter "'[^\\]'" michael@112: syn match haxeNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>" michael@112: "syn match haxeNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\=" michael@112: syn match haxeNumber "\(\<\d\+\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\=" michael@112: syn match haxeNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>" michael@112: syn match haxeNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>" michael@112: michael@112: michael@112: syn region haxeCondIf start="#if \+!\?" end="\W" skip="([A-Za-z0-9_ |&!]\+)" michael@112: syn region haxeCondElse start="#else \+!\?" end="\W" skip="([A-Za-z0-9_ |&!]\+)" michael@112: syn match haxeCondEnd "#end" michael@112: syn match haxeCondError "#else *$" michael@112: michael@112: " unicode characters michael@112: syn match haxeSpecial "\\u\d\{4\}" michael@112: michael@112: syn cluster haxeTop add=haxeString,haxeCharacter,haxeNumber,haxeSpecial,haxeStringError michael@112: michael@112: if exists("haxe_highlight_functions") michael@112: if haxe_highlight_functions == "indent" michael@112: syn match haxeFuncDef "^\(\t\| \{8\}\)[_$a-zA-Z][_$a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=haxeScopeDecl,haxeType,haxeStorageClass,@haxeClasses michael@112: syn region haxeFuncDef start=+^\(\t\| \{8\}\)[$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=haxeScopeDecl,haxeType,haxeStorageClass,@haxeClasses michael@112: syn match haxeFuncDef "^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=haxeScopeDecl,haxeType,haxeStorageClass,@haxeClasses michael@112: syn region haxeFuncDef start=+^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=haxeScopeDecl,haxeType,haxeStorageClass,@haxeClasses michael@112: else michael@112: " This line catches method declarations at any indentation>0, but it assumes michael@112: " two things: michael@112: " 1. class names are always capitalized (ie: Button) michael@112: " 2. method names are never capitalized (except constructors, of course) michael@112: 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: endif michael@112: syn match haxeBraces "[{}]" michael@112: syn cluster haxeTop add=haxeFuncDef,haxeBraces michael@112: endif michael@112: michael@112: if exists("haxe_mark_braces_in_parens_as_errors") michael@112: syn match haxeInParen contained "[{}]" michael@112: HaxeHiLink haxeInParen haxeError michael@112: syn cluster haxeTop add=haxeInParen michael@112: endif michael@112: michael@112: " catch errors caused by wrong parenthesis michael@112: syn region haxeParenT transparent matchgroup=haxeParen start="(" end=")" contains=@haxeTop,haxeParenT1 michael@112: syn region haxeParenT1 transparent matchgroup=haxeParen1 start="(" end=")" contains=@haxeTop,haxeParenT2 contained michael@112: syn region haxeParenT2 transparent matchgroup=haxeParen2 start="(" end=")" contains=@haxeTop,haxeParenT contained michael@112: syn match haxeParenError ")" michael@112: HaxeHiLink haxeParenError haxeError michael@112: michael@112: if !exists("haxe_minlines") michael@112: let haxe_minlines = 10 michael@112: endif michael@112: exec "syn sync ccomment haxeComment minlines=" . haxe_minlines michael@112: michael@112: " The default highlighting. michael@112: if version >= 508 || !exists("did_haxe_syn_inits") michael@112: if version < 508 michael@112: let did_haxe_syn_inits = 1 michael@112: endif michael@112: HaxeHiLink haxeFuncDef Function michael@112: HaxeHiLink haxeBraces Function michael@112: HaxeHiLink haxeBranch Conditional michael@112: HaxeHiLink haxeUserLabelRef haxeUserLabel michael@112: HaxeHiLink haxeLabel Label michael@112: HaxeHiLink haxeUserLabel Label michael@112: HaxeHiLink haxeConditional Conditional michael@112: HaxeHiLink haxeRepeat Repeat michael@112: HaxeHiLink haxeExceptions Exception michael@112: HaxeHiLink haxeAssert Statement michael@112: HaxeHiLink haxeStatic MoreMsg michael@112: HaxeHiLink haxeStorageClass StorageClass michael@112: HaxeHiLink haxeMethodDecl haxeStorageClass michael@112: HaxeHiLink haxeClassDecl haxeStorageClass michael@112: HaxeHiLink haxeScopeDecl haxeStorageClass michael@112: HaxeHiLink haxeBoolean Boolean michael@112: HaxeHiLink haxeSpecial Special michael@112: HaxeHiLink haxeSpecialError Error michael@112: HaxeHiLink haxeSpecialCharError Error michael@112: HaxeHiLink haxeString String michael@112: HaxeHiLink haxeSingleString String michael@112: HaxeHiLink haxeEreg Special michael@112: HaxeHiLink haxeEregEscape Special michael@112: HaxeHiLink haxeCharacter Character michael@112: HaxeHiLink haxeSpecialChar SpecialChar michael@112: HaxeHiLink haxeNumber Number michael@112: HaxeHiLink haxeError Error michael@112: HaxeHiLink haxeStringError Error michael@112: HaxeHiLink haxeStatement Statement michael@112: HaxeHiLink haxeOperator Operator michael@112: HaxeHiLink haxeComment Comment michael@112: HaxeHiLink haxeDocComment Comment michael@112: HaxeHiLink haxeLineComment Comment michael@112: HaxeHiLink haxeConstant Constant michael@112: HaxeHiLink haxeTypedef Typedef michael@112: HaxeHiLink haxeTodo Todo michael@112: michael@112: HaxeHiLink haxeCommentTitle SpecialComment michael@112: HaxeHiLink haxeDocTags Special michael@112: HaxeHiLink haxeDocParam Function michael@112: HaxeHiLink haxeCommentStar haxeComment michael@112: michael@112: HaxeHiLink haxeType Type michael@112: HaxeHiLink haxeExternal Include michael@112: michael@112: HaxeHiLink htmlComment Special michael@112: HaxeHiLink htmlCommentPart Special michael@112: HaxeHiLink haxeSpaceError Error michael@112: michael@112: HaxeHiLink haxeCondIf Macro michael@112: HaxeHiLink haxeCondElse Macro michael@112: HaxeHiLink haxeCondEnd Macro michael@112: HaxeHiLink haxeCondError Error michael@112: endif michael@112: michael@112: delcommand HaxeHiLink michael@112: michael@112: let b:current_syntax = "haxe" michael@112: michael@112: if main_syntax == 'haxe' michael@112: unlet main_syntax michael@112: endif michael@112: michael@112: let b:spell_options="contained" michael@112: michael@112: " vim: ts=8