summaryrefslogtreecommitdiffstats
path: root/syntax/groovy.vim
blob: 9430f0ab523caa29a0a4763b2a6827db6c1065d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vim') == -1
  
" Vim syntax file
" Language:	Groovy
" Original Author:	Alessio Pace <billy.corgan@tiscali.it>
" Maintainer:	Tobias Rapp <yahuxo@gmx.de>
" Version: 	0.1.16
" URL:	  http://www.vim.org/scripts/script.php?script_id=945
" Last Change:	2016 May 23

" THE ORIGINAL AUTHOR'S NOTES:
"
" This is my very first vim script, I hope to have
" done it the right way.
"
" I must directly or indirectly thank the author of java.vim and ruby.vim:
" I copied from them most of the stuff :-)
"
" Relies on html.vim

" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
"
" HOWTO USE IT (INSTALL) when not part of the distribution:
"
" 1) copy the file in the (global or user's $HOME/.vim/syntax/) syntax folder
"
" 2) add this line to recognize groovy files by filename extension:
"
" au BufNewFile,BufRead *.groovy  setf groovy
" in the global vim filetype.vim file or inside $HOME/.vim/filetype.vim
"
" 3) add this part to recognize by content groovy script (no extension needed :-)
"
"  if did_filetype()
"    finish
"  endif
"  if getline(1) =~ '^#!.*[/\\]groovy\>'
"    setf groovy
"  endif
"
"  in the global scripts.vim file or in $HOME/.vim/scripts.vim
"
" 4) open/write a .groovy file or a groovy script :-)
"
" Let me know if you like it or send me patches, so that I can improve it
" when I have time

" quit when a syntax file was already loaded
if !exists("main_syntax")
  if exists("b:current_syntax")
    finish
  endif
  " we define it here so that included files can test for it
  let main_syntax='groovy'
endif

let s:cpo_save = &cpo
set cpo&vim

