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