Skip to content

Commit f41b4e3

Browse files
committed
auto merge of #10888 : chris-morgan/rust/2013-12-10-vim-updates, r=thestinger
### Fix up float highlighting in Vim. This fixes a regression introduced in #10793. Having a colorscheme which highlights Float the same as Number (I believe most do), I hadn't noticed that having the special case of "5." floats (which was one of the added features in #10793) last made it take precedence, and so it was left to @thestinger to notice it. The regression meant that in `5.0`, the `5.` was a `rustFloat` (linked by default to `Float`) and the `0` was a `rustDecNumber` (linked by default to `Number`), and for `5.0f32` the `5.` was a `rustFloat` and the `0f32` was a second `rustFloat` (and thus appeared correctly, though for the wrong reason). ### Vim keyword highlighting improvements. - Removed the `log` keyword; - Removed keyword duplicates; - Highlighted `const` as `Error` rather than `StorageClass`; and - Highlighted all the reserved keywords as `Error` rather than as `Keyword`. (As usual, these highlightings can be overridden if desired.)
2 parents d441c54 + f39c883 commit f41b4e3

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/etc/vim/syntax/rust.vim

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Maintainer: Patrick Walton <[email protected]>
44
" Maintainer: Ben Blum <[email protected]>
55
" Maintainer: Chris Morgan <[email protected]>
6-
" Last Change: 2013 Dec 04
6+
" Last Change: 2013 Dec 10
77

88
if version < 600
99
syntax clear
@@ -19,23 +19,23 @@ syn keyword rustOperator as
1919
syn match rustAssert "\<assert\(\w\)*!" contained
2020
syn match rustFail "\<fail\(\w\)*!" contained
2121
syn keyword rustKeyword break continue do extern
22-
syn keyword rustKeyword in if impl let log
23-
syn keyword rustKeyword for impl let log
24-
syn keyword rustKeyword loop mod once priv pub
22+
syn keyword rustKeyword for in if impl let
23+
syn keyword rustKeyword loop once priv pub
2524
syn keyword rustKeyword return
2625
syn keyword rustKeyword unsafe while
2726
syn keyword rustKeyword use nextgroup=rustModPath skipwhite
2827
" FIXME: Scoped impl's name is also fallen in this category
2928
syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite
3029
syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite
3130
syn keyword rustKeyword proc
32-
syn keyword rustStorage const mut ref static
31+
syn keyword rustStorage mut ref static
32+
syn keyword rustObsoleteStorage const
3333

3434
syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
3535
syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
3636

3737
" Reserved (but not yet used) keywords {{{2
38-
syn keyword rustKeyword alignof be offsetof pure sizeof typeof yield
38+
syn keyword rustReservedKeyword alignof be offsetof pure sizeof typeof yield
3939

4040
" Built-in types {{{2
4141
syn keyword rustType int uint float char bool u8 u16 u32 u64 f32
@@ -160,14 +160,15 @@ syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\%([iu]\%(8\|16\|32\|64
160160
syn match rustOctNumber display "\<0o[0-7_]\+\%([iu]\%(8\|16\|32\|64\)\=\)\="
161161
syn match rustBinNumber display "\<0b[01_]\+\%([iu]\%(8\|16\|32\|64\)\=\)\="
162162

163-
" To mark it as a float, it must have at least one of the three things integral values don't have:
163+
" Special case for numbers of the form "1." which are float literals, unless followed by
164+
" an identifier, which makes them integer literals with a method call or field access.
165+
" (This must go first so the others take precedence.)
166+
syn match rustFloat display "\<[0-9][0-9_]*\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\@!"
167+
" To mark a number as a normal float, it must have at least one of the three things integral values don't have:
164168
" a decimal point and more numbers; an exponent; and a type suffix.
165169
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)\="
166170
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\(f32\|f64\)\="
167171
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:]]\|_\)\@!"
171172

172173
" For the benefit of delimitMate
173174
syn region rustLifetimeCandidate display start=/&'\%(\([^'\\]\|\\\(['nrt0\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'\)\@!/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustSigil,rustLifetime
@@ -227,6 +228,7 @@ hi def link rustSelf Constant
227228
hi def link rustFloat Float
228229
hi def link rustOperator Operator
229230
hi def link rustKeyword Keyword
231+
hi def link rustReservedKeyword Error
230232
hi def link rustConditional Conditional
231233
hi def link rustIdentifier Identifier
232234
hi def link rustCapsIdent rustIdentifier
@@ -247,6 +249,7 @@ hi def link rustTodo Todo
247249
hi def link rustAttribute PreProc
248250
hi def link rustDeriving PreProc
249251
hi def link rustStorage StorageClass
252+
hi def link rustObsoleteStorage Error
250253
hi def link rustLifetime Special
251254

252255
" Other Suggestions:

0 commit comments

Comments
 (0)