]> git.r.bdr.sh - rbdr/dotfiles/blob - vim/syntax/scala.vim
Add nvim config
[rbdr/dotfiles] / vim / syntax / scala.vim
1 " Vim syntax file
2 " Language : Scala (http://scala-lang.org/)
3 " Maintainers: Stefan Matthias Aust, Julien Wetterwald
4 " Last Change: 2007 June 13
5
6 if version < 600
7 syntax clear
8 elseif exists("b:current_syntax")
9 finish
10 endif
11
12 syn case match
13 syn sync minlines=50
14
15 " most Scala keywords
16 syn keyword scalaKeyword abstract case catch do else extends final finally for forSome if implicit lazy match new null override private protected requires return sealed super this throw try type while with yield
17 syn match scalaKeyword "=>"
18 syn match scalaKeyword "<-"
19 syn match scalaKeyword "\<_\>"
20
21 syn match scalaOperator ":\{2,\}" "this is not a type
22
23 " package and import statements
24 syn keyword scalaPackage package nextgroup=scalaFqn skipwhite
25 syn keyword scalaImport import nextgroup=scalaFqn skipwhite
26 syn match scalaFqn "\<[._$a-zA-Z0-9,]*" contained nextgroup=scalaFqnSet
27 syn region scalaFqnSet start="{" end="}" contained
28
29 " boolean literals
30 syn keyword scalaBoolean true false
31
32 " definitions
33 syn keyword scalaDef def nextgroup=scalaDefName skipwhite
34 syn keyword scalaVal val nextgroup=scalaValName skipwhite
35 syn keyword scalaVar var nextgroup=scalaVarName skipwhite
36 syn keyword scalaClass class nextgroup=scalaClassName skipwhite
37 syn keyword scalaObject object nextgroup=scalaClassName skipwhite
38 syn keyword scalaTrait trait nextgroup=scalaClassName skipwhite
39 syn match scalaDefName "[^ =:;([]\+" contained nextgroup=scalaDefSpecializer skipwhite
40 syn match scalaValName "[^ =:;([]\+" contained
41 syn match scalaVarName "[^ =:;([]\+" contained
42 syn match scalaClassName "[^ =:;(\[]\+" contained nextgroup=scalaClassSpecializer skipwhite
43 syn region scalaDefSpecializer start="\[" end="\]" contained contains=scalaDefSpecializer
44 syn region scalaClassSpecializer start="\[" end="\]" contained contains=scalaClassSpecializer
45
46 " type constructor (actually anything with an uppercase letter)
47 syn match scalaConstructor "\<[A-Z][_$a-zA-Z0-9]*\>" nextgroup=scalaConstructorSpecializer
48 syn region scalaConstructorSpecializer start="\[" end="\]" contained contains=scalaConstructorSpecializer
49
50 " method call
51 syn match scalaRoot "\<[a-zA-Z][_$a-zA-Z0-9]*\."me=e-1
52 syn match scalaMethodCall "\.[a-z][_$a-zA-Z0-9]*"ms=s+1
53
54 " type declarations in val/var/def
55 syn match scalaType ":\s*\(=>\s*\)\?[._$a-zA-Z0-9]\+\(\[[^]]*\]\+\)\?\(\s*\(<:\|>:\|#\|=>\)\s*[._$a-zA-Z0-9]\+\(\[[^]]*\]\+\)*\)*"ms=s+1
56
57 " comments
58 syn match scalaTodo "[tT][oO][dD][oO]" contained
59 syn match scalaLineComment "//.*" contains=scalaTodo
60 syn region scalaComment start="/\*" end="\*/" contains=scalaTodo
61 syn case ignore
62 syn include @scalaHtml syntax/html.vim
63 unlet b:current_syntax
64 syn case match
65 syn region scalaDocComment start="/\*\*" end="\*/" contains=scalaDocTags,scalaTodo,@scalaHtml keepend
66 syn region scalaDocTags start="{@\(link\|linkplain\|inherit[Dd]oc\|doc[rR]oot\|value\)" end="}" contained
67 syn match scalaDocTags "@[a-z]\+" contained
68
69 syn match scalaEmptyString "\"\""
70
71 " multi-line string literals
72 syn region scalaMultiLineString start="\"\"\"" end="\"\"\"" contains=scalaUnicode
73 syn match scalaUnicode "\\u[0-9a-fA-F]\{4}" contained
74
75 " string literals with escapes
76 syn region scalaString start="\"[^"]" skip="\\\"" end="\"" contains=scalaStringEscape " TODO end \n or not?
77 syn match scalaStringEscape "\\u[0-9a-fA-F]\{4}" contained
78 syn match scalaStringEscape "\\[nrfvb\\\"]" contained
79
80 " symbol and character literals
81 syn match scalaSymbol "'[_a-zA-Z0-9][_a-zA-Z0-9]*\>"
82 syn match scalaChar "'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'"
83
84 " number literals
85 syn match scalaNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
86 syn match scalaNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
87 syn match scalaNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"
88 syn match scalaNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>"
89
90 " xml literals
91 syn match scalaXmlTag "<[a-zA-Z]\_[^>]*/>" contains=scalaXmlQuote,scalaXmlEscape,scalaXmlString
92 syn region scalaXmlString start="\"" end="\"" contained
93 syn match scalaXmlStart "<[a-zA-Z]\_[^>]*>" contained contains=scalaXmlQuote,scalaXmlEscape,scalaXmlString
94 syn region scalaXml start="<\([a-zA-Z]\_[^>]*\_[^/]\|[a-zA-Z]\)>" matchgroup=scalaXmlStart end="</\_[^>]\+>" contains=scalaXmlEscape,scalaXmlQuote,scalaXml,scalaXmlStart,scalaXmlComment
95 syn region scalaXmlEscape matchgroup=scalaXmlEscapeSpecial start="{" matchgroup=scalaXmlEscapeSpecial end="}" contained contains=TOP
96 syn match scalaXmlQuote "&[^;]\+;" contained
97 syn match scalaXmlComment "<!--\_[^>]*-->" contained
98
99 syn sync fromstart
100
101 " map Scala groups to standard groups
102 hi link scalaKeyword Keyword
103 hi link scalaPackage Include
104 hi link scalaImport Include
105 hi link scalaBoolean Boolean
106 hi link scalaOperator Normal
107 hi link scalaNumber Number
108 hi link scalaEmptyString String
109 hi link scalaString String
110 hi link scalaChar String
111 hi link scalaMultiLineString String
112 hi link scalaStringEscape Special
113 hi link scalaSymbol Special
114 hi link scalaUnicode Special
115 hi link scalaComment Comment
116 hi link scalaLineComment Comment
117 hi link scalaDocComment Comment
118 hi link scalaDocTags Special
119 hi link scalaTodo Todo
120 hi link scalaType Type
121 hi link scalaTypeSpecializer scalaType
122 hi link scalaXml String
123 hi link scalaXmlTag Include
124 hi link scalaXmlString String
125 hi link scalaXmlStart Include
126 hi link scalaXmlEscape Normal
127 hi link scalaXmlEscapeSpecial Special
128 hi link scalaXmlQuote Special
129 hi link scalaXmlComment Comment
130 hi link scalaDef Keyword
131 hi link scalaVar Keyword
132 hi link scalaVal Keyword
133 hi link scalaClass Keyword
134 hi link scalaObject Keyword
135 hi link scalaTrait Keyword
136 hi link scalaDefName Function
137 hi link scalaDefSpecializer Function
138 hi link scalaClassName Special
139 hi link scalaClassSpecializer Special
140 hi link scalaConstructor Special
141 hi link scalaConstructorSpecializer scalaConstructor
142
143 let b:current_syntax = "scala"
144
145 " you might like to put these lines in your .vimrc
146 "
147 " customize colors a little bit (should be a different file)
148 " hi scalaNew gui=underline
149 " hi scalaMethodCall gui=italic
150 " hi scalaValName gui=underline
151 " hi scalaVarName gui=underline