blob: 5b256f39893b724d56599ec73e2faedc295ec2aa [file] [log] [blame]
Bram Moolenaarc01140a2006-03-24 22:21:52 +00001" Vim syntax file
2" Language: Groovy
Bram Moolenaar81af9252010-12-10 20:35:50 +01003" Original Author: Alessio Pace <billy.corgan@tiscali.it>
4" Maintainer: Tobias Rapp <yahuxo@gmx.de>
Bram Moolenaar6be7f872012-01-20 21:08:56 +01005" Version: 0.1.11
6" URL: http://www.vim.org/scripts/script.php?script_id=945
7" Last Change: 2012 Jan 08
Bram Moolenaarc01140a2006-03-24 22:21:52 +00008
Bram Moolenaar81af9252010-12-10 20:35:50 +01009" THE ORIGINAL AUTHOR'S NOTES:
10"
Bram Moolenaarc01140a2006-03-24 22:21:52 +000011" This is my very first vim script, I hope to have
12" done it the right way.
Bram Moolenaar6be7f872012-01-20 21:08:56 +010013"
Bram Moolenaarc01140a2006-03-24 22:21:52 +000014" I must directly or indirectly thank the author of java.vim and ruby.vim:
15" I copied from them most of the stuff :-)
16"
17" Relies on html.vim
18
19" For version 5.x: Clear all syntax items
20" For version 6.x: Quit when a syntax file was already loaded
21"
Bram Moolenaar81af9252010-12-10 20:35:50 +010022" HOWTO USE IT (INSTALL) when not part of the distribution:
Bram Moolenaarc01140a2006-03-24 22:21:52 +000023"
24" 1) copy the file in the (global or user's $HOME/.vim/syntax/) syntax folder
Bram Moolenaar6be7f872012-01-20 21:08:56 +010025"
Bram Moolenaarc01140a2006-03-24 22:21:52 +000026" 2) add this line to recognize groovy files by filename extension:
27"
28" au BufNewFile,BufRead *.groovy setf groovy
29" in the global vim filetype.vim file or inside $HOME/.vim/filetype.vim
30"
31" 3) add this part to recognize by content groovy script (no extension needed :-)
32"
33" if did_filetype()
34" finish
35" endif
36" if getline(1) =~ '^#!.*[/\\]groovy\>'
37" setf groovy
38" endif
39"
40" in the global scripts.vim file or in $HOME/.vim/scripts.vim
Bram Moolenaar6be7f872012-01-20 21:08:56 +010041"
Bram Moolenaarc01140a2006-03-24 22:21:52 +000042" 4) open/write a .groovy file or a groovy script :-)
43"
44" Let me know if you like it or send me patches, so that I can improve it
45" when I have time
46
47" Quit when a syntax file was already loaded
48if !exists("main_syntax")
49 if version < 600
50 syntax clear
51 elseif exists("b:current_syntax")
52 finish
53 endif
54 " we define it here so that included files can test for it
55 let main_syntax='groovy'
56endif
57
Bram Moolenaar6be7f872012-01-20 21:08:56 +010058let s:cpo_save = &cpo
59set cpo&vim
60
Bram Moolenaarc01140a2006-03-24 22:21:52 +000061" don't use standard HiLink, it will not work with included syntax files
62if version < 508
63 command! -nargs=+ GroovyHiLink hi link <args>
64else
65 command! -nargs=+ GroovyHiLink hi def link <args>
66endif
67
68" ##########################
69" Java stuff taken from java.vim
70" some characters that cannot be in a groovy program (outside a string)
71" syn match groovyError "[\\@`]"
72"syn match groovyError "<<<\|\.\.\|=>\|<>\|||=\|&&=\|[^-]->\|\*\/"
73"syn match groovyOK "\.\.\."
74
75" keyword definitions
76syn keyword groovyExternal native package
77syn match groovyExternal "\<import\(\s\+static\>\)\?"
78syn keyword groovyError goto const
79syn keyword groovyConditional if else switch
80syn keyword groovyRepeat while for do
81syn keyword groovyBoolean true false
82syn keyword groovyConstant null
83syn keyword groovyTypedef this super
84syn keyword groovyOperator new instanceof
85syn keyword groovyType boolean char byte short int long float double
86syn keyword groovyType void
87syn keyword groovyType Integer Double Date Boolean Float String Array Vector List
88syn keyword groovyStatement return
89syn keyword groovyStorageClass static synchronized transient volatile final strictfp serializable
90syn keyword groovyExceptions throw try catch finally
91syn keyword groovyAssert assert
92syn keyword groovyMethodDecl synchronized throws
93syn keyword groovyClassDecl extends implements interface
94" to differentiate the keyword class from MyClass.class we use a match here
95syn match groovyTypedef "\.\s*\<class\>"ms=s+1
96syn keyword groovyClassDecl enum
97syn match groovyClassDecl "^class\>"
98syn match groovyClassDecl "[^.]\s*\<class\>"ms=s+1
99syn keyword groovyBranch break continue nextgroup=groovyUserLabelRef skipwhite
100syn match groovyUserLabelRef "\k\+" contained
101syn keyword groovyScopeDecl public protected private abstract
102
103
104if exists("groovy_highlight_groovy_lang_ids") || exists("groovy_highlight_groovy_lang") || exists("groovy_highlight_all")
105 " groovy.lang.*
106 syn keyword groovyLangClass Closure MetaMethod GroovyObject
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100107
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000108 syn match groovyJavaLangClass "\<System\>"
109 syn keyword groovyJavaLangClass Cloneable Comparable Runnable Serializable Boolean Byte Class Object
110 syn keyword groovyJavaLangClass Character CharSequence ClassLoader Compiler
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100111 " syn keyword groovyJavaLangClass Integer Double Float Long
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000112 syn keyword groovyJavaLangClass InheritableThreadLocal Math Number Object Package Process
113 syn keyword groovyJavaLangClass Runtime RuntimePermission InheritableThreadLocal
114 syn keyword groovyJavaLangClass SecurityManager Short StrictMath StackTraceElement
115 syn keyword groovyJavaLangClass StringBuffer Thread ThreadGroup
116 syn keyword groovyJavaLangClass ThreadLocal Throwable Void ArithmeticException
117 syn keyword groovyJavaLangClass ArrayIndexOutOfBoundsException AssertionError
118 syn keyword groovyJavaLangClass ArrayStoreException ClassCastException
119 syn keyword groovyJavaLangClass ClassNotFoundException
120 syn keyword groovyJavaLangClass CloneNotSupportedException Exception
121 syn keyword groovyJavaLangClass IllegalAccessException
122 syn keyword groovyJavaLangClass IllegalArgumentException
123 syn keyword groovyJavaLangClass IllegalMonitorStateException
124 syn keyword groovyJavaLangClass IllegalStateException
125 syn keyword groovyJavaLangClass IllegalThreadStateException
126 syn keyword groovyJavaLangClass IndexOutOfBoundsException
127 syn keyword groovyJavaLangClass InstantiationException InterruptedException
128 syn keyword groovyJavaLangClass NegativeArraySizeException NoSuchFieldException
129 syn keyword groovyJavaLangClass NoSuchMethodException NullPointerException
130 syn keyword groovyJavaLangClass NumberFormatException RuntimeException
131 syn keyword groovyJavaLangClass SecurityException StringIndexOutOfBoundsException
132 syn keyword groovyJavaLangClass UnsupportedOperationException
133 syn keyword groovyJavaLangClass AbstractMethodError ClassCircularityError
134 syn keyword groovyJavaLangClass ClassFormatError Error ExceptionInInitializerError
135 syn keyword groovyJavaLangClass IllegalAccessError InstantiationError
136 syn keyword groovyJavaLangClass IncompatibleClassChangeError InternalError
137 syn keyword groovyJavaLangClass LinkageError NoClassDefFoundError
138 syn keyword groovyJavaLangClass NoSuchFieldError NoSuchMethodError
139 syn keyword groovyJavaLangClass OutOfMemoryError StackOverflowError
140 syn keyword groovyJavaLangClass ThreadDeath UnknownError UnsatisfiedLinkError
141 syn keyword groovyJavaLangClass UnsupportedClassVersionError VerifyError
142 syn keyword groovyJavaLangClass VirtualMachineError
143
144 syn keyword groovyJavaLangObject clone equals finalize getClass hashCode
145 syn keyword groovyJavaLangObject notify notifyAll toString wait
146
147 GroovyHiLink groovyLangClass groovyConstant
148 GroovyHiLink groovyJavaLangClass groovyExternal
149 GroovyHiLink groovyJavaLangObject groovyConstant
150 syn cluster groovyTop add=groovyJavaLangObject,groovyJavaLangClass,groovyLangClass
151 syn cluster groovyClasses add=groovyJavaLangClass,groovyLangClass
152endif
153
154
155" Groovy stuff
156syn match groovyOperator "\.\."
157syn match groovyOperator "<\{2,3}"
158syn match groovyOperator ">\{2,3}"
159syn match groovyOperator "->"
160syn match groovyExternal '^#!.*[/\\]groovy\>'
161syn match groovyExceptions "\<Exception\>\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>"
162
163" Groovy JDK stuff
164syn keyword groovyJDKBuiltin as def in
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100165syn keyword groovyJDKOperOverl div minus plus abs round power multiply
166syn keyword groovyJDKMethods each call inject sort print println
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000167syn keyword groovyJDKMethods getAt putAt size push pop toList getText writeLine eachLine readLines
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100168syn keyword groovyJDKMethods withReader withStream withWriter withPrintWriter write read leftShift
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000169syn keyword groovyJDKMethods withWriterAppend readBytes splitEachLine
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100170syn keyword groovyJDKMethods newInputStream newOutputStream newPrintWriter newReader newWriter
171syn keyword groovyJDKMethods compareTo next previous isCase
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000172syn keyword groovyJDKMethods times step toInteger upto any collect dump every find findAll grep
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100173syn keyword groovyJDKMethods inspect invokeMethods join
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000174syn keyword groovyJDKMethods getErr getIn getOut waitForOrKill
175syn keyword groovyJDKMethods count tokenize asList flatten immutable intersect reverse reverseEach
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100176syn keyword groovyJDKMethods subMap append asWritable eachByte eachLine eachFile
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000177syn cluster groovyTop add=groovyJDKBuiltin,groovyJDKOperOverl,groovyJDKMethods
178
179" no useful I think, so I comment it..
180"if filereadable(expand("<sfile>:p:h")."/groovyid.vim")
181 " source <sfile>:p:h/groovyid.vim
182"endif
183
184if exists("groovy_space_errors")
185 if !exists("groovy_no_trail_space_error")
186 syn match groovySpaceError "\s\+$"
187 endif
188 if !exists("groovy_no_tab_space_error")
189 syn match groovySpaceError " \+\t"me=e-1
190 endif
191endif
192
193" it is a better case construct than java.vim to match groovy syntax
194syn region groovyLabelRegion transparent matchgroup=groovyLabel start="\<case\>" matchgroup=NONE end=":\|$" contains=groovyNumber,groovyString,groovyLangClass,groovyJavaLangClass
195syn match groovyUserLabel "^\s*[_$a-zA-Z][_$a-zA-Z0-9_]*\s*:"he=e-1 contains=groovyLabel
196syn keyword groovyLabel default
197
198if !exists("groovy_allow_cpp_keywords")
199 syn keyword groovyError auto delete extern friend inline redeclared
200 syn keyword groovyError register signed sizeof struct template typedef union
201 syn keyword groovyError unsigned operator
202endif
203
204" The following cluster contains all groovy groups except the contained ones
205syn cluster groovyTop add=groovyExternal,groovyError,groovyError,groovyBranch,groovyLabelRegion,groovyLabel,groovyConditional,groovyRepeat,groovyBoolean,groovyConstant,groovyTypedef,groovyOperator,groovyType,groovyType,groovyStatement,groovyStorageClass,groovyAssert,groovyExceptions,groovyMethodDecl,groovyClassDecl,groovyClassDecl,groovyClassDecl,groovyScopeDecl,groovyError,groovyError2,groovyUserLabel,groovyLangObject
206
207
208" Comments
209syn keyword groovyTodo contained TODO FIXME XXX
210if exists("groovy_comment_strings")
211 syn region groovyCommentString contained start=+"+ end=+"+ end=+$+ end=+\*/+me=s-1,he=s-1 contains=groovySpecial,groovyCommentStar,groovySpecialChar,@Spell
212 syn region groovyComment2String contained start=+"+ end=+$\|"+ contains=groovySpecial,groovySpecialChar,@Spell
213 syn match groovyCommentCharacter contained "'\\[^']\{1,6\}'" contains=groovySpecialChar
214 syn match groovyCommentCharacter contained "'\\''" contains=groovySpecialChar
215 syn match groovyCommentCharacter contained "'[^\\]'"
216 syn cluster groovyCommentSpecial add=groovyCommentString,groovyCommentCharacter,groovyNumber
217 syn cluster groovyCommentSpecial2 add=groovyComment2String,groovyCommentCharacter,groovyNumber
218endif
219syn region groovyComment start="/\*" end="\*/" contains=@groovyCommentSpecial,groovyTodo,@Spell
220syn match groovyCommentStar contained "^\s*\*[^/]"me=e-1
221syn match groovyCommentStar contained "^\s*\*$"
222syn match groovyLineComment "//.*" contains=@groovyCommentSpecial2,groovyTodo,@Spell
223syn match groovyLineComment "#.*" contains=@groovyCommentSpecial2,groovyTodo,@Spell
224GroovyHiLink groovyCommentString groovyString
225GroovyHiLink groovyComment2String groovyString
226GroovyHiLink groovyCommentCharacter groovyCharacter
227
228syn cluster groovyTop add=groovyComment,groovyLineComment
229
230if !exists("groovy_ignore_groovydoc") && main_syntax != 'jsp'
231 syntax case ignore
232 " syntax coloring for groovydoc comments (HTML)
233 " syntax include @groovyHtml <sfile>:p:h/html.vim
234 syntax include @groovyHtml runtime! syntax/html.vim
235 unlet b:current_syntax
Bram Moolenaar5c736222010-01-06 20:54:52 +0100236 syntax spell default " added by Bram
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000237 syn region groovyDocComment start="/\*\*" end="\*/" keepend contains=groovyCommentTitle,@groovyHtml,groovyDocTags,groovyTodo,@Spell
238 syn region groovyCommentTitle contained matchgroup=groovyDocComment start="/\*\*" matchgroup=groovyCommentTitle keepend end="\.$" end="\.[ \t\r<&]"me=e-1 end="[^{]@"me=s-2,he=s-1 end="\*/"me=s-1,he=s-1 contains=@groovyHtml,groovyCommentStar,groovyTodo,@Spell,groovyDocTags
239
240 syn region groovyDocTags contained start="{@\(link\|linkplain\|inherit[Dd]oc\|doc[rR]oot\|value\)" end="}"
241 syn match groovyDocTags contained "@\(see\|param\|exception\|throws\|since\)\s\+\S\+" contains=groovyDocParam
242 syn match groovyDocParam contained "\s\S\+"
243 syn match groovyDocTags contained "@\(version\|author\|return\|deprecated\|serial\|serialField\|serialData\)\>"
244 syntax case match
245endif
246
247" match the special comment /**/
248syn match groovyComment "/\*\*/"
249
250" Strings and constants
251syn match groovySpecialError contained "\\."
252syn match groovySpecialCharError contained "[^']"
253syn match groovySpecialChar contained "\\\([4-9]\d\|[0-3]\d\d\|[\"\\'ntbrf]\|u\x\{4\}\)"
254syn region groovyString start=+"+ end=+"+ end=+$+ contains=groovySpecialChar,groovySpecialError,@Spell,groovyELExpr
Bram Moolenaar81af9252010-12-10 20:35:50 +0100255syn region groovyString start=+'+ end=+'+ end=+$+ contains=groovySpecialChar,groovySpecialError,@Spell
256syn region groovyString start=+"""+ end=+"""+ contains=groovySpecialChar,groovySpecialError,@Spell,groovyELExpr
257syn region groovyString start=+'''+ end=+'''+ contains=groovySpecialChar,groovySpecialError,@Spell
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000258" syn region groovyELExpr start=+${+ end=+}+ keepend contained
259 syn match groovyELExpr /\${.\{-}}/ contained
260GroovyHiLink groovyELExpr Identifier
261
262" TODO: better matching. I am waiting to understand how it really works in groovy
263" syn region groovyClosureParamsBraces start=+|+ end=+|+ contains=groovyClosureParams
264" syn match groovyClosureParams "[ a-zA-Z0-9_*]\+" contained
265" GroovyHiLink groovyClosureParams Identifier
266
267" next line disabled, it can cause a crash for a long line
268"syn match groovyStringError +"\([^"\\]\|\\.\)*$+
269
270" disabled: in groovy strings or characters are written the same
271" syn match groovyCharacter "'[^']*'" contains=groovySpecialChar,groovySpecialCharError
272" syn match groovyCharacter "'\\''" contains=groovySpecialChar
273" syn match groovyCharacter "'[^\\]'"
274syn match groovyNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
275syn match groovyNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
276syn match groovyNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
277syn match groovyNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
278
279" unicode characters
280syn match groovySpecial "\\u\d\{4\}"
281
282syn cluster groovyTop add=groovyString,groovyCharacter,groovyNumber,groovySpecial,groovyStringError
283
284if exists("groovy_highlight_functions")
285 if groovy_highlight_functions == "indent"
286 syn match groovyFuncDef "^\(\t\| \{8\}\)[_$a-zA-Z][_$a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
287 syn region groovyFuncDef start=+^\(\t\| \{8\}\)[$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
288 syn match groovyFuncDef "^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
289 syn region groovyFuncDef start=+^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
290 else
291 " This line catches method declarations at any indentation>0, but it assumes
292 " two things:
293 " 1. class names are always capitalized (ie: Button)
294 " 2. method names are never capitalized (except constructors, of course)
295 syn region groovyFuncDef start=+^\s\+\(\(public\|protected\|private\|static\|abstract\|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*([^0-9]+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,groovyComment,groovyLineComment,@groovyClasses
296 endif
297 syn match groovyBraces "[{}]"
298 syn cluster groovyTop add=groovyFuncDef,groovyBraces
299endif
300
301if exists("groovy_highlight_debug")
302
303 " Strings and constants
304 syn match groovyDebugSpecial contained "\\\d\d\d\|\\."
305 syn region groovyDebugString contained start=+"+ end=+"+ contains=groovyDebugSpecial
306 syn match groovyDebugStringError +"\([^"\\]\|\\.\)*$+
307 syn match groovyDebugCharacter contained "'[^\\]'"
308 syn match groovyDebugSpecialCharacter contained "'\\.'"
309 syn match groovyDebugSpecialCharacter contained "'\\''"
310 syn match groovyDebugNumber contained "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
311 syn match groovyDebugNumber contained "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
312 syn match groovyDebugNumber contained "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
313 syn match groovyDebugNumber contained "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
314 syn keyword groovyDebugBoolean contained true false
315 syn keyword groovyDebugType contained null this super
316 syn region groovyDebugParen start=+(+ end=+)+ contained contains=groovyDebug.*,groovyDebugParen
317
318 " to make this work you must define the highlighting for these groups
319 syn match groovyDebug "\<System\.\(out\|err\)\.print\(ln\)*\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
320 syn match groovyDebug "\<p\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
321 syn match groovyDebug "[A-Za-z][a-zA-Z0-9_]*\.printStackTrace\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
322 syn match groovyDebug "\<trace[SL]\=\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
323
324 syn cluster groovyTop add=groovyDebug
325
326 if version >= 508 || !exists("did_c_syn_inits")
327 GroovyHiLink groovyDebug Debug
328 GroovyHiLink groovyDebugString DebugString
329 GroovyHiLink groovyDebugStringError groovyError
330 GroovyHiLink groovyDebugType DebugType
331 GroovyHiLink groovyDebugBoolean DebugBoolean
332 GroovyHiLink groovyDebugNumber Debug
333 GroovyHiLink groovyDebugSpecial DebugSpecial
334 GroovyHiLink groovyDebugSpecialCharacter DebugSpecial
335 GroovyHiLink groovyDebugCharacter DebugString
336 GroovyHiLink groovyDebugParen Debug
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100337
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000338 GroovyHiLink DebugString String
339 GroovyHiLink DebugSpecial Special
340 GroovyHiLink DebugBoolean Boolean
341 GroovyHiLink DebugType Type
342 endif
343endif
344
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100345" Match all Exception classes
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000346syn match groovyExceptions "\<Exception\>\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>"
347
348
349if !exists("groovy_minlines")
350 let groovy_minlines = 10
351endif
352exec "syn sync ccomment groovyComment minlines=" . groovy_minlines
353
354
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100355" ###################
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000356" Groovy stuff
357" syn match groovyOperator "|[ ,a-zA-Z0-9_*]\+|"
358
359" All groovy valid tokens
360" syn match groovyTokens ";\|,\|<=>\|<>\|:\|:=\|>\|>=\|=\|==\|<\|<=\|!=\|/\|/=\|\.\.|\.\.\.\|\~=\|\~=="
361" syn match groovyTokens "\*=\|&\|&=\|\*\|->\|\~\|+\|-\|/\|?\|<<<\|>>>\|<<\|>>"
362
363" Must put explicit these ones because groovy.vim mark them as errors otherwise
364" syn match groovyTokens "<=>\|<>\|==\~"
365"syn cluster groovyTop add=groovyTokens
366
367" Mark these as operators
368
369" Hightlight brackets
370" syn match groovyBraces "[{}]"
371" syn match groovyBraces "[\[\]]"
372" syn match groovyBraces "[\|]"
373
374if exists("groovy_mark_braces_in_parens_as_errors")
375 syn match groovyInParen contained "[{}]"
376 GroovyHiLink groovyInParen groovyError
377 syn cluster groovyTop add=groovyInParen
378endif
379
380" catch errors caused by wrong parenthesis
381syn region groovyParenT transparent matchgroup=groovyParen start="(" end=")" contains=@groovyTop,groovyParenT1
382syn region groovyParenT1 transparent matchgroup=groovyParen1 start="(" end=")" contains=@groovyTop,groovyParenT2 contained
383syn region groovyParenT2 transparent matchgroup=groovyParen2 start="(" end=")" contains=@groovyTop,groovyParenT contained
384syn match groovyParenError ")"
385GroovyHiLink groovyParenError groovyError
386
387" catch errors caused by wrong square parenthesis
388syn region groovyParenT transparent matchgroup=groovyParen start="\[" end="\]" contains=@groovyTop,groovyParenT1
389syn region groovyParenT1 transparent matchgroup=groovyParen1 start="\[" end="\]" contains=@groovyTop,groovyParenT2 contained
390syn region groovyParenT2 transparent matchgroup=groovyParen2 start="\[" end="\]" contains=@groovyTop,groovyParenT contained
391syn match groovyParenError "\]"
392
393" ###############################
394" java.vim default highlighting
395if version >= 508 || !exists("did_groovy_syn_inits")
396 if version < 508
397 let did_groovy_syn_inits = 1
398 endif
399 GroovyHiLink groovyFuncDef Function
400 GroovyHiLink groovyBraces Function
401 GroovyHiLink groovyBranch Conditional
402 GroovyHiLink groovyUserLabelRef groovyUserLabel
403 GroovyHiLink groovyLabel Label
404 GroovyHiLink groovyUserLabel Label
405 GroovyHiLink groovyConditional Conditional
406 GroovyHiLink groovyRepeat Repeat
407 GroovyHiLink groovyExceptions Exception
408 GroovyHiLink groovyAssert Statement
409 GroovyHiLink groovyStorageClass StorageClass
410 GroovyHiLink groovyMethodDecl groovyStorageClass
411 GroovyHiLink groovyClassDecl groovyStorageClass
412 GroovyHiLink groovyScopeDecl groovyStorageClass
413 GroovyHiLink groovyBoolean Boolean
414 GroovyHiLink groovySpecial Special
415 GroovyHiLink groovySpecialError Error
416 GroovyHiLink groovySpecialCharError Error
417 GroovyHiLink groovyString String
418 GroovyHiLink groovyCharacter Character
419 GroovyHiLink groovySpecialChar SpecialChar
420 GroovyHiLink groovyNumber Number
421 GroovyHiLink groovyError Error
422 GroovyHiLink groovyStringError Error
423 GroovyHiLink groovyStatement Statement
424 GroovyHiLink groovyOperator Operator
425 GroovyHiLink groovyComment Comment
426 GroovyHiLink groovyDocComment Comment
427 GroovyHiLink groovyLineComment Comment
428 GroovyHiLink groovyConstant Constant
429 GroovyHiLink groovyTypedef Typedef
430 GroovyHiLink groovyTodo Todo
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100431
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000432 GroovyHiLink groovyCommentTitle SpecialComment
433 GroovyHiLink groovyDocTags Special
434 GroovyHiLink groovyDocParam Function
435 GroovyHiLink groovyCommentStar groovyComment
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100436
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000437 GroovyHiLink groovyType Type
438 GroovyHiLink groovyExternal Include
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100439
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000440 GroovyHiLink htmlComment Special
441 GroovyHiLink htmlCommentPart Special
442 GroovyHiLink groovySpaceError Error
443 GroovyHiLink groovyJDKBuiltin Special
444 GroovyHiLink groovyJDKOperOverl Operator
445 GroovyHiLink groovyJDKMethods Function
446endif
447
448delcommand GroovyHiLink
449
450
451let b:current_syntax = "groovy"
452if main_syntax == 'groovy'
453 unlet main_syntax
454endif
455
456let b:spell_options="contained"
457
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100458let &cpo = s:cpo_save
459unlet s:cpo_save
460
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000461" vim: ts=8