blob: 3509401edb5af27c523891266a94a97aa3280366 [file] [log] [blame]
Bram Moolenaarc01140a2006-03-24 22:21:52 +00001" Vim syntax file
2" Language: Groovy
Bram Moolenaar388a5d42020-05-26 21:20:45 +02003" Original Author: Alessio Pace <billy.corgan AT tiscali.it>
4" Maintainer: Tobias Rapp <yahuxo+vim AT mailbox.org>
Bram Moolenaar942db232021-02-13 18:14:48 +01005" Version: 0.1.18
Bram Moolenaar6be7f872012-01-20 21:08:56 +01006" URL: http://www.vim.org/scripts/script.php?script_id=945
Bram Moolenaar942db232021-02-13 18:14:48 +01007" Last Change: 2021 Feb 03
Hirohito Higashifbe4a8f2025-04-27 15:28:30 +02008" 2025 Apr 27 by Vim Project correct Vim script spelling
Bram Moolenaarc01140a2006-03-24 22:21:52 +00009
Bram Moolenaar81af9252010-12-10 20:35:50 +010010" THE ORIGINAL AUTHOR'S NOTES:
11"
Hirohito Higashifbe4a8f2025-04-27 15:28:30 +020012" This is my very first Vim script, I hope to have
Bram Moolenaarc01140a2006-03-24 22:21:52 +000013" done it the right way.
Bram Moolenaar6be7f872012-01-20 21:08:56 +010014"
Bram Moolenaarc01140a2006-03-24 22:21:52 +000015" I must directly or indirectly thank the author of java.vim and ruby.vim:
16" I copied from them most of the stuff :-)
17"
18" Relies on html.vim
19
20" For version 5.x: Clear all syntax items
21" For version 6.x: Quit when a syntax file was already loaded
22"
Bram Moolenaar81af9252010-12-10 20:35:50 +010023" HOWTO USE IT (INSTALL) when not part of the distribution:
Bram Moolenaarc01140a2006-03-24 22:21:52 +000024"
25" 1) copy the file in the (global or user's $HOME/.vim/syntax/) syntax folder
Bram Moolenaar6be7f872012-01-20 21:08:56 +010026"
Bram Moolenaarc01140a2006-03-24 22:21:52 +000027" 2) add this line to recognize groovy files by filename extension:
28"
29" au BufNewFile,BufRead *.groovy setf groovy
30" in the global vim filetype.vim file or inside $HOME/.vim/filetype.vim
31"
32" 3) add this part to recognize by content groovy script (no extension needed :-)
33"
34" if did_filetype()
35" finish
36" endif
37" if getline(1) =~ '^#!.*[/\\]groovy\>'
38" setf groovy
39" endif
40"
41" in the global scripts.vim file or in $HOME/.vim/scripts.vim
Bram Moolenaar6be7f872012-01-20 21:08:56 +010042"
Bram Moolenaarc01140a2006-03-24 22:21:52 +000043" 4) open/write a .groovy file or a groovy script :-)
44"
45" Let me know if you like it or send me patches, so that I can improve it
46" when I have time
47
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020048" quit when a syntax file was already loaded
Bram Moolenaarc01140a2006-03-24 22:21:52 +000049if !exists("main_syntax")
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020050 if exists("b:current_syntax")
Bram Moolenaarc01140a2006-03-24 22:21:52 +000051 finish
52 endif
53 " we define it here so that included files can test for it
54 let main_syntax='groovy'
55endif
56
Bram Moolenaar6be7f872012-01-20 21:08:56 +010057let s:cpo_save = &cpo
58set cpo&vim
59
Bram Moolenaarc01140a2006-03-24 22:21:52 +000060" ##########################
61" Java stuff taken from java.vim
62" some characters that cannot be in a groovy program (outside a string)
63" syn match groovyError "[\\@`]"
64"syn match groovyError "<<<\|\.\.\|=>\|<>\|||=\|&&=\|[^-]->\|\*\/"
65"syn match groovyOK "\.\.\."
66
67" keyword definitions
68syn keyword groovyExternal native package
Bram Moolenaarff034192013-04-24 18:51:19 +020069syn match groovyExternal "\<import\>\(\s\+static\>\)\?"
Bram Moolenaarc01140a2006-03-24 22:21:52 +000070syn keyword groovyError goto const
71syn keyword groovyConditional if else switch
72syn keyword groovyRepeat while for do
73syn keyword groovyBoolean true false
74syn keyword groovyConstant null
75syn keyword groovyTypedef this super
76syn keyword groovyOperator new instanceof
77syn keyword groovyType boolean char byte short int long float double
78syn keyword groovyType void
79syn keyword groovyType Integer Double Date Boolean Float String Array Vector List
80syn keyword groovyStatement return
81syn keyword groovyStorageClass static synchronized transient volatile final strictfp serializable
82syn keyword groovyExceptions throw try catch finally
83syn keyword groovyAssert assert
84syn keyword groovyMethodDecl synchronized throws
85syn keyword groovyClassDecl extends implements interface
86" to differentiate the keyword class from MyClass.class we use a match here
87syn match groovyTypedef "\.\s*\<class\>"ms=s+1
88syn keyword groovyClassDecl enum
89syn match groovyClassDecl "^class\>"
90syn match groovyClassDecl "[^.]\s*\<class\>"ms=s+1
91syn keyword groovyBranch break continue nextgroup=groovyUserLabelRef skipwhite
92syn match groovyUserLabelRef "\k\+" contained
93syn keyword groovyScopeDecl public protected private abstract
94
95
96if exists("groovy_highlight_groovy_lang_ids") || exists("groovy_highlight_groovy_lang") || exists("groovy_highlight_all")
97 " groovy.lang.*
98 syn keyword groovyLangClass Closure MetaMethod GroovyObject
Bram Moolenaar6be7f872012-01-20 21:08:56 +010099
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000100 syn match groovyJavaLangClass "\<System\>"
101 syn keyword groovyJavaLangClass Cloneable Comparable Runnable Serializable Boolean Byte Class Object
102 syn keyword groovyJavaLangClass Character CharSequence ClassLoader Compiler
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100103 " syn keyword groovyJavaLangClass Integer Double Float Long
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000104 syn keyword groovyJavaLangClass InheritableThreadLocal Math Number Object Package Process
105 syn keyword groovyJavaLangClass Runtime RuntimePermission InheritableThreadLocal
106 syn keyword groovyJavaLangClass SecurityManager Short StrictMath StackTraceElement
107 syn keyword groovyJavaLangClass StringBuffer Thread ThreadGroup
108 syn keyword groovyJavaLangClass ThreadLocal Throwable Void ArithmeticException
109 syn keyword groovyJavaLangClass ArrayIndexOutOfBoundsException AssertionError
110 syn keyword groovyJavaLangClass ArrayStoreException ClassCastException
111 syn keyword groovyJavaLangClass ClassNotFoundException
112 syn keyword groovyJavaLangClass CloneNotSupportedException Exception
113 syn keyword groovyJavaLangClass IllegalAccessException
114 syn keyword groovyJavaLangClass IllegalArgumentException
115 syn keyword groovyJavaLangClass IllegalMonitorStateException
116 syn keyword groovyJavaLangClass IllegalStateException
117 syn keyword groovyJavaLangClass IllegalThreadStateException
118 syn keyword groovyJavaLangClass IndexOutOfBoundsException
119 syn keyword groovyJavaLangClass InstantiationException InterruptedException
120 syn keyword groovyJavaLangClass NegativeArraySizeException NoSuchFieldException
121 syn keyword groovyJavaLangClass NoSuchMethodException NullPointerException
122 syn keyword groovyJavaLangClass NumberFormatException RuntimeException
123 syn keyword groovyJavaLangClass SecurityException StringIndexOutOfBoundsException
124 syn keyword groovyJavaLangClass UnsupportedOperationException
125 syn keyword groovyJavaLangClass AbstractMethodError ClassCircularityError
126 syn keyword groovyJavaLangClass ClassFormatError Error ExceptionInInitializerError
127 syn keyword groovyJavaLangClass IllegalAccessError InstantiationError
128 syn keyword groovyJavaLangClass IncompatibleClassChangeError InternalError
129 syn keyword groovyJavaLangClass LinkageError NoClassDefFoundError
130 syn keyword groovyJavaLangClass NoSuchFieldError NoSuchMethodError
131 syn keyword groovyJavaLangClass OutOfMemoryError StackOverflowError
132 syn keyword groovyJavaLangClass ThreadDeath UnknownError UnsatisfiedLinkError
133 syn keyword groovyJavaLangClass UnsupportedClassVersionError VerifyError
134 syn keyword groovyJavaLangClass VirtualMachineError
135
136 syn keyword groovyJavaLangObject clone equals finalize getClass hashCode
137 syn keyword groovyJavaLangObject notify notifyAll toString wait
138
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200139 hi def link groovyLangClass groovyConstant
140 hi def link groovyJavaLangClass groovyExternal
141 hi def link groovyJavaLangObject groovyConstant
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000142 syn cluster groovyTop add=groovyJavaLangObject,groovyJavaLangClass,groovyLangClass
143 syn cluster groovyClasses add=groovyJavaLangClass,groovyLangClass
144endif
145
146
147" Groovy stuff
148syn match groovyOperator "\.\."
149syn match groovyOperator "<\{2,3}"
150syn match groovyOperator ">\{2,3}"
151syn match groovyOperator "->"
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200152syn match groovyLineComment '^\%1l#!.*' " Shebang line
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000153syn match groovyExceptions "\<Exception\>\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>"
154
155" Groovy JDK stuff
156syn keyword groovyJDKBuiltin as def in
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100157syn keyword groovyJDKOperOverl div minus plus abs round power multiply
158syn keyword groovyJDKMethods each call inject sort print println
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000159syn keyword groovyJDKMethods getAt putAt size push pop toList getText writeLine eachLine readLines
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100160syn keyword groovyJDKMethods withReader withStream withWriter withPrintWriter write read leftShift
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000161syn keyword groovyJDKMethods withWriterAppend readBytes splitEachLine
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100162syn keyword groovyJDKMethods newInputStream newOutputStream newPrintWriter newReader newWriter
163syn keyword groovyJDKMethods compareTo next previous isCase
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000164syn keyword groovyJDKMethods times step toInteger upto any collect dump every find findAll grep
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100165syn keyword groovyJDKMethods inspect invokeMethods join
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000166syn keyword groovyJDKMethods getErr getIn getOut waitForOrKill
167syn keyword groovyJDKMethods count tokenize asList flatten immutable intersect reverse reverseEach
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100168syn keyword groovyJDKMethods subMap append asWritable eachByte eachLine eachFile
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000169syn cluster groovyTop add=groovyJDKBuiltin,groovyJDKOperOverl,groovyJDKMethods
170
171" no useful I think, so I comment it..
172"if filereadable(expand("<sfile>:p:h")."/groovyid.vim")
173 " source <sfile>:p:h/groovyid.vim
174"endif
175
176if exists("groovy_space_errors")
177 if !exists("groovy_no_trail_space_error")
178 syn match groovySpaceError "\s\+$"
179 endif
180 if !exists("groovy_no_tab_space_error")
181 syn match groovySpaceError " \+\t"me=e-1
182 endif
183endif
184
185" it is a better case construct than java.vim to match groovy syntax
186syn region groovyLabelRegion transparent matchgroup=groovyLabel start="\<case\>" matchgroup=NONE end=":\|$" contains=groovyNumber,groovyString,groovyLangClass,groovyJavaLangClass
187syn match groovyUserLabel "^\s*[_$a-zA-Z][_$a-zA-Z0-9_]*\s*:"he=e-1 contains=groovyLabel
188syn keyword groovyLabel default
189
190if !exists("groovy_allow_cpp_keywords")
191 syn keyword groovyError auto delete extern friend inline redeclared
192 syn keyword groovyError register signed sizeof struct template typedef union
193 syn keyword groovyError unsigned operator
194endif
195
196" The following cluster contains all groovy groups except the contained ones
197syn 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
198
199
200" Comments
201syn keyword groovyTodo contained TODO FIXME XXX
202if exists("groovy_comment_strings")
203 syn region groovyCommentString contained start=+"+ end=+"+ end=+$+ end=+\*/+me=s-1,he=s-1 contains=groovySpecial,groovyCommentStar,groovySpecialChar,@Spell
204 syn region groovyComment2String contained start=+"+ end=+$\|"+ contains=groovySpecial,groovySpecialChar,@Spell
205 syn match groovyCommentCharacter contained "'\\[^']\{1,6\}'" contains=groovySpecialChar
206 syn match groovyCommentCharacter contained "'\\''" contains=groovySpecialChar
207 syn match groovyCommentCharacter contained "'[^\\]'"
208 syn cluster groovyCommentSpecial add=groovyCommentString,groovyCommentCharacter,groovyNumber
209 syn cluster groovyCommentSpecial2 add=groovyComment2String,groovyCommentCharacter,groovyNumber
210endif
211syn region groovyComment start="/\*" end="\*/" contains=@groovyCommentSpecial,groovyTodo,@Spell
212syn match groovyCommentStar contained "^\s*\*[^/]"me=e-1
213syn match groovyCommentStar contained "^\s*\*$"
214syn match groovyLineComment "//.*" contains=@groovyCommentSpecial2,groovyTodo,@Spell
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200215hi def link groovyCommentString groovyString
216hi def link groovyComment2String groovyString
217hi def link groovyCommentCharacter groovyCharacter
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000218
219syn cluster groovyTop add=groovyComment,groovyLineComment
220
221if !exists("groovy_ignore_groovydoc") && main_syntax != 'jsp'
222 syntax case ignore
223 " syntax coloring for groovydoc comments (HTML)
224 " syntax include @groovyHtml <sfile>:p:h/html.vim
225 syntax include @groovyHtml runtime! syntax/html.vim
226 unlet b:current_syntax
Bram Moolenaar5c736222010-01-06 20:54:52 +0100227 syntax spell default " added by Bram
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000228 syn region groovyDocComment start="/\*\*" end="\*/" keepend contains=groovyCommentTitle,@groovyHtml,groovyDocTags,groovyTodo,@Spell
229 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
230
231 syn region groovyDocTags contained start="{@\(link\|linkplain\|inherit[Dd]oc\|doc[rR]oot\|value\)" end="}"
232 syn match groovyDocTags contained "@\(see\|param\|exception\|throws\|since\)\s\+\S\+" contains=groovyDocParam
233 syn match groovyDocParam contained "\s\S\+"
234 syn match groovyDocTags contained "@\(version\|author\|return\|deprecated\|serial\|serialField\|serialData\)\>"
235 syntax case match
236endif
237
238" match the special comment /**/
239syn match groovyComment "/\*\*/"
240
241" Strings and constants
242syn match groovySpecialError contained "\\."
243syn match groovySpecialCharError contained "[^']"
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100244syn match groovySpecialChar contained "\\\([4-9]\d\|[0-3]\d\d\|[\"\\'ntbrf]\|u\x\{4\}\|\$\)"
245syn match groovyRegexChar contained "\\."
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000246syn region groovyString start=+"+ end=+"+ end=+$+ contains=groovySpecialChar,groovySpecialError,@Spell,groovyELExpr
Bram Moolenaar81af9252010-12-10 20:35:50 +0100247syn region groovyString start=+'+ end=+'+ end=+$+ contains=groovySpecialChar,groovySpecialError,@Spell
248syn region groovyString start=+"""+ end=+"""+ contains=groovySpecialChar,groovySpecialError,@Spell,groovyELExpr
249syn region groovyString start=+'''+ end=+'''+ contains=groovySpecialChar,groovySpecialError,@Spell
Bram Moolenaar26852122016-05-24 20:02:38 +0200250if exists("groovy_regex_strings")
251 " regex strings interfere with the division operator and thus are disabled
252 " by default
253 syn region groovyString start='/[^/*]' end='/' contains=groovySpecialChar,groovyRegexChar,groovyELExpr
254endif
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000255" syn region groovyELExpr start=+${+ end=+}+ keepend contained
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100256syn match groovyELExpr /\${.\{-}}/ contained
Bram Moolenaar942db232021-02-13 18:14:48 +0100257" Fix: force use of the NFA regexp engine (2), see GitHub issue #7280
258syn match groovyELExpr /\%#=2\$[a-zA-Z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE_][a-zA-Z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE0-9_.]*/ contained
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200259hi def link groovyELExpr Identifier
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000260
261" TODO: better matching. I am waiting to understand how it really works in groovy
262" syn region groovyClosureParamsBraces start=+|+ end=+|+ contains=groovyClosureParams
263" syn match groovyClosureParams "[ a-zA-Z0-9_*]\+" contained
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200264" hi def link groovyClosureParams Identifier
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000265
266" next line disabled, it can cause a crash for a long line
267"syn match groovyStringError +"\([^"\\]\|\\.\)*$+
268
269" disabled: in groovy strings or characters are written the same
270" syn match groovyCharacter "'[^']*'" contains=groovySpecialChar,groovySpecialCharError
271" syn match groovyCharacter "'\\''" contains=groovySpecialChar
272" syn match groovyCharacter "'[^\\]'"
273syn match groovyNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
274syn match groovyNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
275syn match groovyNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
276syn match groovyNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
277
278" unicode characters
279syn match groovySpecial "\\u\d\{4\}"
280
281syn cluster groovyTop add=groovyString,groovyCharacter,groovyNumber,groovySpecial,groovyStringError
282
283if exists("groovy_highlight_functions")
284 if groovy_highlight_functions == "indent"
285 syn match groovyFuncDef "^\(\t\| \{8\}\)[_$a-zA-Z][_$a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
286 syn region groovyFuncDef start=+^\(\t\| \{8\}\)[$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
287 syn match groovyFuncDef "^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
288 syn region groovyFuncDef start=+^ [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
289 else
290 " This line catches method declarations at any indentation>0, but it assumes
291 " two things:
292 " 1. class names are always capitalized (ie: Button)
293 " 2. method names are never capitalized (except constructors, of course)
294 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
295 endif
296 syn match groovyBraces "[{}]"
297 syn cluster groovyTop add=groovyFuncDef,groovyBraces
298endif
299
300if exists("groovy_highlight_debug")
301
302 " Strings and constants
303 syn match groovyDebugSpecial contained "\\\d\d\d\|\\."
304 syn region groovyDebugString contained start=+"+ end=+"+ contains=groovyDebugSpecial
305 syn match groovyDebugStringError +"\([^"\\]\|\\.\)*$+
306 syn match groovyDebugCharacter contained "'[^\\]'"
307 syn match groovyDebugSpecialCharacter contained "'\\.'"
308 syn match groovyDebugSpecialCharacter contained "'\\''"
309 syn match groovyDebugNumber contained "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
310 syn match groovyDebugNumber contained "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
311 syn match groovyDebugNumber contained "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
312 syn match groovyDebugNumber contained "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
313 syn keyword groovyDebugBoolean contained true false
314 syn keyword groovyDebugType contained null this super
315 syn region groovyDebugParen start=+(+ end=+)+ contained contains=groovyDebug.*,groovyDebugParen
316
317 " to make this work you must define the highlighting for these groups
318 syn match groovyDebug "\<System\.\(out\|err\)\.print\(ln\)*\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
319 syn match groovyDebug "\<p\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
320 syn match groovyDebug "[A-Za-z][a-zA-Z0-9_]*\.printStackTrace\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
321 syn match groovyDebug "\<trace[SL]\=\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
322
323 syn cluster groovyTop add=groovyDebug
324
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200325 hi def link groovyDebug Debug
326 hi def link groovyDebugString DebugString
327 hi def link groovyDebugStringError groovyError
328 hi def link groovyDebugType DebugType
329 hi def link groovyDebugBoolean DebugBoolean
330 hi def link groovyDebugNumber Debug
331 hi def link groovyDebugSpecial DebugSpecial
332 hi def link groovyDebugSpecialCharacter DebugSpecial
333 hi def link groovyDebugCharacter DebugString
334 hi def link groovyDebugParen Debug
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100335
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200336 hi def link DebugString String
337 hi def link DebugSpecial Special
338 hi def link DebugBoolean Boolean
339 hi def link DebugType Type
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000340endif
341
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100342" Match all Exception classes
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000343syn match groovyExceptions "\<Exception\>\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>"
344
345
346if !exists("groovy_minlines")
347 let groovy_minlines = 10
348endif
349exec "syn sync ccomment groovyComment minlines=" . groovy_minlines
350
351
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100352" ###################
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000353" Groovy stuff
354" syn match groovyOperator "|[ ,a-zA-Z0-9_*]\+|"
355
356" All groovy valid tokens
357" syn match groovyTokens ";\|,\|<=>\|<>\|:\|:=\|>\|>=\|=\|==\|<\|<=\|!=\|/\|/=\|\.\.|\.\.\.\|\~=\|\~=="
358" syn match groovyTokens "\*=\|&\|&=\|\*\|->\|\~\|+\|-\|/\|?\|<<<\|>>>\|<<\|>>"
359
360" Must put explicit these ones because groovy.vim mark them as errors otherwise
361" syn match groovyTokens "<=>\|<>\|==\~"
362"syn cluster groovyTop add=groovyTokens
363
364" Mark these as operators
365
Viktor Szépe3fc7a7e2023-08-23 21:20:00 +0200366" Highlight brackets
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000367" syn match groovyBraces "[{}]"
368" syn match groovyBraces "[\[\]]"
369" syn match groovyBraces "[\|]"
370
371if exists("groovy_mark_braces_in_parens_as_errors")
372 syn match groovyInParen contained "[{}]"
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200373 hi def link groovyInParen groovyError
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000374 syn cluster groovyTop add=groovyInParen
375endif
376
377" catch errors caused by wrong parenthesis
378syn region groovyParenT transparent matchgroup=groovyParen start="(" end=")" contains=@groovyTop,groovyParenT1
379syn region groovyParenT1 transparent matchgroup=groovyParen1 start="(" end=")" contains=@groovyTop,groovyParenT2 contained
380syn region groovyParenT2 transparent matchgroup=groovyParen2 start="(" end=")" contains=@groovyTop,groovyParenT contained
381syn match groovyParenError ")"
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200382hi def link groovyParenError groovyError
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000383
384" catch errors caused by wrong square parenthesis
385syn region groovyParenT transparent matchgroup=groovyParen start="\[" end="\]" contains=@groovyTop,groovyParenT1
386syn region groovyParenT1 transparent matchgroup=groovyParen1 start="\[" end="\]" contains=@groovyTop,groovyParenT2 contained
387syn region groovyParenT2 transparent matchgroup=groovyParen2 start="\[" end="\]" contains=@groovyTop,groovyParenT contained
388syn match groovyParenError "\]"
389
390" ###############################
391" java.vim default highlighting
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200392hi def link groovyFuncDef Function
393hi def link groovyBraces Function
394hi def link groovyBranch Conditional
395hi def link groovyUserLabelRef groovyUserLabel
396hi def link groovyLabel Label
397hi def link groovyUserLabel Label
398hi def link groovyConditional Conditional
399hi def link groovyRepeat Repeat
400hi def link groovyExceptions Exception
401hi def link groovyAssert Statement
402hi def link groovyStorageClass StorageClass
403hi def link groovyMethodDecl groovyStorageClass
404hi def link groovyClassDecl groovyStorageClass
405hi def link groovyScopeDecl groovyStorageClass
406hi def link groovyBoolean Boolean
407hi def link groovySpecial Special
408hi def link groovySpecialError Error
409hi def link groovySpecialCharError Error
410hi def link groovyString String
411hi def link groovyRegexChar String
412hi def link groovyCharacter Character
413hi def link groovySpecialChar SpecialChar
414hi def link groovyNumber Number
415hi def link groovyError Error
416hi def link groovyStringError Error
417hi def link groovyStatement Statement
418hi def link groovyOperator Operator
419hi def link groovyComment Comment
420hi def link groovyDocComment Comment
421hi def link groovyLineComment Comment
422hi def link groovyConstant Constant
423hi def link groovyTypedef Typedef
424hi def link groovyTodo Todo
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100425
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200426hi def link groovyCommentTitle SpecialComment
427hi def link groovyDocTags Special
428hi def link groovyDocParam Function
429hi def link groovyCommentStar groovyComment
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100430
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200431hi def link groovyType Type
432hi def link groovyExternal Include
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100433
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200434hi def link htmlComment Special
435hi def link htmlCommentPart Special
436hi def link groovySpaceError Error
437hi def link groovyJDKBuiltin Special
438hi def link groovyJDKOperOverl Operator
439hi def link groovyJDKMethods Function
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000440
441
442let b:current_syntax = "groovy"
443if main_syntax == 'groovy'
444 unlet main_syntax
445endif
446
447let b:spell_options="contained"
448
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100449let &cpo = s:cpo_save
450unlet s:cpo_save
451
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000452" vim: ts=8