" ##########################
" Java stuff taken from java.vim
" some characters that cannot be in a groovy program (outside a string)
" syn match groovyError "[\\@`]"
"syn match groovyError "<<<\|\.\.\|=>\|<>\|||=\|&&=\|[^-]->\|\*\/"
"syn match groovyOK "\.\.\."

" keyword definitions
syn keyword groovyExternal        native package
syn match groovyExternal          "\<import\>\(\s\+static\>\)\?"
syn keyword groovyError           goto const
syn keyword groovyConditional     if else switch
syn keyword groovyRepeat          while for do
syn keyword groovyBoolean         true false
syn keyword groovyConstant        null
syn keyword groovyTypedef         this super
syn keyword groovyOperator        new instanceof
syn keyword groovyType            boolean char byte short int long float double
syn keyword groovyType            void
syn keyword groovyType		  Integer Double Date Boolean Float String Array Vector List
syn keyword groovyStatement       return
syn keyword groovyStorageClass    static synchronized transient volatile final strictfp serializable
syn keyword groovyExceptions      throw try catch finally
syn keyword groovyAssert          assert
syn keyword groovyMethodDecl      synchronized throws
syn keyword groovyClassDecl       extends implements interface
" to differentiate the keyword class from MyClass.class we use a match here
syn match   groovyTypedef         "\.\s*\<class\>"ms=s+1
syn keyword groovyClassDecl         enum
syn match   groovyClassDecl       "^class\>"
syn match   groovyClassDecl       "[^.]\s*\<class\>"ms=s+1
syn keyword groovyBranch          break continue nextgroup=groovyUserLabelRef skipwhite
syn match   groovyUserLabelRef    "\k\+" contained
syn keyword groovyScopeDecl       public protected private abstract


if exists("groovy_highlight_groovy_lang_ids") || exists("groovy_highlight_groovy_lang") || exists("groovy_highlight_all")
  " groovy.lang.*
  syn keyword groovyLangClass  Closure MetaMethod GroovyObject

  syn match groovyJavaLangClass "\<System\>"
  syn keyword groovyJavaLangClass  Cloneable Comparable Runnable Serializable Boolean Byte Class Object
  syn keyword groovyJavaLangClass  Character CharSequence ClassLoader Compiler
  " syn keyword groovyJavaLangClass  Integer Double Float Long
  syn keyword groovyJavaLangClass  InheritableThreadLocal Math Number Object Package Process
  syn keyword groovyJavaLangClass  Runtime RuntimePermission InheritableThreadLocal
  syn keyword groovyJavaLangClass  SecurityManager Short StrictMath StackTraceElement
  syn keyword groovyJavaLangClass  StringBuffer Thread ThreadGroup
  syn keyword groovyJavaLangClass  ThreadLocal Throwable Void ArithmeticException
  syn keyword groovyJavaLangClass  ArrayIndexOutOfBoundsException AssertionError
  syn keyword groovyJavaLangClass  ArrayStoreException ClassCastException
  syn keyword groovyJavaLangClass  ClassNotFoundException
  syn keyword groovyJavaLangClass  CloneNotSupportedException Exception
  syn keyword groovyJavaLangClass  IllegalAccessException
  syn keyword groovyJavaLangClass  IllegalArgumentException
  syn keyword groovyJavaLangClass  IllegalMonitorStateException
  syn keyword groovyJavaLangClass  IllegalStateException
  syn keyword groovyJavaLangClass  IllegalThreadStateException
  syn keyword groovyJavaLangClass  IndexOutOfBoundsException
  syn keyword groovyJavaLangClass  InstantiationException InterruptedException
  syn keyword groovyJavaLangClass  NegativeArraySizeException NoSuchFieldException
  syn keyword groovyJavaLangClass  NoSuchMethodException NullPointerException
  syn keyword groovyJavaLangClass  NumberFormatException RuntimeException
  syn keyword groovyJavaLangClass  SecurityException StringIndexOutOfBoundsException
  syn keyword groovyJavaLangClass  UnsupportedOperationException
  syn keyword groovyJavaLangClass  AbstractMethodError ClassCircularityError
  syn keyword groovyJavaLangClass  ClassFormatError Error ExceptionInInitializerError
  syn keyword groovyJavaLangClass  IllegalAccessError InstantiationError
  syn keyword groovyJavaLangClass  IncompatibleClassChangeError InternalError
  syn keyword groovyJavaLangClass  LinkageError NoClassDefFoundError
  syn keyword groovyJavaLangClass  NoSuchFieldError NoSuchMethodError
  syn keyword groovyJavaLangClass  OutOfMemoryError StackOverflowError
  syn keyword groovyJavaLangClass  ThreadDeath UnknownError UnsatisfiedLinkError
  syn keyword groovyJavaLangClass  UnsupportedClassVersionError VerifyError
  syn keyword groovyJavaLangClass  VirtualMachineError

  syn keyword groovyJavaLangObject clone equals finalize getClass hashCode
  syn keyword groovyJavaLangObject notify notifyAll toString wait

  hi def link groovyLangClass                   groovyConstant
  hi def link groovyJavaLangClass               groovyExternal
  hi def link groovyJavaLangObject              groovyConstant
  syn cluster groovyTop add=groovyJavaLangObject,groovyJavaLangClass,groovyLangClass
  syn cluster groovyClasses add=groovyJavaLangClass,groovyLangClass
endif


" Groovy stuff
syn match groovyOperator "\.\."
syn match groovyOperator "<\{2,3}"
syn match groovyOperator ">\{2,3}"
syn match groovyOperator "->"
syn match groovyLineComment       '^\%1l#!.*'  " Shebang line
syn match groovyExceptions        "\<Exception\>\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>"

" Groovy JDK stuff
syn keyword groovyJDKBuiltin    as def in
syn keyword groovyJDKOperOverl  div minus plus abs round power multiply
syn keyword groovyJDKMethods 	each call inject sort print println
syn keyword groovyJDKMethods    getAt putAt size push pop toList getText writeLine eachLine readLines
syn keyword groovyJDKMethods    withReader withStream withWriter withPrintWriter write read leftShift
syn keyword groovyJDKMethods    withWriterAppend readBytes splitEachLine
syn keyword groovyJDKMethods    newInputStream newOutputStream newPrintWriter newReader newWriter
syn keyword groovyJDKMethods    compareTo next previous isCase
syn keyword groovyJDKMethods    times step toInteger upto any collect dump every find findAll grep
syn keyword groovyJDKMethods    inspect invokeMethods join
syn keyword groovyJDKMethods    getErr getIn getOut waitForOrKill
syn keyword groovyJDKMethods    count tokenize asList flatten immutable intersect reverse reverseEach
syn keyword groovyJDKMethods    subMap append asWritable eachByte eachLine eachFile
syn cluster groovyTop add=groovyJDKBuiltin,groovyJDKOperOverl,groovyJDKMethods

" no useful I think, so I comment it..
"if filereadable(expand("<sfile>:p:h")."/groovyid.vim")
 " source <sfile>:p:h/groovyid.vim
"endif

if exists("groovy_space_errors")
  if !exists("groovy_no_trail_space_error")
    syn match   groovySpaceError  "\s\+$"
  endif
  if !exists("groovy_no_tab_space_error")
    syn match   groovySpaceError  " \+\t"me=e-1
  endif
endif

" it is a better case construct than java.vim to match groovy syntax
syn region  groovyLabelRegion     transparent matchgroup=groovyLabel start="\<case\>" matchgroup=NONE end=":\|$" contains=groovyNumber,groovyString,groovyLangClass,groovyJavaLangClass
syn match   groovyUserLabel       "^\s*[_$a-zA-Z][_$a-zA-Z0-9_]*\s*:"he=e-1 contains=groovyLabel
syn keyword groovyLabel           default

if !exists("groovy_allow_cpp_keywords")
  syn keyword groovyError auto delete extern friend inline redeclared
  syn keyword groovyError register signed sizeof struct template typedef union
  syn keyword groovyError unsigned operator
endif

" The following cluster contains all groovy groups except the contained ones
syn 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


" Comments
syn keyword groovyTodo             contained TODO FIXME XXX
if exists("groovy_comment_strings")
  syn region  groovyCommentString    contained start=+"+ end=+"+ end=+$+ end=+\*/+me=s-1,he=s-1 contains=groovySpecial,groovyCommentStar,groovySpecialChar,@Spell
  syn region  groovyComment2String   contained start=+"+  end=+$\|"+  contains=groovySpecial,groovySpecialChar,@Spell
  syn match   groovyCommentCharacter contained "'\\[^']\{1,6\}'" contains=groovySpecialChar
  syn match   groovyCommentCharacter contained "'\\''" contains=groovySpecialChar
  syn match   groovyCommentCharacter contained "'[^\\]'"
  syn cluster groovyCommentSpecial add=groovyCommentString,groovyCommentCharacter,groovyNumber
  syn cluster groovyCommentSpecial2 add=groovyComment2String,groovyCommentCharacter,groovyNumber
endif
syn region  groovyComment          start="/\*"  end="\*/" contains=@groovyCommentSpecial,groovyTodo,@Spell
syn match   groovyCommentStar      contained "^\s*\*[^/]"me=e-1
syn match   groovyCommentStar      contained "^\s*\*$"
syn match   groovyLineComment      "//.*" contains=@groovyCommentSpecial2,groovyTodo,@Spell
hi def link groovyCommentString groovyString
hi def link groovyComment2String groovyString
hi def link groovyCommentCharacter groovyCharacter

syn cluster groovyTop add=groovyComment,groovyLineComment

if !exists("groovy_ignore_groovydoc") && main_syntax != 'jsp'
  syntax case ignore
  " syntax coloring for groovydoc comments (HTML)
  " syntax include @groovyHtml <sfile>:p:h/html.vim
   syntax include @groovyHtml runtime! syntax/html.vim
  unlet b:current_syntax
  syntax spell default  " added by Bram
  syn region  groovyDocComment    start="/\*\*"  end="\*/" keepend contains=groovyCommentTitle,@groovyHtml,groovyDocTags,groovyTodo,@Spell
  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

  syn region groovyDocTags  contained start="{@\(link\|linkplain\|inherit[Dd]oc\|doc[rR]oot\|value\)" end="}"
  syn match  groovyDocTags  contained "@\(see\|param\|exception\|throws\|since\)\s\+\S\+" contains=groovyDocParam
  syn match  groovyDocParam contained "\s\S\+"
  syn match  groovyDocTags  contained "@\(version\|author\|return\|deprecated\|serial\|serialField\|serialData\)\>"
  syntax case match
endif

" match the special comment /**/
syn match   groovyComment          "/\*\*/"

" Strings and constants
syn match   groovySpecialError     contained "\\."
syn match   groovySpecialCharError contained "[^']"
syn match   groovySpecialChar      contained "\\\([4-9]\d\|[0-3]\d\d\|[\"\\'ntbrf]\|u\x\{4\}\|\$\)"
syn match   groovyRegexChar        contained "\\."
syn region  groovyString          start=+"+ end=+"+ end=+$+ contains=groovySpecialChar,groovySpecialError,@Spell,groovyELExpr
syn region  groovyString          start=+'+ end=+'+ end=+$+ contains=groovySpecialChar,groovySpecialError,@Spell
syn region  groovyString          start=+"""+ end=+"""+ contains=groovySpecialChar,groovySpecialError,@Spell,groovyELExpr
syn region  groovyString          start=+'''+ end=+'''+ contains=groovySpecialChar,groovySpecialError,@Spell
if exists("groovy_regex_strings")
  " regex strings interfere with the division operator and thus are disabled
  " by default
  syn region groovyString         start='/[^/*]' end='/' contains=groovySpecialChar,groovyRegexChar,groovyELExpr
endif
" syn region groovyELExpr start=+${+ end=+}+ keepend contained
syn match groovyELExpr /\${.\{-}}/ contained
syn match groovyELExpr /\$[a-zA-Z_][a-zA-Z0-9_.]*/ contained
hi def link groovyELExpr Identifier

" TODO: better matching. I am waiting to understand how it really works in groovy
" syn region  groovyClosureParamsBraces          start=+|+ end=+|+ contains=groovyClosureParams
" syn match groovyClosureParams	"[ a-zA-Z0-9_*]\+" contained
" hi def link groovyClosureParams Identifier

" next line disabled, it can cause a crash for a long line
"syn match   groovyStringError      +"\([^"\\]\|\\.\)*$+

" disabled: in groovy strings or characters are written the same
" syn match   groovyCharacter        "'[^']*'" contains=groovySpecialChar,groovySpecialCharError
" syn match   groovyCharacter        "'\\''" contains=groovySpecialChar
" syn match   groovyCharacter        "'[^\\]'"
syn match   groovyNumber           "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
syn match   groovyNumber           "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
syn match   groovyNumber           "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
syn match   groovyNumber           "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"

" unicode characters
syn match   groovySpecial "\\u\d\{4\}"

syn cluster groovyTop add=groovyString,groovyCharacter,groovyNumber,groovySpecial,groovyStringError

if exists("groovy_highlight_functions")
  if groovy_highlight_functions == "indent"
    syn match  groovyFuncDef "^\(\t\| \{8\}\)[_$a-zA-Z][_$a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
    syn region groovyFuncDef start=+^\(\t\| \{8\}\)[$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
    syn match  groovyFuncDef "^  [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
    syn region groovyFuncDef start=+^  [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
  else
    " This line catches method declarations at any indentation>0, but it assumes
    " two things:
    "   1. class names are always capitalized (ie: Button)
    "   2. method names are never capitalized (except constructors, of course)
    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
  endif
  syn match  groovyBraces  "[{}]"
  syn cluster groovyTop add=groovyFuncDef,groovyBraces
endif

if exists("groovy_highlight_debug")

  " Strings and constants
  syn match   groovyDebugSpecial          contained "\\\d\d\d\|\\."
  syn region  groovyDebugString           contained start=+"+  end=+"+  contains=groovyDebugSpecial
  syn match   groovyDebugStringError      +"\([^"\\]\|\\.\)*$+
  syn match   groovyDebugCharacter        contained "'[^\\]'"
  syn match   groovyDebugSpecialCharacter contained "'\\.'"
  syn match   groovyDebugSpecialCharacter contained "'\\''"
  syn match   groovyDebugNumber           contained "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
  syn match   groovyDebugNumber           contained "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
  syn match   groovyDebugNumber           contained "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
  syn match   groovyDebugNumber           contained "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
  syn keyword groovyDebugBoolean          contained true false
  syn keyword groovyDebugType             contained null this super
  syn region groovyDebugParen  start=+(+ end=+)+ contained contains=groovyDebug.*,groovyDebugParen

  " to make this work you must define the highlighting for these groups
  syn match groovyDebug "\<System\.\(out\|err\)\.print\(ln\)*\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
  syn match groovyDebug "\<p\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
  syn match groovyDebug "[A-Za-z][a-zA-Z0-9_]*\.printStackTrace\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
  syn match groovyDebug "\<trace[SL]\=\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen

  syn cluster groovyTop add=groovyDebug

  hi def link groovyDebug                 Debug
  hi def link groovyDebugString           DebugString
  hi def link groovyDebugStringError      groovyError
  hi def link groovyDebugType             DebugType
  hi def link groovyDebugBoolean          DebugBoolean
  hi def link groovyDebugNumber           Debug
  hi def link groovyDebugSpecial          DebugSpecial
  hi def link groovyDebugSpecialCharacter DebugSpecial
  hi def link groovyDebugCharacter        DebugString
  hi def link groovyDebugParen            Debug

  hi def link DebugString               String
  hi def link DebugSpecial              Special
  hi def link DebugBoolean              Boolean
  hi def link DebugType                 Type
endif

" Match all Exception classes
syn match groovyExceptions        "\<Exception\>\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>"


if !exists("groovy_minlines")
  let groovy_minlines = 10
endif
exec "syn sync ccomment groovyComment minlines=" . groovy_minlines


" ###################
" Groovy stuff
" syn match groovyOperator		"|[ ,a-zA-Z0-9_*]\+|"

" All groovy valid tokens
" syn match groovyTokens ";\|,\|<=>\|<>\|:\|:=\|>\|>=\|=\|==\|<\|<=\|!=\|/\|/=\|\.\.|\.\.\.\|\~=\|\~=="
" syn match groovyTokens "\*=\|&\|&=\|\*\|->\|\~\|+\|-\|/\|?\|<<<\|>>>\|<<\|>>"

" Must put explicit these ones because groovy.vim mark them as errors otherwise
" syn match groovyTokens "<=>\|<>\|==\~"
"syn cluster groovyTop add=groovyTokens

" Mark these as operators

" Hightlight brackets
" syn match  groovyBraces		"[{}]"
" syn match  groovyBraces		"[\[\]]"
" syn match  groovyBraces		"[\|]"

if exists("groovy_mark_braces_in_parens_as_errors")
  syn match groovyInParen          contained "[{}]"
  hi def link groovyInParen        groovyError
  syn cluster groovyTop add=groovyInParen
endif

" catch errors caused by wrong parenthesis
syn region  groovyParenT  transparent matchgroup=groovyParen  start="("  end=")" contains=@groovyTop,groovyParenT1
syn region  groovyParenT1 transparent matchgroup=groovyParen1 start="(" end=")" contains=@groovyTop,groovyParenT2 contained
syn region  groovyParenT2 transparent matchgroup=groovyParen2 start="(" end=")" contains=@groovyTop,groovyParenT  contained
syn match   groovyParenError       ")"
hi def link groovyParenError       groovyError

" catch errors caused by wrong square parenthesis
syn region  groovyParenT  transparent matchgroup=groovyParen  start="\["  end="\]" contains=@groovyTop,groovyParenT1
syn region  groovyParenT1 transparent matchgroup=groovyParen1 start="\[" end="\]" contains=@groovyTop,groovyParenT2 contained
syn region  groovyParenT2 transparent matchgroup=groovyParen2 start="\[" end="\]" contains=@groovyTop,groovyParenT  contained
syn match   groovyParenError       "\]"

" ###############################
" java.vim default highlighting
hi def link groovyFuncDef		Function
hi def link groovyBraces		Function
hi def link groovyBranch		Conditional
hi def link groovyUserLabelRef	groovyUserLabel
hi def link groovyLabel		Label
hi def link groovyUserLabel		Label
hi def link groovyConditional	Conditional
hi def link groovyRepeat		Repeat
hi def link groovyExceptions		Exception
hi def link groovyAssert 		Statement
hi def link groovyStorageClass	StorageClass
hi def link groovyMethodDecl		groovyStorageClass
hi def link groovyClassDecl		groovyStorageClass
hi def link groovyScopeDecl		groovyStorageClass
hi def link groovyBoolean		Boolean
hi def link groovySpecial		Special
hi def link groovySpecialError	Error
hi def link groovySpecialCharError	Error
hi def link groovyString		String
hi def link groovyRegexChar		String
hi def link groovyCharacter		Character
hi def link groovySpecialChar	SpecialChar
hi def link groovyNumber		Number
hi def link groovyError		Error
hi def link groovyStringError	Error
hi def link groovyStatement		Statement
hi def link groovyOperator		Operator
hi def link groovyComment		Comment
hi def link groovyDocComment		Comment
hi def link groovyLineComment	Comment
hi def link groovyConstant		Constant
hi def link groovyTypedef		Typedef
hi def link groovyTodo		Todo

hi def link groovyCommentTitle	SpecialComment
hi def link groovyDocTags		Special
hi def link groovyDocParam		Function
hi def link groovyCommentStar	groovyComment

hi def link groovyType		Type
hi def link groovyExternal		Include

hi def link htmlComment		Special
hi def link htmlCommentPart		Special
hi def link groovySpaceError		Error
hi def link groovyJDKBuiltin         Special
hi def link groovyJDKOperOverl       Operator
hi def link groovyJDKMethods         Function


let b:current_syntax = "groovy"
if main_syntax == 'groovy'
  unlet main_syntax
endif

let b:spell_options="contained"

let &cpo = s:cpo_save
unlet s:cpo_save

" vim: ts=8

endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'groovy') == -1
  
" Vim syntax file
" Language:	Groovy
" Maintainer:	Alessio Pace <billy.corgan@tiscali.it>
" Version: 	0.1.9b
" URL:	  http://www.vim.org/scripts/script.php?script_id=945	
" Last Change:	6/4/2004

" This is my very first vim script, I hope to have
" done it the right way.
" 
" I must directly or indirectly thank the author of java.vim and ruby.vim:
" I copied from them most of the stuff :-)
"
" Relies on html.vim

" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
"
" HOWTO USE IT (INSTALL):
" [groovy is still not recognized by vim! :-( ]
"
" 1) copy the file in the (global or user's $HOME/.vim/syntax/) syntax folder
" 
" 2) add this line to recognize groovy files by filename extension:
"
" au BufNewFile,BufRead *.groovy  setf groovy
" in the global vim filetype.vim file or inside $HOME/.vim/filetype.vim
"
" 3) add this part to recognize by content groovy script (no extension needed :-)
"
"  if did_filetype()
"    finish
"  endif
"  if getline(1) =~ '^#!.*[/\\]groovy\>'
"    setf groovy
"  endif
"
"  in the global scripts.vim file or in $HOME/.vim/scripts.vim
" 
" 4) open/write a .groovy file or a groovy script :-)
"
" Let me know if you like it or send me patches, so that I can improve it
" when I have time

" Quit when a syntax file was already loaded
if !exists("main_syntax")
  if version < 600
    syntax clear
  elseif exists("b:current_syntax")
    finish
  endif
  " we define it here so that included files can test for it
  let main_syntax='groovy'
endif

" don't use standard HiLink, it will not work with included syntax files
if version < 508
  command! -nargs=+ GroovyHiLink hi link <args>
else
  command! -nargs=+ GroovyHiLink hi def link <args>
endif

" ##########################
" Java stuff taken from java.vim
" some characters that cannot be in a groovy program (outside a string)
" syn match groovyError "[\\@`]"
"syn match groovyError "<<<\|\.\.\|=>\|<>\|||=\|&&=\|[^-]->\|\*\/"
"syn match groovyOK "\.\.\."

