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