haxe/haxe.vim

changeset 112
6052d0605a74
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/haxe/haxe.vim	Wed Feb 25 13:55:52 2009 +0100
     1.3 @@ -0,0 +1,265 @@
     1.4 +" Vim syntax file
     1.5 +" Language:     haxe
     1.6 +
     1.7 +" Please check :help haxe.vim for comments on some of the options available.
     1.8 +
     1.9 +"set errorformat=%f\:%l\:\ characters\ %c-%*[^\ ]\ %m,%f\:%l\:\ %m
    1.10 +set errorformat=%f\:%l\:\ characters\ %c-%*[^\ ]\ %m,%f\:%l\:\ %m
    1.11 +
    1.12 +" Quit when a syntax file was already loaded
    1.13 +if !exists("main_syntax")
    1.14 +  if version < 600
    1.15 +    syntax clear
    1.16 +  elseif exists("b:current_syntax")
    1.17 +    finish
    1.18 +  endif
    1.19 +  " we define it here so that included files can test for it
    1.20 +  let main_syntax='haxe'
    1.21 +endif
    1.22 +
    1.23 +" don't use standard HiLink, it will not work with included syntax files
    1.24 +if version < 508
    1.25 +  command! -nargs=+ HaxeHiLink hi link <args>
    1.26 +else
    1.27 +  command! -nargs=+ HaxeHiLink hi def link <args>
    1.28 +endif
    1.29 +
    1.30 +" some characters that cannot be in a haxe program (outside a string)
    1.31 +syn match haxeError "[\\@`]"
    1.32 +syn match haxeError "<<<\|=>\|<>\|||=\|&&=\|\*\/"
    1.33 +
    1.34 +" use separate name so that it can be deleted in haxecc.vim
    1.35 +syn match   haxeError2 "#\|=<"
    1.36 +HaxeHiLink haxeError2 haxeError
    1.37 +
    1.38 +
    1.39 +" keyword definitions
    1.40 +syn keyword haxeExternal	import extern package
    1.41 +syn keyword haxeConditional	if else switch
    1.42 +syn keyword haxeRepeat		while for do in
    1.43 +syn keyword haxeBoolean		true false
    1.44 +syn keyword haxeConstant	null
    1.45 +syn keyword haxeTypedef		this super
    1.46 +syn keyword haxeOperator	new cast 
    1.47 +syn keyword haxeType		Void Bool Int Float Dynamic
    1.48 +syn keyword haxeStatement	return
    1.49 +syn keyword haxeStorageClass    function var final typedef enum
    1.50 +" syn keyword haxeStatic		
    1.51 +syn keyword haxeExceptions      throw try catch finally untyped
    1.52 +syn keyword haxeAssert		assert
    1.53 +syn keyword haxeMethodDecl      synchronized throws
    1.54 +syn keyword haxeClassDecl       extends implements interface
    1.55 +syn match   haxeOperator "\.\.\."
    1.56 +" to differentiate the keyword class from MyClass.class we use a match here
    1.57 +syn match   haxeTypedef		"\.\s*\<class\>"ms=s+1
    1.58 +syn match   haxeClassDecl       "^class\>"
    1.59 +syn match   haxeClassDecl       "[^.]\s*\<class\>"ms=s+1
    1.60 +syn keyword haxeBranch		break continue nextgroup=haxeUserLabelRef skipwhite
    1.61 +syn match   haxeUserLabelRef    "\k\+" contained
    1.62 +syn keyword haxeScopeDecl       static public protected private abstract override 
    1.63 +
    1.64 +" haxe.lang.*
    1.65 +syn match haxeLangClass "\<System\>"
    1.66 +syn keyword haxeLangClass  Array BasicType Class Date DateTools EReg Hash IntHash IntIter Iterator Lambda List Math Md5 Reflect Std String StringBuf StringTools Xml XmlType
    1.67 +HaxeHiLink haxeLangClass		     haxeConstant
    1.68 +HaxeHiLink haxeLangObject		     haxeConstant
    1.69 +syn cluster haxeTop add=haxeLangObject,haxeLangClass
    1.70 +syn cluster haxeClasses add=haxeLangClass
    1.71 +
    1.72 +if filereadable(expand("<sfile>:p:h")."/haxeid.vim")
    1.73 +  source <sfile>:p:h/haxeid.vim
    1.74 +endif
    1.75 +
    1.76 +if exists("haxe_space_errors")
    1.77 +  if !exists("haxe_no_trail_space_error")
    1.78 +    syn match   haxeSpaceError  "\s\+$"
    1.79 +  endif
    1.80 +  if !exists("haxe_no_tab_space_error")
    1.81 +    syn match   haxeSpaceError  " \+\t"me=e-1
    1.82 +  endif
    1.83 +endif
    1.84 +
    1.85 +syn region  haxeLabelRegion     transparent matchgroup=haxeLabel start="\<case\>" matchgroup=NONE end=":" contains=haxeNumber,haxeCharacter
    1.86 +syn match   haxeUserLabel       "^\s*[_$a-zA-Z][_$a-zA-Z0-9_]*\s*:"he=e-1 contains=haxeLabel
    1.87 +syn keyword haxeLabel		default
    1.88 +
    1.89 +" The following cluster contains all haxe groups except the contained ones
    1.90 +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
    1.91 +
    1.92 +
    1.93 +" Comments
    1.94 +syn keyword haxeTodo		 contained TODO FIXME XXX
    1.95 +if exists("haxe_comment_strings")
    1.96 +  syn region  haxeCommentString    contained start=+"+ end=+"+ end=+$+ end=+\*/+me=s-1,he=s-1 contains=haxeSpecial,haxeCommentStar,haxeSpecialChar,@Spell
    1.97 +  syn region  haxeComment2String   contained start=+"+  end=+$\|"+  contains=haxeSpecial,haxeSpecialChar,@Spell
    1.98 +  syn match   haxeCommentCharacter contained "'\\[^']\{1,6\}'" contains=haxeSpecialChar
    1.99 +  syn match   haxeCommentCharacter contained "'\\''" contains=haxeSpecialChar
   1.100 +  syn match   haxeCommentCharacter contained "'[^\\]'"
   1.101 +  syn cluster haxeCommentSpecial add=haxeCommentString,haxeCommentCharacter,haxeNumber
   1.102 +  syn cluster haxeCommentSpecial2 add=haxeComment2String,haxeCommentCharacter,haxeNumber
   1.103 +endif
   1.104 +syn region  haxeComment		 start="/\*"  end="\*/" contains=@haxeCommentSpecial,haxeTodo,@Spell
   1.105 +syn match   haxeCommentStar      contained "^\s*\*[^/]"me=e-1
   1.106 +syn match   haxeCommentStar      contained "^\s*\*$"
   1.107 +syn match   haxeLineComment      "//.*" contains=@haxeCommentSpecial2,haxeTodo,@Spell
   1.108 +HaxeHiLink haxeCommentString haxeString
   1.109 +HaxeHiLink haxeComment2String haxeString
   1.110 +HaxeHiLink haxeCommentCharacter haxeCharacter
   1.111 +
   1.112 +syn cluster haxeTop add=haxeComment,haxeLineComment
   1.113 +
   1.114 +if exists("haxe_haxedoc") || main_syntax == 'jsp'
   1.115 +  syntax case ignore
   1.116 +  " syntax coloring for haxedoc comments (HTML)
   1.117 +  " syntax include @haxeHtml <sfile>:p:h/html.vim
   1.118 +  " unlet b:current_syntax
   1.119 +  syn region  haxeDocComment    start="/\*\*"  end="\*/" keepend contains=haxeCommentTitle,@haxeHtml,haxeDocTags,haxeTodo,@Spell
   1.120 +  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
   1.121 +
   1.122 +  syn region haxeDocTags  contained start="{@\(link\|linkplain\|inherit[Dd]oc\|doc[rR]oot\|value\)" end="}"
   1.123 +  syn match  haxeDocTags  contained "@\(see\|param\|exception\|throws\|since\)\s\+\S\+" contains=haxeDocParam
   1.124 +  syn match  haxeDocParam contained "\s\S\+"
   1.125 +  syn match  haxeDocTags  contained "@\(version\|author\|return\|deprecated\|serial\|serialField\|serialData\)\>"
   1.126 +  syntax case match
   1.127 +endif
   1.128 +
   1.129 +" match the special comment /**/
   1.130 +syn match   haxeComment		 "/\*\*/"
   1.131 +
   1.132 +" Strings and constants
   1.133 +syn match   haxeSpecialError     contained "\\."
   1.134 +syn match   haxeSpecialCharError contained "[^']"
   1.135 +syn match   haxeSpecialChar      contained "\\\([4-9]\d\|[0-3]\d\d\|[\"\\'ntbrf]\|u\x\{4\}\)"
   1.136 +syn match haxeEregEscape	contained "\(\\\\\|\\/\)"
   1.137 +syn region  haxeEreg		start=+\~\/+ end=+\/[gims]*+ contains=haxeEregEscape
   1.138 +
   1.139 +syn region  haxeString		start=+"+ end=+"+ contains=haxeSpecialChar,haxeSpecialError,@Spell
   1.140 +syn region  haxeSingleString  start=+'+ end=+'+ 
   1.141 +" next line disabled, it can cause a crash for a long line
   1.142 +"syn match   haxeStringError	  +"\([^"\\]\|\\.\)*$+
   1.143 +syn match   haxeCharacter	 "'[^']*'" contains=haxeSpecialChar,haxeSpecialCharError
   1.144 +syn match   haxeCharacter	 "'\\''" contains=haxeSpecialChar
   1.145 +syn match   haxeCharacter	 "'[^\\]'"
   1.146 +syn match   haxeNumber		 "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
   1.147 +"syn match   haxeNumber		 "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
   1.148 +syn match   haxeNumber		 "\(\<\d\+\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
   1.149 +syn match   haxeNumber		 "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
   1.150 +syn match   haxeNumber		 "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
   1.151 +
   1.152 +
   1.153 +syn region haxeCondIf start="#if \+!\?" end="\W" skip="([A-Za-z0-9_ |&!]\+)"
   1.154 +syn region haxeCondElse start="#else \+!\?" end="\W" skip="([A-Za-z0-9_ |&!]\+)"
   1.155 +syn match haxeCondEnd "#end"
   1.156 +syn match haxeCondError "#else *$"
   1.157 +
   1.158 +" unicode characters
   1.159 +syn match   haxeSpecial "\\u\d\{4\}"
   1.160 +
   1.161 +syn cluster haxeTop add=haxeString,haxeCharacter,haxeNumber,haxeSpecial,haxeStringError
   1.162 +
   1.163 +if exists("haxe_highlight_functions")
   1.164 +  if haxe_highlight_functions == "indent"
   1.165 +    syn match  haxeFuncDef "^\(\t\| \{8\}\)[_$a-zA-Z][_$a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=haxeScopeDecl,haxeType,haxeStorageClass,@haxeClasses
   1.166 +    syn region haxeFuncDef start=+^\(\t\| \{8\}\)[$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=haxeScopeDecl,haxeType,haxeStorageClass,@haxeClasses
   1.167 +    syn match  haxeFuncDef "^  [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=haxeScopeDecl,haxeType,haxeStorageClass,@haxeClasses
   1.168 +    syn region haxeFuncDef start=+^  [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=haxeScopeDecl,haxeType,haxeStorageClass,@haxeClasses
   1.169 +  else
   1.170 +    " This line catches method declarations at any indentation>0, but it assumes
   1.171 +    " two things:
   1.172 +    "   1. class names are always capitalized (ie: Button)
   1.173 +    "   2. method names are never capitalized (except constructors, of course)
   1.174 +    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
   1.175 +  endif
   1.176 +  syn match  haxeBraces  "[{}]"
   1.177 +  syn cluster haxeTop add=haxeFuncDef,haxeBraces
   1.178 +endif
   1.179 +
   1.180 +if exists("haxe_mark_braces_in_parens_as_errors")
   1.181 +  syn match haxeInParen		 contained "[{}]"
   1.182 +  HaxeHiLink haxeInParen	haxeError
   1.183 +  syn cluster haxeTop add=haxeInParen
   1.184 +endif
   1.185 +
   1.186 +" catch errors caused by wrong parenthesis
   1.187 +syn region  haxeParenT  transparent matchgroup=haxeParen  start="("  end=")" contains=@haxeTop,haxeParenT1
   1.188 +syn region  haxeParenT1 transparent matchgroup=haxeParen1 start="(" end=")" contains=@haxeTop,haxeParenT2 contained
   1.189 +syn region  haxeParenT2 transparent matchgroup=haxeParen2 start="(" end=")" contains=@haxeTop,haxeParenT  contained
   1.190 +syn match   haxeParenError       ")"
   1.191 +HaxeHiLink haxeParenError       haxeError
   1.192 +
   1.193 +if !exists("haxe_minlines")
   1.194 +  let haxe_minlines = 10
   1.195 +endif
   1.196 +exec "syn sync ccomment haxeComment minlines=" . haxe_minlines
   1.197 +
   1.198 +" The default highlighting.
   1.199 +if version >= 508 || !exists("did_haxe_syn_inits")
   1.200 +  if version < 508
   1.201 +    let did_haxe_syn_inits = 1
   1.202 +  endif
   1.203 +  HaxeHiLink haxeFuncDef		Function
   1.204 +  HaxeHiLink haxeBraces		Function
   1.205 +  HaxeHiLink haxeBranch		Conditional
   1.206 +  HaxeHiLink haxeUserLabelRef	haxeUserLabel
   1.207 +  HaxeHiLink haxeLabel		Label
   1.208 +  HaxeHiLink haxeUserLabel		Label
   1.209 +  HaxeHiLink haxeConditional	Conditional
   1.210 +  HaxeHiLink haxeRepeat		Repeat
   1.211 +  HaxeHiLink haxeExceptions		Exception
   1.212 +  HaxeHiLink haxeAssert		Statement
   1.213 +  HaxeHiLink haxeStatic MoreMsg
   1.214 +  HaxeHiLink haxeStorageClass	StorageClass
   1.215 +  HaxeHiLink haxeMethodDecl		haxeStorageClass
   1.216 +  HaxeHiLink haxeClassDecl		haxeStorageClass
   1.217 +  HaxeHiLink haxeScopeDecl		haxeStorageClass
   1.218 +  HaxeHiLink haxeBoolean		Boolean
   1.219 +  HaxeHiLink haxeSpecial		Special
   1.220 +  HaxeHiLink haxeSpecialError	Error
   1.221 +  HaxeHiLink haxeSpecialCharError	Error
   1.222 +  HaxeHiLink haxeString		String
   1.223 +  HaxeHiLink haxeSingleString	String
   1.224 +  HaxeHiLink haxeEreg Special
   1.225 +  HaxeHiLink haxeEregEscape Special
   1.226 +  HaxeHiLink haxeCharacter		Character
   1.227 +  HaxeHiLink haxeSpecialChar	SpecialChar
   1.228 +  HaxeHiLink haxeNumber		Number
   1.229 +  HaxeHiLink haxeError		Error
   1.230 +  HaxeHiLink haxeStringError	Error
   1.231 +  HaxeHiLink haxeStatement		Statement
   1.232 +  HaxeHiLink haxeOperator		Operator
   1.233 +  HaxeHiLink haxeComment		Comment
   1.234 +  HaxeHiLink haxeDocComment		Comment
   1.235 +  HaxeHiLink haxeLineComment	Comment
   1.236 +  HaxeHiLink haxeConstant		Constant
   1.237 +  HaxeHiLink haxeTypedef		Typedef
   1.238 +  HaxeHiLink haxeTodo		Todo
   1.239 +
   1.240 +  HaxeHiLink haxeCommentTitle	SpecialComment
   1.241 +  HaxeHiLink haxeDocTags		Special
   1.242 +  HaxeHiLink haxeDocParam		Function
   1.243 +  HaxeHiLink haxeCommentStar	haxeComment
   1.244 +
   1.245 +  HaxeHiLink haxeType		Type
   1.246 +  HaxeHiLink haxeExternal		Include
   1.247 +
   1.248 +  HaxeHiLink htmlComment		Special
   1.249 +  HaxeHiLink htmlCommentPart	Special
   1.250 +  HaxeHiLink haxeSpaceError		Error
   1.251 +
   1.252 +  HaxeHiLink haxeCondIf Macro
   1.253 +  HaxeHiLink haxeCondElse Macro
   1.254 +  HaxeHiLink haxeCondEnd Macro
   1.255 +  HaxeHiLink haxeCondError Error
   1.256 +endif
   1.257 +
   1.258 +delcommand HaxeHiLink
   1.259 +
   1.260 +let b:current_syntax = "haxe"
   1.261 +
   1.262 +if main_syntax == 'haxe'
   1.263 +  unlet main_syntax
   1.264 +endif
   1.265 +
   1.266 +let b:spell_options="contained"
   1.267 +
   1.268 +" vim: ts=8

mercurial