Skip to content

Commit 2bde046

Browse files
yorik1984Notgnoshi
authored andcommitted
Highlight integer literal suffixes differently rust-lang#468
1 parent a3f180e commit 2bde046

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

syntax/rust.vim

+13-7
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ syn match rustKeyword "\<dyn\ze\_s\+\%([^[:cntrl:][:space:][:punct:][:digit:
175175
syn keyword rustDynKeyword dyn contained
176176

177177
" Number literals
178-
syn match rustDecNumber display "\<[0-9][0-9_]*\%([iu]\%(size\|8\|16\|32\|64\|128\)\)\="
179-
syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\%([iu]\%(size\|8\|16\|32\|64\|128\)\)\="
180-
syn match rustOctNumber display "\<0o[0-7_]\+\%([iu]\%(size\|8\|16\|32\|64\|128\)\)\="
181-
syn match rustBinNumber display "\<0b[01_]\+\%([iu]\%(size\|8\|16\|32\|64\|128\)\)\="
178+
syn match rustDecNumber display "\<[0-9][0-9_]*\%([iu]\%(size\|8\|16\|32\|64\|128\)\)\=" contains=rustNumberSuffix
179+
syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\%([iu]\%(size\|8\|16\|32\|64\|128\)\)\=" contains=rustNumberSuffix
180+
syn match rustOctNumber display "\<0o[0-7_]\+\%([iu]\%(size\|8\|16\|32\|64\|128\)\)\=" contains=rustNumberSuffix
181+
syn match rustBinNumber display "\<0b[01_]\+\%([iu]\%(size\|8\|16\|32\|64\|128\)\)\=" contains=rustNumberSuffix
182182

183183
" Special case for numbers of the form "1." which are float literals, unless followed by
184184
" an identifier, which makes them integer literals with a method call or field access,
@@ -187,9 +187,13 @@ syn match rustBinNumber display "\<0b[01_]\+\%([iu]\%(size\|8\|16\|32\|64\
187187
syn match rustFloat display "\<[0-9][0-9_]*\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\|\.\)\@!"
188188
" To mark a number as a normal float, it must have at least one of the three things integral values don't have:
189189
" a decimal point and more numbers; an exponent; and a type suffix.
190-
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)\="
191-
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\(f32\|f64\)\="
192-
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)"
190+
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)\=" contains=rustFloatSuffix
191+
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\(f32\|f64\)\=" contains=rustFloatSuffix
192+
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)" contains=rustFloatSuffix
193+
194+
" Number literals suffix
195+
syn match rustNumberSuffix "\([_]*[iu]\(size\|8\|16\|32\|64\|128\)\)" contained display
196+
syn match rustFloatSuffix "\([_]*\(f32\|f64\)\)" contained display
193197

194198
" For the benefit of delimitMate
195199
syn region rustLifetimeCandidate display start=/&'\%(\([^'\\]\|\\\(['nrt0\\\"]\|x\x\{2}\|u{\%(\x_*\)\{1,6}}\)\)'\)\@!/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustSigil,rustLifetime
@@ -312,12 +316,14 @@ hi def link rustCharacterInvalid Error
312316
hi def link rustCharacterInvalidUnicode rustCharacterInvalid
313317
hi def link rustCharacter Character
314318
hi def link rustNumber Number
319+
hi rustNumberSuffix gui=italic cterm=italic
315320
hi def link rustBoolean Boolean
316321
hi def link rustEnum rustType
317322
hi def link rustEnumVariant rustConstant
318323
hi def link rustConstant Constant
319324
hi def link rustSelf Constant
320325
hi def link rustFloat Float
326+
hi rustFloatSuffix gui=italic cterm=italic
321327
hi def link rustArrowCharacter rustOperator
322328
hi def link rustOperator Operator
323329
hi def link rustKeyword Keyword

0 commit comments

Comments
 (0)