2013-09-12 11:02:41 -04:00
|
|
|
if version < 600
|
|
|
|
syntax clear
|
|
|
|
elseif exists("b:current_syntax")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2014-06-08 13:35:34 -04:00
|
|
|
scriptencoding utf-8
|
|
|
|
|
2013-12-12 19:37:01 -05:00
|
|
|
let b:current_syntax = "scala"
|
2013-09-12 11:02:41 -04:00
|
|
|
|
2014-06-08 13:35:34 -04:00
|
|
|
function! s:ContainedGroup()
|
|
|
|
try
|
|
|
|
silent syn list @scala
|
|
|
|
return '@scala'
|
|
|
|
catch /E392/
|
|
|
|
return 'TOP'
|
|
|
|
endtry
|
|
|
|
endfunction
|
|
|
|
|
2013-12-12 19:37:01 -05:00
|
|
|
syn case match
|
|
|
|
syn sync minlines=200 maxlines=1000
|
|
|
|
|
|
|
|
syn keyword scalaKeyword catch do else final finally for forSome if
|
2014-02-28 18:15:51 -05:00
|
|
|
syn keyword scalaKeyword match return throw try while yield macro
|
2013-12-25 21:34:22 -05:00
|
|
|
syn keyword scalaKeyword class trait object extends with nextgroup=scalaInstanceDeclaration skipwhite
|
|
|
|
syn keyword scalaKeyword case nextgroup=scalaKeyword,scalaCaseFollowing skipwhite
|
2013-12-12 19:37:01 -05:00
|
|
|
syn keyword scalaKeyword val nextgroup=scalaNameDefinition,scalaQuasiQuotes skipwhite
|
|
|
|
syn keyword scalaKeyword def var nextgroup=scalaNameDefinition skipwhite
|
|
|
|
hi link scalaKeyword Keyword
|
2013-09-12 11:02:41 -04:00
|
|
|
|
2014-06-08 13:35:34 -04:00
|
|
|
exe 'syn region scalaBlock start=/{/ end=/}/ contains=' . s:ContainedGroup() . ' fold'
|
2014-04-14 19:05:44 -04:00
|
|
|
|
2014-01-09 05:59:09 -05:00
|
|
|
syn keyword scalaAkkaSpecialWord when goto using startWith initialize onTransition stay become unbecome
|
|
|
|
hi link scalaAkkaSpecialWord PreProc
|
|
|
|
|
2013-12-25 21:34:22 -05:00
|
|
|
syn match scalaSymbol /'[_A-Za-z0-9$]\+/
|
|
|
|
hi link scalaSymbol Number
|
|
|
|
|
|
|
|
syn match scalaChar /'.'/
|
|
|
|
syn match scalaEscapedChar /\\[\\ntbrf]/
|
|
|
|
syn match scalaUnicodeChar /\\u[A-Fa-f0-9]\{4}/
|
|
|
|
hi link scalaChar Character
|
|
|
|
hi link scalaEscapedChar Function
|
|
|
|
hi link scalaUnicodeChar Special
|
|
|
|
|
2014-01-09 05:59:09 -05:00
|
|
|
syn match scalaOperator "||"
|
|
|
|
syn match scalaOperator "&&"
|
|
|
|
hi link scalaOperator Special
|
|
|
|
|
2013-12-26 18:01:27 -05:00
|
|
|
syn match scalaNameDefinition /\<[_A-Za-z0-9$]\+\>/ contained nextgroup=scalaPostNameDefinition
|
|
|
|
syn match scalaNameDefinition /`[^`]\+`/ contained nextgroup=scalaPostNameDefinition
|
|
|
|
syn match scalaPostNameDefinition /\_s*:\_s*/ contained nextgroup=scalaTypeDeclaration
|
2013-12-12 19:37:01 -05:00
|
|
|
hi link scalaNameDefinition Function
|
2013-09-12 11:02:41 -04:00
|
|
|
|
2014-01-09 05:59:09 -05:00
|
|
|
syn match scalaInstanceDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaInstanceHash
|
2013-12-12 19:37:01 -05:00
|
|
|
syn match scalaInstanceDeclaration /`[^`]\+`/ contained
|
2014-01-09 05:59:09 -05:00
|
|
|
syn match scalaInstanceHash /#/ contained nextgroup=scalaInstanceDeclaration
|
2013-12-12 19:37:01 -05:00
|
|
|
hi link scalaInstanceDeclaration Special
|
2014-01-09 05:59:09 -05:00
|
|
|
hi link scalaInstanceHash Type
|
|
|
|
|
|
|
|
syn match scalaCapitalWord /\<[A-Z][A-Za-z0-9$]*\>/
|
|
|
|
hi link scalaCapitalWord Special
|
|
|
|
|
|
|
|
" Handle type declarations specially
|
|
|
|
syn region scalaTypeStatement matchgroup=Keyword start=/\<type\_s\+\ze/ end=/$/ contains=scalaTypeTypeDeclaration,scalaSquareBrackets,scalaTypeTypeEquals,scalaTypeStatement
|
2013-09-12 11:02:41 -04:00
|
|
|
|
2013-12-26 18:01:27 -05:00
|
|
|
" Ugh... duplication of all the scalaType* stuff to handle special highlighting
|
|
|
|
" of `type X =` declarations
|
|
|
|
syn match scalaTypeTypeDeclaration /(/ contained nextgroup=scalaTypeTypeExtension,scalaTypeTypeEquals contains=scalaRoundBrackets skipwhite
|
|
|
|
syn match scalaTypeTypeDeclaration /\%(⇒\|=>\)\ze/ contained nextgroup=scalaTypeTypeDeclaration contains=scalaTypeTypeExtension skipwhite
|
|
|
|
syn match scalaTypeTypeDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeTypeExtension,scalaTypeTypeEquals skipwhite
|
|
|
|
syn match scalaTypeTypeEquals /=\ze[^>]/ contained nextgroup=scalaTypeTypePostDeclaration skipwhite
|
2014-01-09 05:59:09 -05:00
|
|
|
syn match scalaTypeTypeExtension /)\?\_s*\zs\%(⇒\|=>\|<:\|:>\|=:=\|::\|#\)/ contained nextgroup=scalaTypeTypeDeclaration skipwhite
|
|
|
|
syn match scalaTypeTypePostDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeTypePostExtension skipwhite
|
2013-12-26 18:01:27 -05:00
|
|
|
syn match scalaTypeTypePostExtension /\%(⇒\|=>\|<:\|:>\|=:=\|::\)/ contained nextgroup=scalaTypeTypePostDeclaration skipwhite
|
|
|
|
hi link scalaTypeTypeDeclaration Type
|
|
|
|
hi link scalaTypeTypeExtension Keyword
|
|
|
|
hi link scalaTypeTypePostDeclaration Special
|
|
|
|
hi link scalaTypeTypePostExtension Keyword
|
|
|
|
|
2014-01-09 05:59:09 -05:00
|
|
|
syn match scalaTypeDeclaration /(/ contained nextgroup=scalaTypeExtension contains=scalaRoundBrackets skipwhite
|
2013-12-26 18:01:27 -05:00
|
|
|
syn match scalaTypeDeclaration /\%(⇒\|=>\)\ze/ contained nextgroup=scalaTypeDeclaration contains=scalaTypeExtension skipwhite
|
2014-01-09 05:59:09 -05:00
|
|
|
syn match scalaTypeDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeExtension skipwhite
|
|
|
|
syn match scalaTypeExtension /)\?\_s*\zs\%(⇒\|=>\|<:\|:>\|=:=\|::\|#\)/ contained nextgroup=scalaTypeDeclaration skipwhite
|
2013-12-25 21:34:22 -05:00
|
|
|
hi link scalaTypeDeclaration Type
|
|
|
|
hi link scalaTypeExtension Keyword
|
|
|
|
hi link scalaTypePostExtension Keyword
|
|
|
|
|
2013-12-26 18:01:27 -05:00
|
|
|
syn match scalaTypeAnnotation /\%([_a-zA-Z0-9$\s]:\_s*\)\ze[_=(\.A-Za-z0-9$]\+/ skipwhite nextgroup=scalaTypeDeclaration contains=scalaRoundBrackets
|
|
|
|
syn match scalaTypeAnnotation /)\_s*:\_s*\ze[_=(\.A-Za-z0-9$]\+/ skipwhite nextgroup=scalaTypeDeclaration
|
|
|
|
hi link scalaTypeAnnotation Normal
|
2013-12-25 21:34:22 -05:00
|
|
|
|
2014-01-09 05:59:09 -05:00
|
|
|
syn match scalaCaseFollowing /\<[_\.A-Za-z0-9$]\+\>/ contained
|
2013-12-12 19:37:01 -05:00
|
|
|
syn match scalaCaseFollowing /`[^`]\+`/ contained
|
|
|
|
hi link scalaCaseFollowing Special
|
2013-09-12 11:02:41 -04:00
|
|
|
|
2014-01-09 05:59:09 -05:00
|
|
|
syn keyword scalaKeywordModifier abstract override final lazy implicit implicitly private protected sealed null require super
|
2013-12-12 19:37:01 -05:00
|
|
|
hi link scalaKeywordModifier Function
|
2013-09-12 11:02:41 -04:00
|
|
|
|
2014-01-09 05:59:09 -05:00
|
|
|
syn keyword scalaSpecial this true false package import ne eq
|
2013-12-12 19:37:01 -05:00
|
|
|
syn keyword scalaSpecial new nextgroup=scalaInstanceDeclaration skipwhite
|
|
|
|
syn match scalaSpecial "\%(=>\|⇒\|<-\|←\|->\|→\)"
|
|
|
|
syn match scalaSpecial /`[^`]*`/ " Backtick literals
|
|
|
|
hi link scalaSpecial PreProc
|
2013-09-12 11:02:41 -04:00
|
|
|
|
2013-12-25 21:34:22 -05:00
|
|
|
syn match scalaStringEmbeddedQuote /\\"/ contained
|
|
|
|
syn region scalaString start=/"/ end=/"/ contains=scalaStringEmbeddedQuote,scalaEscapedChar,scalaUnicodeChar
|
2013-09-12 11:02:41 -04:00
|
|
|
hi link scalaString String
|
2013-12-25 21:34:22 -05:00
|
|
|
hi link scalaStringEmbeddedQuote String
|
2013-09-12 11:02:41 -04:00
|
|
|
|
2014-04-14 19:05:44 -04:00
|
|
|
syn region scalaIString matchgroup=Special start=/\<[a-zA-Z][a-zA-Z0-9_]*"/ skip=/\\"/ end=/"/ contains=scalaInterpolation,scalaInterpolationB,scalaEscapedChar,scalaUnicodeChar
|
|
|
|
syn region scalaTripleIString matchgroup=Special start=/\<[a-zA-Z][a-zA-Z0-9_]*"""/ end=/"""\%([^"]\|$\)/ contains=scalaInterpolation,scalaInterpolationB,scalaEscapedChar,scalaUnicodeChar
|
|
|
|
hi link scalaIString String
|
|
|
|
hi link scalaTripleIString String
|
|
|
|
|
2013-12-12 19:37:01 -05:00
|
|
|
syn match scalaInterpolation /\$[a-zA-Z0-9_$]\+/ contained
|
2014-06-08 13:35:34 -04:00
|
|
|
exe 'syn region scalaInterpolationB matchgroup=scalaInterpolation start=/\${/ end=/}/ contained contains=' . s:ContainedGroup()
|
2013-12-12 19:37:01 -05:00
|
|
|
hi link scalaInterpolation Function
|
2014-04-14 19:05:44 -04:00
|
|
|
hi link scalaInterpolationB Normal
|
2013-12-12 19:37:01 -05:00
|
|
|
|
2014-04-14 19:05:44 -04:00
|
|
|
syn region scalaFString matchgroup=Special start=/f"/ skip=/\\"/ end=/"/ contains=scalaFInterpolation,scalaFInterpolationB,scalaEscapedChar,scalaUnicodeChar
|
|
|
|
syn match scalaFInterpolation /\$[a-zA-Z0-9_$]\+\(%[-A-Za-z0-9\.]\+\)\?/ contained
|
2014-06-08 13:35:34 -04:00
|
|
|
exe 'syn region scalaFInterpolationB matchgroup=scalaFInterpolation start=/${/ end=/}\(%[-A-Za-z0-9\.]\+\)\?/ contained contains=' . s:ContainedGroup()
|
2013-12-12 19:37:01 -05:00
|
|
|
hi link scalaFString String
|
|
|
|
hi link scalaFInterpolation Function
|
2014-04-14 19:05:44 -04:00
|
|
|
hi link scalaFInterpolationB Normal
|
2013-12-12 19:37:01 -05:00
|
|
|
|
2014-01-09 05:59:09 -05:00
|
|
|
syn region scalaTripleString start=/"""/ end=/"""\%([^"]\|$\)/ contains=scalaEscapedChar,scalaUnicodeChar
|
2014-04-14 19:05:44 -04:00
|
|
|
syn region scalaTripleFString matchgroup=Special start=/f"""/ end=/"""\%([^"]\|$\)/ contains=scalaFInterpolation,scalaFInterpolationB,scalaEscapedChar,scalaUnicodeChar
|
2013-12-12 19:37:01 -05:00
|
|
|
hi link scalaTripleString String
|
|
|
|
hi link scalaTripleFString String
|
|
|
|
|
2014-01-09 05:59:09 -05:00
|
|
|
syn match scalaNumber /\<0[dDfFlL]\?\>/ " Just a bare 0
|
|
|
|
syn match scalaNumber /\<[1-9]\d*[dDfFlL]\?\>/ " A multi-digit number - octal numbers with leading 0's are deprecated in Scala
|
|
|
|
syn match scalaNumber /\<0[xX][0-9a-fA-F]\+[dDfFlL]\?\>/ " Hex number
|
|
|
|
syn match scalaNumber /\%(\<\d\+\.\d*\|\.\d\+\)\%([eE][-+]\=\d\+\)\=[fFdD]\=/ " exponential notation 1
|
|
|
|
syn match scalaNumber /\<\d\+[eE][-+]\=\d\+[fFdD]\=\>/ " exponential notation 2
|
|
|
|
syn match scalaNumber /\<\d\+\%([eE][-+]\=\d\+\)\=[fFdD]\>/ " exponential notation 3
|
2013-12-12 19:37:01 -05:00
|
|
|
hi link scalaNumber Number
|
2013-09-12 11:02:41 -04:00
|
|
|
|
2013-12-26 18:01:27 -05:00
|
|
|
syn region scalaRoundBrackets start="(" end=")" skipwhite contained contains=scalaTypeDeclaration,scalaSquareBrackets,scalaRoundBrackets
|
2013-12-25 21:34:22 -05:00
|
|
|
|
2013-12-26 18:01:27 -05:00
|
|
|
syn region scalaSquareBrackets matchgroup=Type start="\[" end="\]" skipwhite nextgroup=scalaTypeExtension contains=scalaTypeDeclaration,scalaSquareBrackets,scalaTypeOperator,scalaTypeAnnotationParameter
|
2013-12-25 21:34:22 -05:00
|
|
|
syn match scalaTypeOperator /[-+=:<>]\+/ contained
|
|
|
|
syn match scalaTypeAnnotationParameter /@\<[`_A-Za-z0-9$]\+\>/ contained
|
|
|
|
hi link scalaTypeOperator Keyword
|
|
|
|
hi link scalaTypeAnnotationParameter Function
|
2013-12-12 19:37:01 -05:00
|
|
|
|
|
|
|
syn region scalaMultilineComment start="/\*" end="\*/" contains=scalaMultilineComment,scalaDocLinks,scalaParameterAnnotation,scalaCommentAnnotation,scalaCommentCodeBlock,@scalaHtml keepend
|
|
|
|
syn match scalaCommentAnnotation "@[_A-Za-z0-9$]\+" contained
|
|
|
|
syn match scalaParameterAnnotation "@param" nextgroup=scalaParamAnnotationValue skipwhite contained
|
|
|
|
syn match scalaParamAnnotationValue /[`_A-Za-z0-9$]\+/ contained
|
|
|
|
syn region scalaDocLinks start="\[\[" end="\]\]" contained
|
|
|
|
syn region scalaCommentCodeBlock matchgroup=Keyword start="{{{" end="}}}" contained
|
|
|
|
hi link scalaMultilineComment Comment
|
|
|
|
hi link scalaDocLinks Function
|
|
|
|
hi link scalaParameterAnnotation Function
|
|
|
|
hi link scalaParamAnnotationValue Keyword
|
|
|
|
hi link scalaCommentAnnotation Function
|
|
|
|
hi link scalaCommentCodeBlock String
|
|
|
|
|
|
|
|
syn match scalaAnnotation /@\<[`_A-Za-z0-9$]\+\>/
|
|
|
|
hi link scalaAnnotation PreProc
|
|
|
|
|
|
|
|
syn match scalaTrailingComment "//.*$"
|
|
|
|
hi link scalaTrailingComment Comment
|
2014-01-09 05:59:09 -05:00
|
|
|
|
|
|
|
syn match scalaAkkaFSM /goto([^)]*)\_s\+\<using\>/ contains=scalaAkkaFSMGotoUsing
|
|
|
|
syn match scalaAkkaFSM /stay\_s\+using/
|
|
|
|
syn match scalaAkkaFSM /^\s*stay\s*$/
|
|
|
|
syn match scalaAkkaFSM /when\ze([^)]*)/
|
|
|
|
syn match scalaAkkaFSM /startWith\ze([^)]*)/
|
|
|
|
syn match scalaAkkaFSM /initialize\ze()/
|
|
|
|
syn match scalaAkkaFSM /onTransition/
|
|
|
|
syn match scalaAkkaFSM /onTermination/
|
|
|
|
syn match scalaAkkaFSM /whenUnhandled/
|
|
|
|
syn match scalaAkkaFSMGotoUsing /\<using\>/
|
|
|
|
syn match scalaAkkaFSMGotoUsing /\<goto\>/
|
|
|
|
hi link scalaAkkaFSM PreProc
|
|
|
|
hi link scalaAkkaFSMGotoUsing PreProc
|