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