" keyword definitions
syn keyword groovyExternal        native package
syn match groovyExternal          "\<import\(\s\+static\>\)\?"
syn keyword groovyError           goto const
syn keyword groovyConditional     if else switch
syn keyword groovyRepeat          while for do
syn keyword groovyBoolean         true false
syn keyword groovyConstant        null
syn keyword groovyTypedef         this super
syn keyword groovyOperator        new instanceof
syn keyword groovyType            boolean char byte short int long float double
syn keyword groovyType            void
syn keyword groovyType		  Integer Double Date Boolean Float String Array Vector List
syn keyword groovyStatement       return
syn keyword groovyStorageClass    static synchronized transient volatile final strictfp serializable
syn keyword groovyExceptions      throw try catch finally
syn keyword groovyAssert          assert
syn keyword groovyMethodDecl      synchronized throws
syn keyword groovyClassDecl       extends implements interface
" to differentiate the keyword class from MyClass.class we use a match here
syn match   groovyTypedef         "\.\s*\<class\>"ms=s+1
syn keyword groovyClassDecl         enum
syn match   groovyClassDecl       "^class\>"
syn match   groovyClassDecl       "[^.]\s*\<class\>"ms=s+1
syn keyword groovyBranch          break continue nextgroup=groovyUserLabelRef skipwhite
syn match   groovyUserLabelRef    "\k\+" contained
syn keyword groovyScopeDecl       public protected private abstract


