blob: fb788c9397ddeac811a95fbec03e3fb327a868ed [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 Moolenaarff034192013-04-24 18:51:19 +02005" Version: 0.1.13
Bram Moolenaar6be7f872012-01-20 21:08:56 +01006" URL: http://www.vim.org/scripts/script.php?script_id=945
Bram Moolenaar0a63ded2015-04-15 13:31:24 +02007" Last Change: 2015 Apr 13
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
Bram Moolenaarff034192013-04-24 18:51:19 +020077syn match groovyExternal "\<import\>\(\s\+static\>\)\?"
Bram Moolenaarc01140a2006-03-24 22:21:52 +000078syn 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
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000223GroovyHiLink groovyCommentString groovyString
224GroovyHiLink groovyComment2String groovyString
225GroovyHiLink groovyCommentCharacter groovyCharacter
226
227syn cluster groovyTop add=groovyComment,groovyLineComment
228
229if !exists("groovy_ignore_groovydoc") && main_syntax != 'jsp'
230 syntax case ignore
231 " syntax coloring for groovydoc comments (HTML)
232 " syntax include @groovyHtml <sfile>:p:h/html.vim
233 syntax include @groovyHtml runtime! syntax/html.vim
234 unlet b:current_syntax
Bram Moolenaar5c736222010-01-06 20:54:52 +0100235 syntax spell default " added by Bram
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000236 syn region groovyDocComment start="/\*\*" end="\*/" keepend contains=groovyCommentTitle,@groovyHtml,groovyDocTags,groovyTodo,@Spell
237 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
238
239 syn region groovyDocTags contained start="{@\(link\|linkplain\|inherit[Dd]oc\|doc[rR]oot\|value\)" end="}"
240 syn match groovyDocTags contained "@\(see\|param\|exception\|throws\|since\)\s\+\S\+" contains=groovyDocParam
241 syn match groovyDocParam contained "\s\S\+"
242 syn match groovyDocTags contained "@\(version\|author\|return\|deprecated\|serial\|serialField\|serialData\)\>"
243 syntax case match
244endif
245
246" match the special comment /**/
247syn match groovyComment "/\*\*/"
248
249" Strings and constants
250syn match groovySpecialError contained "\\."
251syn match groovySpecialCharError contained "[^']"
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100252syn match groovySpecialChar contained "\\\([4-9]\d\|[0-3]\d\d\|[\"\\'ntbrf]\|u\x\{4\}\|\$\)"
253syn match groovyRegexChar contained "\\."
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000254syn 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 Moolenaarac7bd632013-03-19 11:35:58 +0100258" regex string
259syn region groovyString start='/[^/]' end='/' contains=groovySpecialChar,groovyRegexChar,groovyELExpr
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000260" syn region groovyELExpr start=+${+ end=+}+ keepend contained
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100261syn match groovyELExpr /\${.\{-}}/ contained
262syn match groovyELExpr /\$[a-zA-Z_][a-zA-Z0-9_.]*/ contained
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000263GroovyHiLink groovyELExpr Identifier
264
265" TODO: better matching. I am waiting to understand how it really works in groovy
266" syn region groovyClosureParamsBraces start=+|+ end=+|+ contains=groovyClosureParams
267" syn match groovyClosureParams "[ a-zA-Z0-9_*]\+" contained
268" GroovyHiLink groovyClosureParams Identifier
269
270" next line disabled, it can cause a crash for a long line
271"syn match groovyStringError +"\([^"\\]\|\\.\)*$+
272
273" disabled: in groovy strings or characters are written the same
274" syn match groovyCharacter "'[^']*'" contains=groovySpecialChar,groovySpecialCharError
275" syn match groovyCharacter "'\\''" contains=groovySpecialChar
276" syn match groovyCharacter "'[^\\]'"
277syn match groovyNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
278syn match groovyNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
279syn match groovyNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
280syn match groovyNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
281
282" unicode characters
283syn match groovySpecial "\\u\d\{4\}"
284
285syn cluster groovyTop add=groovyString,groovyCharacter,groovyNumber,groovySpecial,groovyStringError
286
287if exists("groovy_highlight_functions")
288 if groovy_highlight_functions == "indent"
289 syn match groovyFuncDef "^\(\t\| \{8\}\)[_$a-zA-Z][_$a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
290 syn region groovyFuncDef start=+^\(\t\| \{8\}\)[$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
291 syn match groovyFuncDef "^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
292 syn region groovyFuncDef start=+^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
293 else
294 " This line catches method declarations at any indentation>0, but it assumes
295 " two things:
296 " 1. class names are always capitalized (ie: Button)
297 " 2. method names are never capitalized (except constructors, of course)
298 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
299 endif
300 syn match groovyBraces "[{}]"
301 syn cluster groovyTop add=groovyFuncDef,groovyBraces
302endif
303
304if exists("groovy_highlight_debug")
305
306 " Strings and constants
307 syn match groovyDebugSpecial contained "\\\d\d\d\|\\."
308 syn region groovyDebugString contained start=+"+ end=+"+ contains=groovyDebugSpecial
309 syn match groovyDebugStringError +"\([^"\\]\|\\.\)*$+
310 syn match groovyDebugCharacter contained "'[^\\]'"
311 syn match groovyDebugSpecialCharacter contained "'\\.'"
312 syn match groovyDebugSpecialCharacter contained "'\\''"
313 syn match groovyDebugNumber contained "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
314 syn match groovyDebugNumber contained "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
315 syn match groovyDebugNumber contained "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
316 syn match groovyDebugNumber contained "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
317 syn keyword groovyDebugBoolean contained true false
318 syn keyword groovyDebugType contained null this super
319 syn region groovyDebugParen start=+(+ end=+)+ contained contains=groovyDebug.*,groovyDebugParen
320
321 " to make this work you must define the highlighting for these groups
322 syn match groovyDebug "\<System\.\(out\|err\)\.print\(ln\)*\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
323 syn match groovyDebug "\<p\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
324 syn match groovyDebug "[A-Za-z][a-zA-Z0-9_]*\.printStackTrace\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
325 syn match groovyDebug "\<trace[SL]\=\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
326
327 syn cluster groovyTop add=groovyDebug
328
329 if version >= 508 || !exists("did_c_syn_inits")
330 GroovyHiLink groovyDebug Debug
331 GroovyHiLink groovyDebugString DebugString
332 GroovyHiLink groovyDebugStringError groovyError
333 GroovyHiLink groovyDebugType DebugType
334 GroovyHiLink groovyDebugBoolean DebugBoolean
335 GroovyHiLink groovyDebugNumber Debug
336 GroovyHiLink groovyDebugSpecial DebugSpecial
337 GroovyHiLink groovyDebugSpecialCharacter DebugSpecial
338 GroovyHiLink groovyDebugCharacter DebugString
339 GroovyHiLink groovyDebugParen Debug
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100340
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000341 GroovyHiLink DebugString String
342 GroovyHiLink DebugSpecial Special
343 GroovyHiLink DebugBoolean Boolean
344 GroovyHiLink DebugType Type
345 endif
346endif
347
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100348" Match all Exception classes
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000349syn match groovyExceptions "\<Exception\>\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>"
350
351
352if !exists("groovy_minlines")
353 let groovy_minlines = 10
354endif
355exec "syn sync ccomment groovyComment minlines=" . groovy_minlines
356
357
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100358" ###################
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000359" Groovy stuff
360" syn match groovyOperator "|[ ,a-zA-Z0-9_*]\+|"
361
362" All groovy valid tokens
363" syn match groovyTokens ";\|,\|<=>\|<>\|:\|:=\|>\|>=\|=\|==\|<\|<=\|!=\|/\|/=\|\.\.|\.\.\.\|\~=\|\~=="
364" syn match groovyTokens "\*=\|&\|&=\|\*\|->\|\~\|+\|-\|/\|?\|<<<\|>>>\|<<\|>>"
365
366" Must put explicit these ones because groovy.vim mark them as errors otherwise
367" syn match groovyTokens "<=>\|<>\|==\~"
368"syn cluster groovyTop add=groovyTokens
369
370" Mark these as operators
371
372" Hightlight brackets
373" syn match groovyBraces "[{}]"
374" syn match groovyBraces "[\[\]]"
375" syn match groovyBraces "[\|]"
376
377if exists("groovy_mark_braces_in_parens_as_errors")
378 syn match groovyInParen contained "[{}]"
379 GroovyHiLink groovyInParen groovyError
380 syn cluster groovyTop add=groovyInParen
381endif
382
383" catch errors caused by wrong parenthesis
384syn region groovyParenT transparent matchgroup=groovyParen start="(" end=")" contains=@groovyTop,groovyParenT1
385syn region groovyParenT1 transparent matchgroup=groovyParen1 start="(" end=")" contains=@groovyTop,groovyParenT2 contained
386syn region groovyParenT2 transparent matchgroup=groovyParen2 start="(" end=")" contains=@groovyTop,groovyParenT contained
387syn match groovyParenError ")"
388GroovyHiLink groovyParenError groovyError
389
390" catch errors caused by wrong square parenthesis
391syn region groovyParenT transparent matchgroup=groovyParen start="\[" end="\]" contains=@groovyTop,groovyParenT1
392syn region groovyParenT1 transparent matchgroup=groovyParen1 start="\[" end="\]" contains=@groovyTop,groovyParenT2 contained
393syn region groovyParenT2 transparent matchgroup=groovyParen2 start="\[" end="\]" contains=@groovyTop,groovyParenT contained
394syn match groovyParenError "\]"
395
396" ###############################
397" java.vim default highlighting
398if version >= 508 || !exists("did_groovy_syn_inits")
399 if version < 508
400 let did_groovy_syn_inits = 1
401 endif
402 GroovyHiLink groovyFuncDef Function
403 GroovyHiLink groovyBraces Function
404 GroovyHiLink groovyBranch Conditional
405 GroovyHiLink groovyUserLabelRef groovyUserLabel
406 GroovyHiLink groovyLabel Label
407 GroovyHiLink groovyUserLabel Label
408 GroovyHiLink groovyConditional Conditional
409 GroovyHiLink groovyRepeat Repeat
410 GroovyHiLink groovyExceptions Exception
411 GroovyHiLink groovyAssert Statement
412 GroovyHiLink groovyStorageClass StorageClass
413 GroovyHiLink groovyMethodDecl groovyStorageClass
414 GroovyHiLink groovyClassDecl groovyStorageClass
415 GroovyHiLink groovyScopeDecl groovyStorageClass
416 GroovyHiLink groovyBoolean Boolean
417 GroovyHiLink groovySpecial Special
418 GroovyHiLink groovySpecialError Error
419 GroovyHiLink groovySpecialCharError Error
420 GroovyHiLink groovyString String
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100421 GroovyHiLink groovyRegexChar String
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000422 GroovyHiLink groovyCharacter Character
423 GroovyHiLink groovySpecialChar SpecialChar
424 GroovyHiLink groovyNumber Number
425 GroovyHiLink groovyError Error
426 GroovyHiLink groovyStringError Error
427 GroovyHiLink groovyStatement Statement
428 GroovyHiLink groovyOperator Operator
429 GroovyHiLink groovyComment Comment
430 GroovyHiLink groovyDocComment Comment
431 GroovyHiLink groovyLineComment Comment
432 GroovyHiLink groovyConstant Constant
433 GroovyHiLink groovyTypedef Typedef
434 GroovyHiLink groovyTodo Todo
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100435
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000436 GroovyHiLink groovyCommentTitle SpecialComment
437 GroovyHiLink groovyDocTags Special
438 GroovyHiLink groovyDocParam Function
439 GroovyHiLink groovyCommentStar groovyComment
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100440
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000441 GroovyHiLink groovyType Type
442 GroovyHiLink groovyExternal Include
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100443
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000444 GroovyHiLink htmlComment Special
445 GroovyHiLink htmlCommentPart Special
446 GroovyHiLink groovySpaceError Error
447 GroovyHiLink groovyJDKBuiltin Special
448 GroovyHiLink groovyJDKOperOverl Operator
449 GroovyHiLink groovyJDKMethods Function
450endif
451
452delcommand GroovyHiLink
453
454
455let b:current_syntax = "groovy"
456if main_syntax == 'groovy'
457 unlet main_syntax
458endif
459
460let b:spell_options="contained"
461
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100462let &cpo = s:cpo_save
463unlet s:cpo_save
464
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000465" vim: ts=8