blob: dc39677724703c490b96f60c7aaff9ea3480b445 [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 Moolenaar26852122016-05-24 20:02:38 +02005" Version: 0.1.16
Bram Moolenaar6be7f872012-01-20 21:08:56 +01006" URL: http://www.vim.org/scripts/script.php?script_id=945
Bram Moolenaar26852122016-05-24 20:02:38 +02007" Last Change: 2016 May 23
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 "->"
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200160syn match groovyLineComment '^\%1l#!.*' " Shebang line
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000161syn 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 Moolenaar26852122016-05-24 20:02:38 +0200258if exists("groovy_regex_strings")
259 " regex strings interfere with the division operator and thus are disabled
260 " by default
261 syn region groovyString start='/[^/*]' end='/' contains=groovySpecialChar,groovyRegexChar,groovyELExpr
262endif
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000263" syn region groovyELExpr start=+${+ end=+}+ keepend contained
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100264syn match groovyELExpr /\${.\{-}}/ contained
265syn match groovyELExpr /\$[a-zA-Z_][a-zA-Z0-9_.]*/ contained
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000266GroovyHiLink groovyELExpr Identifier
267
268" TODO: better matching. I am waiting to understand how it really works in groovy
269" syn region groovyClosureParamsBraces start=+|+ end=+|+ contains=groovyClosureParams
270" syn match groovyClosureParams "[ a-zA-Z0-9_*]\+" contained
271" GroovyHiLink groovyClosureParams Identifier
272
273" next line disabled, it can cause a crash for a long line
274"syn match groovyStringError +"\([^"\\]\|\\.\)*$+
275
276" disabled: in groovy strings or characters are written the same
277" syn match groovyCharacter "'[^']*'" contains=groovySpecialChar,groovySpecialCharError
278" syn match groovyCharacter "'\\''" contains=groovySpecialChar
279" syn match groovyCharacter "'[^\\]'"
280syn match groovyNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
281syn match groovyNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
282syn match groovyNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
283syn match groovyNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
284
285" unicode characters
286syn match groovySpecial "\\u\d\{4\}"
287
288syn cluster groovyTop add=groovyString,groovyCharacter,groovyNumber,groovySpecial,groovyStringError
289
290if exists("groovy_highlight_functions")
291 if groovy_highlight_functions == "indent"
292 syn match groovyFuncDef "^\(\t\| \{8\}\)[_$a-zA-Z][_$a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
293 syn region groovyFuncDef start=+^\(\t\| \{8\}\)[$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
294 syn match groovyFuncDef "^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
295 syn region groovyFuncDef start=+^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
296 else
297 " This line catches method declarations at any indentation>0, but it assumes
298 " two things:
299 " 1. class names are always capitalized (ie: Button)
300 " 2. method names are never capitalized (except constructors, of course)
301 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
302 endif
303 syn match groovyBraces "[{}]"
304 syn cluster groovyTop add=groovyFuncDef,groovyBraces
305endif
306
307if exists("groovy_highlight_debug")
308
309 " Strings and constants
310 syn match groovyDebugSpecial contained "\\\d\d\d\|\\."
311 syn region groovyDebugString contained start=+"+ end=+"+ contains=groovyDebugSpecial
312 syn match groovyDebugStringError +"\([^"\\]\|\\.\)*$+
313 syn match groovyDebugCharacter contained "'[^\\]'"
314 syn match groovyDebugSpecialCharacter contained "'\\.'"
315 syn match groovyDebugSpecialCharacter contained "'\\''"
316 syn match groovyDebugNumber contained "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
317 syn match groovyDebugNumber contained "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
318 syn match groovyDebugNumber contained "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
319 syn match groovyDebugNumber contained "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
320 syn keyword groovyDebugBoolean contained true false
321 syn keyword groovyDebugType contained null this super
322 syn region groovyDebugParen start=+(+ end=+)+ contained contains=groovyDebug.*,groovyDebugParen
323
324 " to make this work you must define the highlighting for these groups
325 syn match groovyDebug "\<System\.\(out\|err\)\.print\(ln\)*\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
326 syn match groovyDebug "\<p\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
327 syn match groovyDebug "[A-Za-z][a-zA-Z0-9_]*\.printStackTrace\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
328 syn match groovyDebug "\<trace[SL]\=\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
329
330 syn cluster groovyTop add=groovyDebug
331
332 if version >= 508 || !exists("did_c_syn_inits")
333 GroovyHiLink groovyDebug Debug
334 GroovyHiLink groovyDebugString DebugString
335 GroovyHiLink groovyDebugStringError groovyError
336 GroovyHiLink groovyDebugType DebugType
337 GroovyHiLink groovyDebugBoolean DebugBoolean
338 GroovyHiLink groovyDebugNumber Debug
339 GroovyHiLink groovyDebugSpecial DebugSpecial
340 GroovyHiLink groovyDebugSpecialCharacter DebugSpecial
341 GroovyHiLink groovyDebugCharacter DebugString
342 GroovyHiLink groovyDebugParen Debug
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100343
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000344 GroovyHiLink DebugString String
345 GroovyHiLink DebugSpecial Special
346 GroovyHiLink DebugBoolean Boolean
347 GroovyHiLink DebugType Type
348 endif
349endif
350
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100351" Match all Exception classes
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000352syn match groovyExceptions "\<Exception\>\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>"
353
354
355if !exists("groovy_minlines")
356 let groovy_minlines = 10
357endif
358exec "syn sync ccomment groovyComment minlines=" . groovy_minlines
359
360
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100361" ###################
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000362" Groovy stuff
363" syn match groovyOperator "|[ ,a-zA-Z0-9_*]\+|"
364
365" All groovy valid tokens
366" syn match groovyTokens ";\|,\|<=>\|<>\|:\|:=\|>\|>=\|=\|==\|<\|<=\|!=\|/\|/=\|\.\.|\.\.\.\|\~=\|\~=="
367" syn match groovyTokens "\*=\|&\|&=\|\*\|->\|\~\|+\|-\|/\|?\|<<<\|>>>\|<<\|>>"
368
369" Must put explicit these ones because groovy.vim mark them as errors otherwise
370" syn match groovyTokens "<=>\|<>\|==\~"
371"syn cluster groovyTop add=groovyTokens
372
373" Mark these as operators
374
375" Hightlight brackets
376" syn match groovyBraces "[{}]"
377" syn match groovyBraces "[\[\]]"
378" syn match groovyBraces "[\|]"
379
380if exists("groovy_mark_braces_in_parens_as_errors")
381 syn match groovyInParen contained "[{}]"
382 GroovyHiLink groovyInParen groovyError
383 syn cluster groovyTop add=groovyInParen
384endif
385
386" catch errors caused by wrong parenthesis
387syn region groovyParenT transparent matchgroup=groovyParen start="(" end=")" contains=@groovyTop,groovyParenT1
388syn region groovyParenT1 transparent matchgroup=groovyParen1 start="(" end=")" contains=@groovyTop,groovyParenT2 contained
389syn region groovyParenT2 transparent matchgroup=groovyParen2 start="(" end=")" contains=@groovyTop,groovyParenT contained
390syn match groovyParenError ")"
391GroovyHiLink groovyParenError groovyError
392
393" catch errors caused by wrong square parenthesis
394syn region groovyParenT transparent matchgroup=groovyParen start="\[" end="\]" contains=@groovyTop,groovyParenT1
395syn region groovyParenT1 transparent matchgroup=groovyParen1 start="\[" end="\]" contains=@groovyTop,groovyParenT2 contained
396syn region groovyParenT2 transparent matchgroup=groovyParen2 start="\[" end="\]" contains=@groovyTop,groovyParenT contained
397syn match groovyParenError "\]"
398
399" ###############################
400" java.vim default highlighting
401if version >= 508 || !exists("did_groovy_syn_inits")
402 if version < 508
403 let did_groovy_syn_inits = 1
404 endif
405 GroovyHiLink groovyFuncDef Function
406 GroovyHiLink groovyBraces Function
407 GroovyHiLink groovyBranch Conditional
408 GroovyHiLink groovyUserLabelRef groovyUserLabel
409 GroovyHiLink groovyLabel Label
410 GroovyHiLink groovyUserLabel Label
411 GroovyHiLink groovyConditional Conditional
412 GroovyHiLink groovyRepeat Repeat
413 GroovyHiLink groovyExceptions Exception
414 GroovyHiLink groovyAssert Statement
415 GroovyHiLink groovyStorageClass StorageClass
416 GroovyHiLink groovyMethodDecl groovyStorageClass
417 GroovyHiLink groovyClassDecl groovyStorageClass
418 GroovyHiLink groovyScopeDecl groovyStorageClass
419 GroovyHiLink groovyBoolean Boolean
420 GroovyHiLink groovySpecial Special
421 GroovyHiLink groovySpecialError Error
422 GroovyHiLink groovySpecialCharError Error
423 GroovyHiLink groovyString String
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100424 GroovyHiLink groovyRegexChar String
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000425 GroovyHiLink groovyCharacter Character
426 GroovyHiLink groovySpecialChar SpecialChar
427 GroovyHiLink groovyNumber Number
428 GroovyHiLink groovyError Error
429 GroovyHiLink groovyStringError Error
430 GroovyHiLink groovyStatement Statement
431 GroovyHiLink groovyOperator Operator
432 GroovyHiLink groovyComment Comment
433 GroovyHiLink groovyDocComment Comment
434 GroovyHiLink groovyLineComment Comment
435 GroovyHiLink groovyConstant Constant
436 GroovyHiLink groovyTypedef Typedef
437 GroovyHiLink groovyTodo Todo
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100438
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000439 GroovyHiLink groovyCommentTitle SpecialComment
440 GroovyHiLink groovyDocTags Special
441 GroovyHiLink groovyDocParam Function
442 GroovyHiLink groovyCommentStar groovyComment
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100443
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000444 GroovyHiLink groovyType Type
445 GroovyHiLink groovyExternal Include
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100446
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000447 GroovyHiLink htmlComment Special
448 GroovyHiLink htmlCommentPart Special
449 GroovyHiLink groovySpaceError Error
450 GroovyHiLink groovyJDKBuiltin Special
451 GroovyHiLink groovyJDKOperOverl Operator
452 GroovyHiLink groovyJDKMethods Function
453endif
454
455delcommand GroovyHiLink
456
457
458let b:current_syntax = "groovy"
459if main_syntax == 'groovy'
460 unlet main_syntax
461endif
462
463let b:spell_options="contained"
464
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100465let &cpo = s:cpo_save
466unlet s:cpo_save
467
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000468" vim: ts=8