if exists("groovy_highlight_groovy_lang_ids") || exists("groovy_highlight_groovy_lang") || exists("groovy_highlight_all")
  " groovy.lang.*
  syn keyword groovyLangClass  Closure MetaMethod GroovyObject
  
  syn match groovyJavaLangClass "\<System\>"
  syn keyword groovyJavaLangClass  Cloneable Comparable Runnable Serializable Boolean Byte Class Object
  syn keyword groovyJavaLangClass  Character CharSequence ClassLoader Compiler
  " syn keyword groovyJavaLangClass  Integer Double Float Long 
  syn keyword groovyJavaLangClass  InheritableThreadLocal Math Number Object Package Process
  syn keyword groovyJavaLangClass  Runtime RuntimePermission InheritableThreadLocal
  syn keyword groovyJavaLangClass  SecurityManager Short StrictMath StackTraceElement
  syn keyword groovyJavaLangClass  StringBuffer Thread ThreadGroup
  syn keyword groovyJavaLangClass  ThreadLocal Throwable Void ArithmeticException
  syn keyword groovyJavaLangClass  ArrayIndexOutOfBoundsException AssertionError
  syn keyword groovyJavaLangClass  ArrayStoreException ClassCastException
  syn keyword groovyJavaLangClass  ClassNotFoundException
  syn keyword groovyJavaLangClass  CloneNotSupportedException Exception
  syn keyword groovyJavaLangClass  IllegalAccessException
  syn keyword groovyJavaLangClass  IllegalArgumentException
  syn keyword groovyJavaLangClass  IllegalMonitorStateException
  syn keyword groovyJavaLangClass  IllegalStateException
  syn keyword groovyJavaLangClass  IllegalThreadStateException
  syn keyword groovyJavaLangClass  IndexOutOfBoundsException
  syn keyword groovyJavaLangClass  InstantiationException InterruptedException
  syn keyword groovyJavaLangClass  NegativeArraySizeException NoSuchFieldException
  syn keyword groovyJavaLangClass  NoSuchMethodException NullPointerException
  syn keyword groovyJavaLangClass  NumberFormatException RuntimeException
  syn keyword groovyJavaLangClass  SecurityException StringIndexOutOfBoundsException
  syn keyword groovyJavaLangClass  UnsupportedOperationException
  syn keyword groovyJavaLangClass  AbstractMethodError ClassCircularityError
  syn keyword groovyJavaLangClass  ClassFormatError Error ExceptionInInitializerError
  syn keyword groovyJavaLangClass  IllegalAccessError InstantiationError
  syn keyword groovyJavaLangClass  IncompatibleClassChangeError InternalError
  syn keyword groovyJavaLangClass  LinkageError NoClassDefFoundError
  syn keyword groovyJavaLangClass  NoSuchFieldError NoSuchMethodError
  syn keyword groovyJavaLangClass  OutOfMemoryError StackOverflowError
  syn keyword groovyJavaLangClass  ThreadDeath UnknownError UnsatisfiedLinkError
  syn keyword groovyJavaLangClass  UnsupportedClassVersionError VerifyError
  syn keyword groovyJavaLangClass  VirtualMachineError

  syn keyword groovyJavaLangObject clone equals finalize getClass hashCode
  syn keyword groovyJavaLangObject notify notifyAll toString wait

  GroovyHiLink groovyLangClass                   groovyConstant
  GroovyHiLink groovyJavaLangClass               groovyExternal
  GroovyHiLink groovyJavaLangObject              groovyConstant
  syn cluster groovyTop add=groovyJavaLangObject,groovyJavaLangClass,groovyLangClass
  syn cluster groovyClasses add=groovyJavaLangClass,groovyLangClass
