3
3
" Maintainer: Patrick Walton <[email protected] >
4
4
" Maintainer: Ben Blum <[email protected] >
5
5
" Maintainer: Chris Morgan <[email protected] >
6
- " Last Change: 2013 Jul 10
6
+ " Last Change: 2013 Aug 1
7
7
8
8
if version < 600
9
9
syntax clear
@@ -17,7 +17,7 @@ syn keyword rustOperator as
17
17
syn match rustAssert " \< assert\(\w\) *!" contained
18
18
syn match rustFail " \< fail\(\w\) *!" contained
19
19
syn keyword rustKeyword break copy do extern
20
- syn keyword rustKeyword for if impl let log
20
+ syn keyword rustKeyword in if impl let log
21
21
syn keyword rustKeyword copy do extern
22
22
syn keyword rustKeyword for impl let log
23
23
syn keyword rustKeyword loop mod once priv pub
@@ -83,12 +83,26 @@ syn match rustModPathSep "::"
83
83
syn match rustFuncCall " \w\(\w\) *(" he =e - 1 ,me =e - 1
84
84
syn match rustFuncCall " \w\(\w\) *::<" he =e - 3 ,me =e - 3 " foo::<T>();
85
85
86
+ " This is merely a convention; note also the use of [A-Z], restricting it to
87
+ " latin identifiers rather than the full Unicode uppercase. I have not used
88
+ " [:upper:] as it depends upon 'noignorecase'
89
+ " syn match rustCapsIdent display "[A-Z]\w\(\w\)*"
90
+
91
+ syn match rustOperator display " \% (+\| -\| /\| *\| =\|\^\| &\| |\| !\| >\| <\| %\) =\? "
92
+ " This one isn't *quite* right, as we could have binary-& with a reference
93
+ syn match rustSigil display / &\s\+ [&~@*][^)= \t\r\n ]/ he =e - 1 ,me =e - 1
94
+ syn match rustSigil display / [&~@*][^)= \t\r\n ]/ he =e - 1 ,me =e - 1
95
+ " This isn't actually correct; a closure with no arguments can be `|| { }`.
96
+ " Last, because the & in && isn't a sigil
97
+ syn match rustOperator display " &&\| ||"
98
+
86
99
syn match rustMacro ' \w\(\w\) *!' contains =rustAssert,rustFail
87
100
syn match rustMacro ' #\w\(\w\) *' contains =rustAssert,rustFail
88
101
89
102
syn match rustFormat display " %\(\d\+\$\)\= [-+' #0*]*\(\d *\|\*\|\*\d\+\$\)\(\.\(\d *\|\*\|\*\d\+\$\)\)\=\( [hlLjzt]\| ll\| hh\)\=\( [aAbdiuoxXDOUfFeEgGcCsSpn?]\|\[\^\= .[^]]*\]\) " contained
90
103
syn match rustFormat display " %%" contained
91
- syn region rustString start =+ L\= "+ skip =+ \\\\\|\\ "+ end =+ "+ contains =rustTodo,rustFormat
104
+ syn match rustSpecial display contained / \\\( [nrt\\ '"]\| x\x\{ 2}\| u\x\{ 4}\| U\x\{ 8}\) /
105
+ syn region rustString start =+ L\= "+ skip =+ \\\\\|\\ "+ end =+ "+ contains =rustTodo,rustFormat,rustSpecial
92
106
93
107
syn region rustAttribute start =" #\[ " end =" \] " contains =rustString,rustDeriving
94
108
syn region rustDeriving start =" deriving(" end =" )" contained contains =rustTrait
@@ -114,13 +128,13 @@ syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9
114
128
syn match rustFloat display " \< [0-9][0-9_]*\. [0-9_]\+\% ([eE][+-]\= [0-9_]\+\)\( f\| f32\| f64\)\> "
115
129
116
130
" For the benefit of delimitMate
117
- syn region rustLifetimeCandidate display start =/ &'\% (\( [^'\\ ]\|\\\( ['nrt\\\" ]\| x\x\{ 2}\| u\x\{ 4}\| U\x\{ 8}\)\) '\)\@ !/ end =/ [[:cntrl:][:space:][:punct:]]\@ =\| $/ contains =rustLifetime
131
+ syn region rustLifetimeCandidate display start =/ &'\% (\( [^'\\ ]\|\\\( ['nrt\\\" ]\| x\x\{ 2}\| u\x\{ 4}\| U\x\{ 8}\)\) '\)\@ !/ end =/ [[:cntrl:][:space:][:punct:]]\@ =\| $/ contains =rustSigil, rustLifetime
118
132
syn region rustGenericRegion display start =/ <\% ('\| [^[cntrl:][:space:][:punct:]]\)\@ =')\S\@ =/ end =/ >/ contains =rustGenericLifetimeCandidate
119
- syn region rustGenericLifetimeCandidate display start =/ \% (<\| ,\s *\)\@ <='/ end =/ [[:cntrl:][:space:][:punct:]]\@ =\| $/ contains =rustLifetime
133
+ syn region rustGenericLifetimeCandidate display start =/ \% (<\| ,\s *\)\@ <='/ end =/ [[:cntrl:][:space:][:punct:]]\@ =\| $/ contains =rustSigil, rustLifetime
120
134
121
135
" rustLifetime must appear before rustCharacter, or chars will get the lifetime highlighting
122
136
syn match rustLifetime display " \'\% ([^[:cntrl:][:space:][:punct:][:digit:]]\| _\)\% ([^[:cntrl:][:punct:][:space:]]\| _\) *"
123
- syn match rustCharacter " '\( [^'\\ ]\|\\\( [' nrt\\\ " ]\| x\x\{ 2}\| u\x\{ 4}\| U\x\{ 8}\)\) '"
137
+ syn match rustCharacter / '\( [^'\\ ]\|\\\( [nrt\\ ' "]\| x\x\{ 2}\| u\x\{ 4}\| U\x\{ 8}\)\) '/ contains = rustSpecial
124
138
125
139
syn region rustCommentML start =" /\* " end =" \* /" contains =rustTodo
126
140
syn region rustComment start =" //" skip =" \\ $" end =" $" contains =rustTodo keepend
@@ -140,7 +154,9 @@ hi def link rustBinNumber rustNumber
140
154
hi def link rustIdentifierPrime rustIdentifier
141
155
hi def link rustTrait rustType
142
156
157
+ hi def link rustSigil StorageClass
143
158
hi def link rustFormat Special
159
+ hi def link rustSpecial Special
144
160
hi def link rustString String
145
161
hi def link rustCharacter Character
146
162
hi def link rustNumber Number
@@ -152,6 +168,7 @@ hi def link rustOperator Operator
152
168
hi def link rustKeyword Keyword
153
169
hi def link rustConditional Conditional
154
170
hi def link rustIdentifier Identifier
171
+ hi def link rustCapsIdent rustIdentifier
155
172
hi def link rustModPath Include
156
173
hi def link rustModPathSep Delimiter
157
174
hi def link rustFuncName Function
0 commit comments