@@ -15,11 +15,17 @@ if !exists("main_syntax")
15
15
endif
16
16
17
17
syn keyword rustKeyword alt as assert be bind break
18
- syn keyword rustKeyword check claim cont const copy do else enum export fail
19
- syn keyword rustKeyword fn for if iface impl import in inline lambda let log
18
+ syn keyword rustKeyword check claim cont const copy do else export fail
19
+ syn keyword rustKeyword for if impl import in inline lambda let log
20
20
syn keyword rustKeyword loop mod mut mutable native note of prove pure
21
- syn keyword rustKeyword resource ret self syntax to type unchecked
21
+ syn keyword rustKeyword ret self syntax to unchecked
22
22
syn keyword rustKeyword unsafe use while with
23
+ " FIXME: Scoped impl's name is also fallen in this category
24
+ syn keyword rustKeyword mod iface resource class enum type nextgroup =rustIdentifier skipwhite
25
+ syn keyword rustKeyword fn nextgroup =rustFuncName skipwhite
26
+
27
+ syn match rustIdentifier " \% ([^[:cntrl:][:space:][:punct:][:digit:]]\| _\)\% ([^[:cntrl:][:punct:][:space:]]\| _\) *" display contained
28
+ syn match rustFuncName " \% ([^[:cntrl:][:space:][:punct:][:digit:]]\| _\)\% ([^[:cntrl:][:punct:][:space:]]\| _\) *" display contained
23
29
24
30
" Reserved words
25
31
syn keyword rustKeyword m32 m64 m128 f80 f16 f128 class trait
@@ -33,35 +39,48 @@ syn match rustItemPath "\(\w\|::\)\+"
33
39
34
40
syn region rustString start =+ L\= "+ skip =+ \\\\\|\\ "+ end =+ "+
35
41
36
- " integer number, or floating point number without a dot and with "f".
37
- syn case ignore
38
- syn match rustNumber display contained " \d\+\( u\= l\{ 0,2}\| ll\= u\)\> "
39
- " hex number
40
- syn match rustNumber display contained " 0x\x\+\( u\= l\{ 0,2}\| ll\= u\)\> "
41
- syn match rustFloat display contained " \d\+ f"
42
- " floating point number, with dot, optional exponent
43
- syn match rustFloat display contained " \d\+\.\d *\( e[-+]\=\d\+\)\= [fl]\= "
44
- " floating point number, starting with a dot, optional exponent
45
- syn match rustFloat display contained " \.\d\+\( e[-+]\=\d\+\)\= [fl]\=\> "
46
- " floating point number, without dot, with exponent
47
- syn match rustFloat display contained " \d\+ e[-+]\=\d\+ [fl]\=\> "
48
-
49
- syn case match
42
+ " Number literals
43
+ syn match rustNumber display " \< [0-9][0-9_]*\> "
44
+ syn match rustNumber display " \< [0-9][0-9_]*\( u\| u8\| u16\| u32\| u64\)\> "
45
+ syn match rustNumber display " \< [0-9][0-9_]*\( i8\| i16\| i32\| i64\)\> "
46
+
47
+ syn match rustHexNumber display " \< 0x[a-fA-F0-9_]\+\> "
48
+ syn match rustHexNumber display " \< 0x[a-fA-F0-9_]\+\( u\| u8\| u16\| u32\| u64\)\> "
49
+ syn match rustHexNumber display " \< 0x[a-fA-F0-9_]\+\( i8\| i16\| i32\| i64\)\> "
50
+ syn match rustBinNumber display " \< 0b[01_]\+\> "
51
+ syn match rustBinNumber display " \< 0b[01_]\+\( u\| u8\| u16\| u32\| u64\)\> "
52
+ syn match rustBinNumber display " \< 0b[01_]\+\( i8\| i16\| i32\| i64\)\> "
53
+
54
+ syn match rustFloat display " \< [0-9][0-9_]*\( f\| f32\| f64\)\> "
55
+ syn match rustFloat display " \< [0-9][0-9_]*\( [eE][+-]\= [0-9_]\+\)\> "
56
+ syn match rustFloat display " \< [0-9][0-9_]*\( [eE][+-]\= [0-9_]\+\)\( f\| f32\| f64\)\> "
57
+ syn match rustFloat display " \< [0-9][0-9_]*\. [0-9_]\+\> "
58
+ syn match rustFloat display " \< [0-9][0-9_]*\. [0-9_]\+\( f\| f32\| f64\)\> "
59
+ syn match rustFloat display " \< [0-9][0-9_]*\. [0-9_]\+\% ([eE][+-]\= [0-9_]\+\)\> "
60
+ syn match rustFloat display " \< [0-9][0-9_]*\. [0-9_]\+\% ([eE][+-]\= [0-9_]\+\)\( f\| f32\| f64\)\> "
50
61
51
62
syn match rustCharacter " '\( [^'\\ ]\|\\\( ['nrt\\\" ]\| x\x\{ 2}\| u\x\{ 4}\| U\x\{ 8}\)\) '"
52
63
53
- syn region rustComment start =" /\* " end =" \* /" contains =rustComment
54
- syn region rustComment start =" //" skip =" \\ $" end =" $" keepend
64
+ syn region rustComment start =" /\* " end =" \* /" contains =rustComment,rustTodo
65
+ syn region rustComment start =" //" skip =" \\ $" end =" $" contains =rustTodo keepend
66
+
67
+ syn keyword rustTodo TODO FIXME XXX NB
68
+
69
+ hi def link rustHexNumber rustNumber
70
+ hi def link rustBinNumber rustNumber
55
71
56
72
hi def link rustString String
57
73
hi def link rustCharacter Character
58
74
hi def link rustNumber Number
59
75
hi def link rustBoolean Boolean
60
76
hi def link rustFloat Float
61
77
hi def link rustKeyword Keyword
78
+ hi def link rustIdentifier Identifier
79
+ hi def link rustFuncName Function
62
80
hi def link rustComment Comment
63
81
hi def link rustMacro Macro
64
82
hi def link rustType Type
83
+ hi def link rustTodo Todo
65
84
66
85
syn sync minlines =200
67
86
syn sync maxlines =500
0 commit comments