endif


" Groovy stuff
syn match groovyOperator "\.\."
syn match groovyOperator "<\{2,3}"
syn match groovyOperator ">\{2,3}"
syn match groovyOperator "->"
syn match groovyExternal		'^#!.*[/\\]groovy\>'
syn match groovyExceptions        "\<Exception\>\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>"

" Groovy JDK stuff
syn keyword groovyJDKBuiltin    as def in
syn keyword groovyJDKOperOverl  div minus plus abs round power multiply 
syn keyword groovyJDKMethods 	each call inject sort print println 
syn keyword groovyJDKMethods    getAt putAt size push pop toList getText writeLine eachLine readLines
syn keyword groovyJDKMethods    withReader withStream withWriter withPrintWriter write read leftShift 
syn keyword groovyJDKMethods    withWriterAppend readBytes splitEachLine
syn keyword groovyJDKMethods    newInputStream newOutputStream newPrintWriter newReader newWriter 
syn keyword groovyJDKMethods    compareTo next previous isCase 
syn keyword groovyJDKMethods    times step toInteger upto any collect dump every find findAll grep
syn keyword groovyJDKMethods    inspect invokeMethods join 
syn keyword groovyJDKMethods    getErr getIn getOut waitForOrKill
syn keyword groovyJDKMethods    count tokenize asList flatten immutable intersect reverse reverseEach
syn keyword groovyJDKMethods    subMap append asWritable eachByte eachLine eachFile 
syn cluster groovyTop add=groovyJDKBuiltin,groovyJDKOperOverl,groovyJDKMethods

