Attachment 'vala.vim'

Download

   1 " Vim syntax file
   2 " Language:	Vala
   3 " Maintainers:	Emmanuele Bassi <ebassi@gnome.org>
   4 " 		Hans Vercammen <hveso3@gmail.com>
   5 " 		pancake <pancake@nopcode.org>
   6 " 		Sebastian Reichel <sre@ring0.de>
   7 " Last Change: 	2012-02-19
   8 " Filenames: 	*.vala *.vapi
   9 "
  10 " REFERENCES:
  11 " [1] http://live.gnome.org/Vala
  12 "
  13 " TODO: Possibly when reaching vala 1.0 release
  14 " 	- validate code attributes
  15 " 	- better error checking for known errors
  16 " 	- full support for valadoc
  17 "
  18 " 	add vala in /usr/share/vim/vim73/scripts.vim below ruby
  19 " 	to have shebang support
  20 
  21 if exists("b:current_syntax")
  22   finish
  23 endif
  24 
  25 let s:vala_cpo_save = &cpo
  26 set cpo&vim
  27 
  28 " Types
  29 syn keyword valaType			bool char double float size_t ssize_t string unichar void
  30 syn keyword valaType 			int int8 int16 int32 int64 long short
  31 syn keyword valaType 			uint uint8 uint16 uint32 uint64 ulong ushort
  32 " Storage keywords
  33 syn keyword valaStorage			class delegate enum errordomain interface namespace struct
  34 " repeat / condition / label
  35 syn keyword valaRepeat			break continue do for foreach return while
  36 syn keyword valaConditional		else if switch assert
  37 " User Labels
  38 syn keyword valaLabel			case default
  39 
  40 " Modifiers
  41 syn keyword valaModifier		abstract const dynamic ensures extern inline internal override 
  42 syn keyword valaModifier 		private protected public requires signal static virtual volatile weak
  43 syn keyword valaModifier 		async owned unowned
  44 " Constants
  45 syn keyword valaConstant		false null true
  46 " Exceptions
  47 syn keyword valaException		try catch finally throw
  48 " Unspecified Statements
  49 syn keyword valaUnspecifiedStatement	as base construct delete get in is lock new out params ref sizeof set this throws typeof using value var yield
  50 
  51 " Comments
  52 syn cluster valaCommentGroup 		contains=valaTodo
  53 syn keyword valaTodo 			contained TODO FIXME XXX NOTE
  54 
  55 " valadoc Comments (ported from javadoc comments in java.vim)
  56 " TODO: need to verify valadoc syntax
  57 if !exists("vala_ignore_valadoc")
  58   syn cluster valaDocCommentGroup	contains=valaDocTags,valaDocSeeTag
  59   syn region  valaDocTags 		contained start="{@\(link\|linkplain\|inherit[Dd]oc\|doc[rR]oot\|value\)" end="}"
  60   syn match   valaDocTags 		contained "@\(param\|exception\|throws\|since\)\s\+\S\+" contains=valaDocParam
  61   syn match   valaDocParam 		contained "\s\S\+"
  62   syn match   valaDocTags 		contained "@\(author\|brief\|version\|return\|deprecated\)\>"
  63   syn region  valaDocSeeTag		contained matchgroup=valaDocTags start="@see\s\+" matchgroup=NONE end="\_."re=e-1 contains=valaDocSeeTagParam
  64   syn match   valaDocSeeTagParam	contained @"\_[^"]\+"\|<a\s\+\_.\{-}</a>\|\(\k\|\.\)*\(#\k\+\((\_[^)]\+)\)\=\)\=@ extend
  65 endif
  66 
  67 " Comment Strings (ported from c.vim)
  68 if exists("vala_comment_strings")
  69   syn match  	valaCommentSkip		contained "^\s*\*\($\|\s\+\)"
  70   syn region 	valaCommentString	contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=valaSpecialChar,valaCommentSkip
  71   syn region 	valaComment2String	contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=valaSpecialChar
  72   syn cluster 	valaCommentStringGroup 	contains=valaCommentString,valaCharacter,valaNumber
  73 
  74   syn region 	valaCommentL		start="//" end="$" keepend contains=@valaCommentGroup,valaComment2String,valaCharacter,valaNumber,valaSpaceError,@Spell
  75   syn region 	valaComment		matchgroup=valaCommentStart start="/\*" end="\*/" contains=@valaCommentGroup,@valaCommentStringGroup,valaCommentStartError,valaSpaceError,@Spell extend fold
  76   if !exists("vala_ignore_valadoc")
  77     syn region 	valaDocComment 		matchgroup=valaCommentStart start="/\*\*" end="\*/" keepend contains=@valaCommentGroup,@valaDocCommentGroup,@valaCommentStringGroup,valaCommentStartError,valaSpaceError,@Spell
  78   endif
  79 else
  80   syn region	valaCommentL		start="//" end="$" keepend contains=@valaCommentGroup,valaSpaceError,@Spell
  81   syn region	valaComment		matchgroup=valaCommentStart start="/\*" end="\*/" contains=@valaCommentGroup,valaCommentStartError,valaSpaceError,@Spell
  82   if !exists("vala_ignore_valadoc")
  83     syn region 	valaDocComment 		matchgroup=valaCommentStart start="/\*\*" end="\*/" keepend contains=@valaCommentGroup,@valaDocCommentGroup,valaCommentStartError,valaSpaceError,@Spell
  84   endif
  85 endif
  86 
  87 syn region	valaPreCondit		start="^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" end="//"me=s-1
  88 syn match	valaPreCondit		display "^\s*\(%:\|#\)\s*\(else\|endif\)\>"
  89 
  90 " Comment if 0 blocks (ported from c.vim)
  91 if !exists("vala_no_if0")
  92   syn region	valaCppOut		start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=valaCppOut2 fold
  93   syn region	valaCppOut2		contained start="0" end="^\s*\(%:\|#\)\s*\(endif\>\|else\>\|elif\>\)" contains=valaSpaceError,valaCppSkip
  94   syn region	valaCppSkip		contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=valaSpaceError,valaCppSkip
  95 endif
  96 
  97 " match comment errors
  98 syntax match valaCommentError 		display "\*/"
  99 syntax match valaCommentStartError 	display "/\*"me=e-1 contained
 100 " match the special comment /**/
 101 syn match   valaComment		 	"/\*\*/"
 102 
 103 " Vala Code Attributes
 104 syn region  valaAttribute 		start="^\s*\[" end="\]$" contains=valaComment,valaString keepend
 105 syn region  valaAttribute 		start="\[CCode" end="\]" contains=valaComment,valaString
 106 
 107 " Avoid escaped keyword matching
 108 syn match   valaUserContent 		display "@\I*"
 109 
 110 " Strings and constants
 111 syn match   valaSpecialError		contained "\\."
 112 syn match   valaSpecialCharError	contained "[^']"
 113 syn match   valaSpecialChar		contained +\\["\\'0abfnrtvx]+
 114 syn region  valaString			start=+"+  end=+"+ end=+$+ contains=valaSpecialChar,valaSpecialError,valaUnicodeNumber,@Spell
 115 syn region  valaVerbatimString		start=+"""+ end=+"""+ contains=@Spell
 116 syn match   valaUnicodeNumber		+\\\(u\x\{4}\|U\x\{8}\)+ contained contains=valaUnicodeSpecifier
 117 syn match   valaUnicodeSpecifier	+\\[uU]+ contained
 118 syn match   valaCharacter		"'[^']*'" contains=valaSpecialChar,valaSpecialCharError
 119 syn match   valaCharacter		"'\\''" contains=valaSpecialChar
 120 syn match   valaCharacter		"'[^\\]'"
 121 syn match   valaNumber			display "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
 122 syn match   valaNumber			display "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
 123 syn match   valaNumber			display "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
 124 syn match   valaNumber			display "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
 125 
 126 " when wanted, highlight trailing white space
 127 if exists("vala_space_errors")
 128   if !exists("vala_no_trail_space_error")
 129     syn match valaSpaceError		display excludenl "\s\+$"
 130   endif
 131   if !exists("vala_no_tab_space_error")
 132     syn match valaSpaceError 		display " \+\t"me=e-1
 133   endif
 134 endif
 135 
 136 " when wanted, set minimum lines for comment syntax syncing
 137 if exists("vala_minlines")
 138   let b:vala_minlines = vala_minlines
 139 else
 140   let b:vala_minlines = 50
 141 endif
 142 exec "syn sync ccomment valaComment minlines=" . b:vala_minlines
 143 
 144 " code folding
 145 syn region valaBlock			start="{" end="}" transparent fold
 146 
 147 " The default highlighting.
 148 hi def link valaType			Type
 149 hi def link valaStorage			StorageClass
 150 hi def link valaRepeat			Repeat
 151 hi def link valaConditional		Conditional
 152 hi def link valaLabel			Label
 153 hi def link valaModifier		StorageClass
 154 hi def link valaConstant		Constant
 155 hi def link valaException		Exception
 156 hi def link valaUnspecifiedStatement	Statement
 157 hi def link valaUnspecifiedKeyword	Keyword
 158 hi def link valaContextualStatement	Statement
 159 
 160 hi def link valaCommentError		Error
 161 hi def link valaCommentStartError	Error
 162 hi def link valaSpecialError		Error
 163 hi def link valaSpecialCharError	Error
 164 hi def link valaSpaceError 		Error
 165 
 166 hi def link valaTodo			Todo
 167 hi def link valaCommentL		valaComment
 168 hi def link valaCommentStart		valaComment
 169 hi def link valaCommentSkip		valaComment
 170 hi def link valaComment			Comment
 171 hi def link valaDocComment		Comment
 172 hi def link valaDocTags 		Special
 173 hi def link valaDocParam 		Function
 174 hi def link valaDocSeeTagParam 		Function
 175 hi def link valaAttribute 		PreCondit
 176 
 177 hi def link valaCommentString		valaString
 178 hi def link valaComment2String		valaString
 179 hi def link valaString			String
 180 hi def link valaVerbatimString		String
 181 hi def link valaCharacter		Character
 182 hi def link valaSpecialChar		SpecialChar
 183 hi def link valaNumber			Number
 184 hi def link valaUnicodeNumber		SpecialChar
 185 hi def link valaUnicodeSpecifier	SpecialChar
 186 
 187 hi def link valaPreCondit		PreCondit
 188 
 189 if !exists("vala_no_if0")
 190   hi def link valaCppSkip		valaCppOut
 191   hi def link valaCppOut2		valaCppOut
 192   hi def link valaCppOut		Comment
 193 endif
 194 
 195 let b:current_syntax = "vala"
 196 
 197 let &cpo = s:vala_cpo_save
 198 unlet s:vala_cpo_save
 199 
 200 " vim: ts=8

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2012-02-19 22:18:48, 8.4 KB) [[attachment:vala.vim]]

You are not allowed to attach a file to this page.