Skip to content

Commit 181538a

Browse files
committed
auto merge of #18023 : chris-morgan/rust/vim-misc-2014-10-14, r=kballard
- Stop highlighting foo in `use foo;` specially. - Highlight `extern crate "foo" as bar;` properly. - Highlight 1..2 according to the current grammar.
2 parents 1fd8e4c + a118bd7 commit 181538a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/etc/vim/syntax/rust.vim

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ syn keyword rustKeyword for in if impl let
2727
syn keyword rustKeyword loop once proc pub
2828
syn keyword rustKeyword return super
2929
syn keyword rustKeyword unsafe virtual where while
30-
syn keyword rustKeyword use nextgroup=rustModPath,rustModPathInUse skipwhite skipempty
30+
syn keyword rustKeyword use nextgroup=rustModPath skipwhite skipempty
3131
" FIXME: Scoped impl's name is also fallen in this category
3232
syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite skipempty
3333
syn keyword rustStorage mut ref static const
3434

3535
syn keyword rustInvalidBareKeyword crate
3636

37-
syn keyword rustExternCrate crate contained nextgroup=rustIdentifier skipwhite skipempty
37+
syn keyword rustExternCrate crate contained nextgroup=rustIdentifier,rustExternCrateString skipwhite skipempty
38+
" This is to get the `bar` part of `extern crate "foo" as bar;` highlighting.
39+
syn match rustExternCrateString /".*"\_s*as/ contained nextgroup=rustIdentifier skipwhite transparent skipempty contains=rustString,rustOperator
3840
syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite skipempty
3941

4042
syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
@@ -131,9 +133,7 @@ syn keyword rustBoolean true false
131133
" If foo::bar changes to foo.bar, change this ("::" to "\.").
132134
" If foo::bar changes to Foo::bar, change this (first "\w" to "\u").
133135
syn match rustModPath "\w\(\w\)*::[^<]"he=e-3,me=e-3
134-
syn match rustModPathInUse "\w\(\w\)*" contained " only for 'use path;'
135136
syn match rustModPathSep "::"
136-
" rustModPathInUse is split out from rustModPath so that :syn-include can get the group list right.
137137

138138
syn match rustFuncCall "\w\(\w\)*("he=e-1,me=e-1
139139
syn match rustFuncCall "\w\(\w\)*::<"he=e-3,me=e-3 " foo::<T>();
@@ -172,9 +172,10 @@ syn match rustOctNumber display "\<0o[0-7_]\+\%([iu]\%(8\|16\|32\|64\)\=\)
172172
syn match rustBinNumber display "\<0b[01_]\+\%([iu]\%(8\|16\|32\|64\)\=\)\="
173173

174174
" Special case for numbers of the form "1." which are float literals, unless followed by
175-
" an identifier, which makes them integer literals with a method call or field access.
175+
" an identifier, which makes them integer literals with a method call or field access,
176+
" or by another ".", which makes them integer literals followed by the ".." token.
176177
" (This must go first so the others take precedence.)
177-
syn match rustFloat display "\<[0-9][0-9_]*\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\@!"
178+
syn match rustFloat display "\<[0-9][0-9_]*\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\|\.\)\@!"
178179
" To mark a number as a normal float, it must have at least one of the three things integral values don't have:
179180
" a decimal point and more numbers; an exponent; and a type suffix.
180181
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)\="
@@ -252,7 +253,6 @@ hi def link rustReservedKeyword Error
252253
hi def link rustConditional Conditional
253254
hi def link rustIdentifier Identifier
254255
hi def link rustCapsIdent rustIdentifier
255-
hi def link rustModPathInUse rustModPath
256256
hi def link rustModPath Include
257257
hi def link rustModPathSep Delimiter
258258
hi def link rustFunction Function

0 commit comments

Comments
 (0)