" no useful I think, so I comment it..
"if filereadable(expand("<sfile>:p:h")."/groovyid.vim")
 " source <sfile>:p:h/groovyid.vim
"endif

if exists("groovy_space_errors")
  if !exists("groovy_no_trail_space_error")
    syn match   groovySpaceError  "\s\+$"
  endif
  if !exists("groovy_no_tab_space_error")
    syn match   groovySpaceError  " \+\t"me=e-1
  endif
endif

" it is a better case construct than java.vim to match groovy syntax
syn region  groovyLabelRegion     transparent matchgroup=groovyLabel start="\<case\>" matchgroup=NONE end=":\|$" contains=groovyNumber,groovyString,groovyLangClass,groovyJavaLangClass
syn match   groovyUserLabel       "^\s*[_$a-zA-Z][_$a-zA-Z0-9_]*\s*:"he=e-1 contains=groovyLabel
syn keyword groovyLabel           default

if !exists("groovy_allow_cpp_keywords")
  syn keyword groovyError auto delete extern friend inline redeclared
  syn keyword groovyError register signed sizeof struct template typedef union
  syn keyword groovyError unsigned operator
endif

" The following cluster contains all groovy groups except the contained ones
syn 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


" Comments
syn keyword groovyTodo             contained TODO FIXME XXX
if exists("groovy_comment_strings")
  syn region  groovyCommentString    contained start=+"+ end=+"+ end=+$+ end=+\*/+me=s-1,he=s-1 contains=groovySpecial,groovyCommentStar,groovySpecialChar,@Spell
  syn region  groovyComment2String   contained start=+"+  end=+$\|"+  contains=groovySpecial,groovySpecialChar,@Spell
  syn match   groovyCommentCharacter contained "'\\[^']\{1,6\}'" contains=groovySpecialChar
  syn match   groovyCommentCharacter contained "'\\''" contains=groovySpecialChar
  syn match   groovyCommentCharacter contained "'[^\\]'"
  syn cluster groovyCommentSpecial add=groovyCommentString,groovyCommentCharacter,groovyNumber
  syn cluster groovyCommentSpecial2 add=groovyComment2String,groovyCommentCharacter,groovyNumber
endif
syn region  groovyComment          start="/\*"  end="\*/" contains=@groovyCommentSpecial,groovyTodo,@Spell
syn match   groovyCommentStar      contained "^\s*\*[^/]"me=e-1
syn match   groovyCommentStar      contained "^\s*\*$"
syn match   groovyLineComment      "//.*" contains=@groovyCommentSpecial2,groovyTodo,@Spell
syn match   groovyLineComment      "#.*" contains=@groovyCommentSpecial2,groovyTodo,@Spell
GroovyHiLink groovyCommentString groovyString
GroovyHiLink groovyComment2String groovyString
GroovyHiLink groovyCommentCharacter groovyCharacter

syn cluster groovyTop add=groovyComment,groovyLineComment

