Skip to content

Commit 1e44e04

Browse files
committed
vim: Update syntax for number/float literals
1 parent 94b0edc commit 1e44e04

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

src/etc/vim/syntax/rust.vim

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,25 @@ syn match rustItemPath "\(\w\|::\)\+"
3939

4040
syn region rustString start=+L\="+ skip=+\\\\\|\\"+ end=+"+
4141

42-
"integer number, or floating point number without a dot and with "f".
43-
syn case ignore
44-
syn match rustNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
45-
"hex number
46-
syn match rustNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
47-
syn match rustFloat display contained "\d\+f"
48-
"floating point number, with dot, optional exponent
49-
syn match rustFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
50-
"floating point number, starting with a dot, optional exponent
51-
syn match rustFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
52-
"floating point number, without dot, with exponent
53-
syn match rustFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>"
54-
55-
syn case match
42+
" Number/Float literals
43+
syn match rustNumber display "\<\d\>"
44+
syn match rustNumber display "\<[1-9]\d\+\>"
45+
syn match rustNumber display "\<\d\+\(u\|u8\|u16\|u32\|u64\)\>"
46+
syn match rustNumber display "\<\d\+\(i8\|i16\|i32\|i64\)\>"
47+
48+
syn match rustHexNumber display "\<0[xX]\x\+\>"
49+
syn match rustHexNumber display "\<0[xX]\x\+_\(u\|u8\|u16\|u32\|u64\)\>"
50+
syn match rustHexNumber display "\<0[xX]\x\+_\(i8\|i16\|i32\|i64\)\>"
51+
syn match rustOctNumber display "\<0\o\+\>"
52+
syn match rustOctNumber display "\<0\o\+_\(u\|u8\|u16\|u32\|u64\)\>"
53+
syn match rustOctNumber display "\<0\o\+_\(i8\|i16\|i32\|i64\)\>"
54+
syn match rustBinNumber display "\<0[bB][01]\+\>"
55+
syn match rustBinNumber display "\<0[bB][01]\+_\(u\|u8\|u16\|u32\|u64\)\>"
56+
syn match rustBinNumber display "\<0[bB][01]\+_\(i8\|i16\|i32\|i64\)\>"
57+
58+
syn match rustFloat display "\.\d\+\%([eE][+-]\=\d\+\)\=\>"
59+
syn match rustFloat display "\<\d\+[eE][+-]\=\d\+\>"
60+
syn match rustFloat display "\<\d\+\.\d*\%([eE][+-]\=\d\+\)\="
5661

5762
syn match rustCharacter "'\([^'\\]\|\\\(['nrt\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'"
5863

@@ -61,6 +66,10 @@ syn region rustComment start="//" skip="\\$" end="$" contains=rustTodo ke
6166

6267
syn keyword rustTodo TODO FIXME XXX NB
6368

69+
hi def link rustHexNumber rustNumber
70+
hi def link rustOctNumber rustNumber
71+
hi def link rustBinNumber rustNumber
72+
6473
hi def link rustString String
6574
hi def link rustCharacter Character
6675
hi def link rustNumber Number

0 commit comments

Comments
 (0)