2
2
" Language: Rust
3
3
" Maintainer: Patrick Walton <[email protected] >
4
4
" Maintainer: Ben Blum <[email protected] >
5
- " Last Change: 2012 Dec 25
5
+ " Last Change: 2012 Jun 14
6
6
7
7
if version < 600
8
8
syntax clear
@@ -13,13 +13,16 @@ endif
13
13
syn keyword rustConditional match if else
14
14
syn keyword rustOperator as
15
15
16
+ syn match rustAssert " \< assert\(\w\) *!"
17
+ syn match rustFail " \< fail\(\w\) *!"
16
18
syn keyword rustKeyword break copy do drop extern
17
19
syn keyword rustKeyword for if impl let log
18
20
syn keyword rustKeyword copy do extern
19
21
syn keyword rustKeyword for impl let log
20
22
syn keyword rustKeyword loop mod once priv pub
21
23
syn keyword rustKeyword return
22
- syn keyword rustKeyword unsafe use while
24
+ syn keyword rustKeyword unsafe while
25
+ syn keyword rustKeyword use nextgroup =rustModPath skipwhite
23
26
" FIXME: Scoped impl's name is also fallen in this category
24
27
syn keyword rustKeyword mod trait struct enum type nextgroup =rustIdentifier skipwhite
25
28
syn keyword rustKeyword fn nextgroup =rustFuncName skipwhite
@@ -45,7 +48,8 @@ syn keyword rustType c_longlong c_ulonglong intptr_t uintptr_t
45
48
syn keyword rustType off_t dev_t ino_t pid_t mode_t ssize_t
46
49
47
50
syn keyword rustTrait Const Copy Send Owned Sized " inherent traits
48
- syn keyword rustTrait Eq Ord Num Ptr
51
+ syn keyword rustTrait Clone Decodable Encodable IterBytes Rand ToStr
52
+ syn keyword rustTrait Eq Ord TotalEq TotalOrd Num Ptr
49
53
syn keyword rustTrait Drop Add Sub Mul Quot Rem Neg BitAnd BitOr
50
54
syn keyword rustTrait BitXor Shl Shr Index
51
55
@@ -72,19 +76,21 @@ syn keyword rustConstant STDIN_FILENO STDOUT_FILENO STDERR_FILENO
72
76
" If foo::bar changes to foo.bar, change this ("::" to "\.").
73
77
" If foo::bar changes to Foo::bar, change this (first "\w" to "\u").
74
78
syn match rustModPath " \w\(\w\) *::[^<]" he =e - 3 ,me =e - 3
79
+ syn match rustModPath " \w\(\w\) *" contained " only for 'use path;'
75
80
syn match rustModPathSep " ::"
76
81
77
82
syn match rustFuncCall " \w\(\w\) *(" he =e - 1 ,me =e - 1
78
83
syn match rustFuncCall " \w\(\w\) *::<" he =e - 3 ,me =e - 3 " foo::<T>();
79
84
80
- syn match rustMacro ' \w\(\w\) *!'
81
- syn match rustMacro ' #\w\(\w\) *'
85
+ syn match rustMacro ' \w\(\w\) *!' contains = rustAssert,rustFail
86
+ syn match rustMacro ' #\w\(\w\) *' contains = rustAssert,rustFail
82
87
83
88
syn match rustFormat display " %\(\d\+\$\)\= [-+' #0*]*\(\d *\|\*\|\*\d\+\$\)\(\.\(\d *\|\*\|\*\d\+\$\)\)\=\( [hlLjzt]\| ll\| hh\)\=\( [aAbdiuoxXDOUfFeEgGcCsSpn?]\|\[\^\= .[^]]*\]\) " contained
84
89
syn match rustFormat display " %%" contained
85
90
syn region rustString start =+ L\= "+ skip =+ \\\\\|\\ "+ end =+ "+ contains =rustTodo,rustFormat
86
91
87
- syn region rustAttribute start =" #\[ " end =" \] " contains =rustString
92
+ syn region rustAttribute start =" #\[ " end =" \] " contains =rustString,rustDeriving
93
+ syn region rustDeriving start =" deriving(" end =" )" contains =rustTrait
88
94
89
95
" Number literals
90
96
syn match rustNumber display " \< [0-9][0-9_]*\> "
@@ -143,11 +149,17 @@ hi def link rustMacro Macro
143
149
hi def link rustType Type
144
150
hi def link rustTodo Todo
145
151
hi def link rustAttribute PreProc
152
+ hi def link rustDeriving PreProc
146
153
hi def link rustStorage StorageClass
147
154
hi def link rustLifetime Special
148
155
149
156
" Other Suggestions:
157
+ " hi rustAttribute ctermfg=cyan
158
+ " hi rustDeriving ctermfg=cyan
159
+ " hi rustAssert ctermfg=yellow
160
+ " hi rustFail ctermfg=red
150
161
" hi rustMacro ctermfg=magenta
162
+ " hi rustModPathSep ctermfg=grey
151
163
152
164
syn sync minlines =200
153
165
syn sync maxlines =500
0 commit comments