if !exists("groovy_ignore_groovydoc") && main_syntax != 'jsp'
  syntax case ignore
  " syntax coloring for groovydoc comments (HTML)
  " syntax include @groovyHtml <sfile>:p:h/html.vim
   syntax include @groovyHtml runtime! syntax/html.vim
  unlet b:current_syntax
  syn region  groovyDocComment    start="/\*\*"  end="\*/" keepend contains=groovyCommentTitle,@groovyHtml,groovyDocTags,groovyTodo,@Spell
  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

  syn region groovyDocTags  contained start="{@\(link\|linkplain\|inherit[Dd]oc\|doc[rR]oot\|value\)" end="}"
  syn match  groovyDocTags  contained "@\(see\|param\|exception\|throws\|since\)\s\+\S\+" contains=groovyDocParam
  syn match  groovyDocParam contained "\s\S\+"
  syn match  groovyDocTags  contained "@\(version\|author\|return\|deprecated\|serial\|serialField\|serialData\)\>"
  syntax case match
endif

" match the special comment /**/
syn match   groovyComment          "/\*\*/"

" Strings and constants
syn match   groovySpecialError     contained "\\."
syn match   groovySpecialCharError contained "[^']"
syn match   groovySpecialChar      contained "\\\([4-9]\d\|[0-3]\d\d\|[\"\\'ntbrf]\|u\x\{4\}\)"
syn region  groovyString          start=+"+ end=+"+ end=+$+ contains=groovySpecialChar,groovySpecialError,@Spell,groovyELExpr
syn region  groovyString          start=+'+ end=+'+ end=+$+ contains=groovySpecialChar,groovySpecialError,@Spell,groovyELExpr
" syn region groovyELExpr start=+${+ end=+}+ keepend contained
 syn match groovyELExpr /\${.\{-}}/ contained
GroovyHiLink groovyELExpr Identifier

" TODO: better matching. I am waiting to understand how it really works in groovy
" syn region  groovyClosureParamsBraces          start=+|+ end=+|+ contains=groovyClosureParams
" syn match groovyClosureParams	"[ a-zA-Z0-9_*]\+" contained
" GroovyHiLink groovyClosureParams Identifier

" next line disabled, it can cause a crash for a long line
"syn match   groovyStringError      +"\([^"\\]\|\\.\)*$+

" disabled: in groovy strings or characters are written the same
" syn match   groovyCharacter        "'[^']*'" contains=groovySpecialChar,groovySpecialCharError
" syn match   groovyCharacter        "'\\''" contains=groovySpecialChar
" syn match   groovyCharacter        "'[^\\]'"
syn match   groovyNumber           "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
syn match   groovyNumber           "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
syn match   groovyNumber           "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
syn match   groovyNumber           "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"

" unicode characters
syn match   groovySpecial "\\u\d\{4\}"

syn cluster groovyTop add=groovyString,groovyCharacter,groovyNumber,groovySpecial,groovyStringError

if exists("groovy_highlight_functions")
  if groovy_highlight_functions == "indent"
    syn match  groovyFuncDef "^\(\t\| \{8\}\)[_$a-zA-Z][_$a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
    syn region groovyFuncDef start=+^\(\t\| \{8\}\)[$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
    syn match  groovyFuncDef "^  [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*)" contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
    syn region groovyFuncDef start=+^  [$_a-zA-Z][$_a-zA-Z0-9_. \[\]]*([^-+*/()]*,\s*+ end=+)+ contains=groovyScopeDecl,groovyType,groovyStorageClass,@groovyClasses
  else
    " This line catches method declarations at any indentation>0, but it assumes
    " two things:
    "   1. class names are always capitalized (ie: Button)
    "   2. method names are never capitalized (except constructors, of course)
    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
  endif
  syn match  groovyBraces  "[{}]"
  syn cluster groovyTop add=groovyFuncDef,groovyBraces
endif

if exists("groovy_highlight_debug")

  " Strings and constants
  syn match   groovyDebugSpecial          contained "\\\d\d\d\|\\."
  syn region  groovyDebugString           contained start=+"+  end=+"+  contains=groovyDebugSpecial
  syn match   groovyDebugStringError      +"\([^"\\]\|\\.\)*$+
  syn match   groovyDebugCharacter        contained "'[^\\]'"
  syn match   groovyDebugSpecialCharacter contained "'\\.'"
  syn match   groovyDebugSpecialCharacter contained "'\\''"
  syn match   groovyDebugNumber           contained "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
  syn match   groovyDebugNumber           contained "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
  syn match   groovyDebugNumber           contained "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
  syn match   groovyDebugNumber           contained "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
  syn keyword groovyDebugBoolean          contained true false
  syn keyword groovyDebugType             contained null this super
  syn region groovyDebugParen  start=+(+ end=+)+ contained contains=groovyDebug.*,groovyDebugParen

  " to make this work you must define the highlighting for these groups
  syn match groovyDebug "\<System\.\(out\|err\)\.print\(ln\)*\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
  syn match groovyDebug "\<p\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
  syn match groovyDebug "[A-Za-z][a-zA-Z0-9_]*\.printStackTrace\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen
  syn match groovyDebug "\<trace[SL]\=\s*("me=e-1 contains=groovyDebug.* nextgroup=groovyDebugParen

  syn cluster groovyTop add=groovyDebug

  if version >= 508 || !exists("did_c_syn_inits")
    GroovyHiLink groovyDebug                 Debug
    GroovyHiLink groovyDebugString           DebugString
    GroovyHiLink groovyDebugStringError      groovyError
    GroovyHiLink groovyDebugType             DebugType
    GroovyHiLink groovyDebugBoolean          DebugBoolean
    GroovyHiLink groovyDebugNumber           Debug
    GroovyHiLink groovyDebugSpecial          DebugSpecial
    GroovyHiLink groovyDebugSpecialCharacter DebugSpecial
    GroovyHiLink groovyDebugCharacter        DebugString
    GroovyHiLink groovyDebugParen            Debug
  
    GroovyHiLink DebugString               String
    GroovyHiLink DebugSpecial              Special
    GroovyHiLink DebugBoolean              Boolean
    GroovyHiLink DebugType                 Type
  endif
