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 Dec 04
6
+ " Last Change: 2013 Oct 29
7
7
8
8
if version < 600
9
9
syntax clear
@@ -28,7 +28,6 @@ syn keyword rustKeyword use nextgroup=rustModPath skipwhite
28
28
" FIXME: Scoped impl's name is also fallen in this category
29
29
syn keyword rustKeyword mod trait struct enum type nextgroup =rustIdentifier skipwhite
30
30
syn keyword rustKeyword fn nextgroup =rustFuncName skipwhite
31
- syn keyword rustKeyword proc
32
31
syn keyword rustStorage const mut ref static
33
32
34
33
syn match rustIdentifier contains =rustIdentifierPrime " \% ([^[:cntrl:][:space:][:punct:][:digit:]]\| _\)\% ([^[:cntrl:][:punct:][:space:]]\| _\) *" display contained
@@ -90,7 +89,6 @@ syn keyword rustTrait Orderable Signed Unsigned Round
90
89
syn keyword rustTrait Primitive Int Float ToStrRadix ToPrimitive FromPrimitive
91
90
syn keyword rustTrait GenericPath Path PosixPath WindowsPath
92
91
syn keyword rustTrait RawPtr
93
- syn keyword rustTrait Buffer Writer Reader Seek
94
92
syn keyword rustTrait SendStr SendStrOwned SendStrStatic IntoSendStr
95
93
syn keyword rustTrait Str StrVector StrSlice OwnedStr
96
94
syn keyword rustTrait IterBytes
@@ -145,29 +143,38 @@ syn match rustOperator display "&&\|||"
145
143
syn match rustMacro ' \w\(\w\) *!' contains =rustAssert,rustFail
146
144
syn match rustMacro ' #\w\(\w\) *' contains =rustAssert,rustFail
147
145
148
- syn match rustSpecialError display contained / \\ ./
146
+ syn match rustFormat display " %\(\d\+\$\)\= [-+' #0*]*\(\d *\|\*\|\*\d\+\$\)\(\.\(\d *\|\*\|\*\d\+\$\)\)\=\( [hlLjzt]\| ll\| hh\)\=\( [aAbdiuoxXDOUfFeEgGcCsSpn?]\|\[\^\= .[^]]*\]\) " contained
147
+ syn match rustFormat display " %%" contained
149
148
syn match rustSpecial display contained / \\\( [nrt0\\ '"]\| x\x\{ 2}\| u\x\{ 4}\| U\x\{ 8}\) /
150
149
syn match rustStringContinuation display contained / \\\n\s */
151
- syn region rustString start =+ "+ skip =+ \\\\\|\\ "+ end =+ "+ contains =rustSpecial,rustSpecialError ,rustStringContinuation
150
+ syn region rustString start =+ "+ skip =+ \\\\\|\\ "+ end =+ "+ contains =rustTodo,rustFormat,rustSpecial ,rustStringContinuation
152
151
syn region rustString start =' r\z (#*\) "' end =' "\z 1'
153
152
154
153
syn region rustAttribute start =" #\[ " end =" \] " contains =rustString,rustDeriving
155
154
syn region rustDeriving start =" deriving(" end =" )" contained contains =rustTrait
156
155
157
156
" Number literals
158
- syn match rustDecNumber display " \< [0-9][0-9_]*\% ([iu]\% (8\| 16\| 32\| 64\)\=\)\= "
159
- syn match rustHexNumber display " \< 0x[a-fA-F0-9_]\+\% ([iu]\% (8\| 16\| 32\| 64\)\=\)\= "
160
- syn match rustOctNumber display " \< 0o[0-7_]\+\% ([iu]\% (8\| 16\| 32\| 64\)\=\)\= "
161
- syn match rustBinNumber display " \< 0b[01_]\+\% ([iu]\% (8\| 16\| 32\| 64\)\=\)\= "
162
-
163
- " To mark it as a float, it must have at least one of the three things integral values don't have:
164
- " a decimal point and more numbers; an exponent; and a type suffix.
165
- syn match rustFloat display " \< [0-9][0-9_]*\% (\. [0-9][0-9_]*\)\% ([eE][+-]\= [0-9_]\+\)\=\( f32\| f64\)\= "
166
- syn match rustFloat display " \< [0-9][0-9_]*\% (\. [0-9][0-9_]*\)\=\% ([eE][+-]\= [0-9_]\+\)\( f32\| f64\)\= "
167
- syn match rustFloat display " \< [0-9][0-9_]*\% (\. [0-9][0-9_]*\)\=\% ([eE][+-]\= [0-9_]\+\)\=\( f32\| f64\) "
168
- " Special case for numbers of the form "1." which are float literals, unless followed by
169
- " an identifier, which makes them integer literals with a method call or field access.
170
- syn match rustFloat display " \< [0-9][0-9_]*\.\% ([^[:cntrl:][:space:][:punct:][:digit:]]\| _\)\@ !"
157
+ syn match rustNumber display " \< [0-9][0-9_]*\> "
158
+ syn match rustNumber display " \< [0-9][0-9_]*\( u\| u8\| u16\| u32\| u64\)\> "
159
+ syn match rustNumber display " \< [0-9][0-9_]*\( i\| i8\| i16\| i32\| i64\)\> "
160
+
161
+ syn match rustHexNumber display " \< 0x[a-fA-F0-9_]\+\> "
162
+ syn match rustHexNumber display " \< 0x[a-fA-F0-9_]\+\( u\| u8\| u16\| u32\| u64\)\> "
163
+ syn match rustHexNumber display " \< 0x[a-fA-F0-9_]\+\( i8\| i16\| i32\| i64\)\> "
164
+ syn match rustOctNumber display " \< 0o[0-7_]\+\> "
165
+ syn match rustOctNumber display " \< 0o[0-7_]\+\( u\| u8\| u16\| u32\| u64\)\> "
166
+ syn match rustOctNumber display " \< 0o[0-7_]\+\( i8\| i16\| i32\| i64\)\> "
167
+ syn match rustBinNumber display " \< 0b[01_]\+\> "
168
+ syn match rustBinNumber display " \< 0b[01_]\+\( u\| u8\| u16\| u32\| u64\)\> "
169
+ syn match rustBinNumber display " \< 0b[01_]\+\( i8\| i16\| i32\| i64\)\> "
170
+
171
+ syn match rustFloat display " \< [0-9][0-9_]*\( f\| f32\| f64\)\> "
172
+ syn match rustFloat display " \< [0-9][0-9_]*\( [eE][+-]\= [0-9_]\+\)\> "
173
+ syn match rustFloat display " \< [0-9][0-9_]*\( [eE][+-]\= [0-9_]\+\)\( f\| f32\| f64\)\> "
174
+ syn match rustFloat display " \< [0-9][0-9_]*\. [0-9_]\+\> "
175
+ syn match rustFloat display " \< [0-9][0-9_]*\. [0-9_]\+\( f\| f32\| f64\)\> "
176
+ syn match rustFloat display " \< [0-9][0-9_]*\. [0-9_]\+\% ([eE][+-]\= [0-9_]\+\)\> "
177
+ syn match rustFloat display " \< [0-9][0-9_]*\. [0-9_]\+\% ([eE][+-]\= [0-9_]\+\)\( f\| f32\| f64\)\> "
171
178
172
179
" For the benefit of delimitMate
173
180
syn region rustLifetimeCandidate display start =/ &'\% (\( [^'\\ ]\|\\\( ['nrt0\\\" ]\| x\x\{ 2}\| u\x\{ 4}\| U\x\{ 8}\)\) '\)\@ !/ end =/ [[:cntrl:][:space:][:punct:]]\@ =\| $/ contains =rustSigil,rustLifetime
@@ -176,24 +183,12 @@ syn region rustGenericLifetimeCandidate display start=/\%(<\|,\s*\)\@<='/ end=/[
176
183
177
184
" rustLifetime must appear before rustCharacter, or chars will get the lifetime highlighting
178
185
syn match rustLifetime display " \'\% ([^[:cntrl:][:space:][:punct:][:digit:]]\| _\)\% ([^[:cntrl:][:punct:][:space:]]\| _\) *"
179
- syn match rustCharacter / '\( [^'\\ ]\|\\\( .\| x\x\{ 2}\| u\x\{ 4}\| U\x\{ 8}\)\) '/ contains =rustSpecial,rustSpecialError
180
-
181
- syn cluster rustComment contains =rustCommentLine,rustCommentLineDoc,rustCommentBlock,rustCommentBlockDoc
182
- syn region rustCommentLine start =" //" end =" $" contains =rustTodo
183
- syn region rustCommentLineDoc start =" //\% (//\@ !\| !\) " end =" $" contains =rustTodo
184
- syn region rustCommentBlock matchgroup =rustCommentBlock start =" /\*\% (!\|\* [*/]\@ !\)\@ !" end =" \* /" contains =rustTodo,@rustComment keepend extend
185
- syn region rustCommentBlockDoc matchgroup =rustCommentBlockDoc start =" /\*\% (!\|\* [*/]\@ !\) " end =" \* /" contains =rustTodo,@rustComment keepend extend
186
- " FIXME: this is a really ugly and not fully correct implementation. Most
187
- " importantly, a case like ``/* */*`` should have the final ``*`` not being in
188
- " a comment, but in practice at present it leaves comments open two levels
189
- " deep. But as long as you stay away from that particular case, I *believe*
190
- " the highlighting is correct. Due to the way Vim's syntax engine works
191
- " (greedy for start matches, unlike Rust's tokeniser which is searching for
192
- " the earliest-starting match, start or end), I believe this cannot be solved.
193
- " Oh you who would fix it, don't bother with things like duplicating the Block
194
- " rules and putting ``\*\@<!`` at the start of them; it makes it worse, as
195
- " then you must deal with cases like ``/*/**/*/``. And don't try making it
196
- " worse with ``\%(/\@<!\*\)\@<!``, either...
186
+ syn match rustCharacter / '\( [^'\\ ]\|\\\( [nrt0\\ '"]\| x\x\{ 2}\| u\x\{ 4}\| U\x\{ 8}\)\) '/ contains =rustSpecial
187
+
188
+ syn region rustCommentML start =" /\* " end =" \* /" contains =rustTodo
189
+ syn region rustComment start =" //" end =" $" contains =rustTodo keepend
190
+ syn region rustCommentMLDoc start =" /\*\% (!\|\* [*/]\@ !\) " end =" \* /" contains =rustTodo
191
+ syn region rustCommentDoc start =" //\% (//\@ !\| !\) " end =" $" contains =rustTodo keepend
197
192
198
193
syn keyword rustTodo contained TODO FIXME XXX NB NOTE
199
194
@@ -205,16 +200,15 @@ syn region rustFoldBraces start="{" end="}" transparent fold
205
200
" It's not enabled by default as it would drive some people mad.
206
201
207
202
" Default highlighting {{{1
208
- hi def link rustDecNumber rustNumber
209
203
hi def link rustHexNumber rustNumber
210
204
hi def link rustOctNumber rustNumber
211
205
hi def link rustBinNumber rustNumber
212
206
hi def link rustIdentifierPrime rustIdentifier
213
207
hi def link rustTrait rustType
214
208
215
209
hi def link rustSigil StorageClass
210
+ hi def link rustFormat Special
216
211
hi def link rustSpecial Special
217
- hi def link rustSpecialError Error
218
212
hi def link rustStringContinuation Special
219
213
hi def link rustString String
220
214
hi def link rustCharacter Character
@@ -235,10 +229,10 @@ hi def link rustModPathSep Delimiter
235
229
hi def link rustFunction Function
236
230
hi def link rustFuncName Function
237
231
hi def link rustFuncCall Function
238
- hi def link rustCommentLine Comment
239
- hi def link rustCommentLineDoc SpecialComment
240
- hi def link rustCommentBlock rustCommentLine
241
- hi def link rustCommentBlockDoc rustCommentLineDoc
232
+ hi def link rustCommentMLDoc rustCommentDoc
233
+ hi def link rustCommentDoc SpecialComment
234
+ hi def link rustCommentML rustComment
235
+ hi def link rustComment Comment
242
236
hi def link rustAssert PreCondit
243
237
hi def link rustFail PreCondit
244
238
hi def link rustMacro Macro
0 commit comments