endif

" Match all Exception classes 
syn match groovyExceptions        "\<Exception\>\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>"


if !exists("groovy_minlines")
  let groovy_minlines = 10
endif
exec "syn sync ccomment groovyComment minlines=" . groovy_minlines


" ################### 
" Groovy stuff
" syn match groovyOperator		"|[ ,a-zA-Z0-9_*]\+|"

" All groovy valid tokens
" syn match groovyTokens ";\|,\|<=>\|<>\|:\|:=\|>\|>=\|=\|==\|<\|<=\|!=\|/\|/=\|\.\.|\.\.\.\|\~=\|\~=="
" syn match groovyTokens "\*=\|&\|&=\|\*\|->\|\~\|+\|-\|/\|?\|<<<\|>>>\|<<\|>>"

" Must put explicit these ones because groovy.vim mark them as errors otherwise
" syn match groovyTokens "<=>\|<>\|==\~"
"syn cluster groovyTop add=groovyTokens

" Mark these as operators

" Hightlight brackets
" syn match  groovyBraces		"[{}]"
" syn match  groovyBraces		"[\[\]]"
" syn match  groovyBraces		"[\|]"

if exists("groovy_mark_braces_in_parens_as_errors")
  syn match groovyInParen          contained "[{}]"
  GroovyHiLink groovyInParen        groovyError
  syn cluster groovyTop add=groovyInParen
endif

" catch errors caused by wrong parenthesis
syn region  groovyParenT  transparent matchgroup=groovyParen  start="("  end=")" contains=@groovyTop,groovyParenT1
syn region  groovyParenT1 transparent matchgroup=groovyParen1 start="(" end=")" contains=@groovyTop,groovyParenT2 contained
syn region  groovyParenT2 transparent matchgroup=groovyParen2 start="(" end=")" contains=@groovyTop,groovyParenT  contained
syn match   groovyParenError       ")"
GroovyHiLink groovyParenError       groovyError

" catch errors caused by wrong square parenthesis
syn region  groovyParenT  transparent matchgroup=groovyParen  start="\["  end="\]" contains=@groovyTop,groovyParenT1
syn region  groovyParenT1 transparent matchgroup=groovyParen1 start="\[" end="\]" contains=@groovyTop,groovyParenT2 contained
syn region  groovyParenT2 transparent matchgroup=groovyParen2 start="\[" end="\]" contains=@groovyTop,groovyParenT  contained
syn match   groovyParenError       "\]"

" ###############################
" java.vim default highlighting
if version >= 508 || !exists("did_groovy_syn_inits")
  if version < 508
    let did_groovy_syn_inits = 1
  endif
  GroovyHiLink groovyFuncDef		Function
  GroovyHiLink groovyBraces		Function
  GroovyHiLink groovyBranch		Conditional
  GroovyHiLink groovyUserLabelRef	groovyUserLabel
  GroovyHiLink groovyLabel		Label
  GroovyHiLink groovyUserLabel		Label
  GroovyHiLink groovyConditional	Conditional
  GroovyHiLink groovyRepeat		Repeat
  GroovyHiLink groovyExceptions		Exception
  GroovyHiLink groovyAssert 		Statement
  GroovyHiLink groovyStorageClass	StorageClass
  GroovyHiLink groovyMethodDecl		groovyStorageClass
  GroovyHiLink groovyClassDecl		groovyStorageClass
  GroovyHiLink groovyScopeDecl		groovyStorageClass
  GroovyHiLink groovyBoolean		Boolean
  GroovyHiLink groovySpecial		Special
  GroovyHiLink groovySpecialError	Error
  GroovyHiLink groovySpecialCharError	Error
  GroovyHiLink groovyString		String
  GroovyHiLink groovyCharacter		Character
  GroovyHiLink groovySpecialChar	SpecialChar
  GroovyHiLink groovyNumber		Number
  GroovyHiLink groovyError		Error
  GroovyHiLink groovyStringError	Error
  GroovyHiLink groovyStatement		Statement
  GroovyHiLink groovyOperator		Operator
  GroovyHiLink groovyComment		Comment
  GroovyHiLink groovyDocComment		Comment
  GroovyHiLink groovyLineComment	Comment
  GroovyHiLink groovyConstant		Constant
  GroovyHiLink groovyTypedef		Typedef
  GroovyHiLink groovyTodo		Todo
  
  GroovyHiLink groovyCommentTitle	SpecialComment
  GroovyHiLink groovyDocTags		Special
  GroovyHiLink groovyDocParam		Function
  GroovyHiLink groovyCommentStar	groovyComment
  
  GroovyHiLink groovyType		Type
  GroovyHiLink groovyExternal		Include
  
  GroovyHiLink htmlComment		Special
  GroovyHiLink htmlCommentPart		Special
  GroovyHiLink groovySpaceError		Error
  GroovyHiLink groovyJDKBuiltin         Special
  GroovyHiLink groovyJDKOperOverl       Operator
  GroovyHiLink groovyJDKMethods         Function
endif

delcommand GroovyHiLink


let b:current_syntax = "groovy"
if main_syntax == 'groovy'
  unlet main_syntax
endif

let b:spell_options="contained"

" vim: ts=8

endif