about summary refs log tree commit diff
path: root/src/etc/vim/syntax/rust.vim
blob: 6cd5440b5daedb04346a175265bce12b158f77d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
" Vim syntax file
" Language:     Rust
" Maintainer:   Patrick Walton <pcwalton@mozilla.com>
" Last Change:  2010 Oct 13

" Quit when a syntax file was already loaded
if !exists("main_syntax")
  if version < 600
    syntax clear
  elseif exists("b:current_syntax")
    finish
  endif
  " we define it here so that included files can test for it
  let main_syntax='rust'
endif

syn keyword   rustKeyword     alt as assert auth be bind break chan check
syn keyword   rustKeyword     claim cont const do each else export fail fn for
syn keyword   rustKeyword     if import in inline iter lambda let log log_err
syn keyword   rustKeyword     macro meta mod mutable native note obj port
syn keyword   rustKeyword     prove pure put resource ret self spawn syntax
syn keyword   rustKeyword     tag type unsafe use while with

syn keyword   rustType        any int uint float char bool u8 u16 u32 u64 f32
syn keyword   rustType        f64 i8 i16 i32 i64 str task

syn keyword   rustBoolean     true false

syn match     rustItemPath    "\(\w\|::\)\+"

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

"integer number, or floating point number without a dot and with "f".
syn case ignore
syn match	  rustNumber		display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
"hex number
syn match	  rustNumber		display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
syn match	rustFloat		display contained "\d\+f"
"floating point number, with dot, optional exponent
syn match	rustFloat		display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
"floating point number, starting with a dot, optional exponent
syn match	rustFloat		display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
"floating point number, without dot, with exponent
syn match	rustFloat		display contained "\d\+e[-+]\=\d\+[fl]\=\>"

syn match   rustCharacter   "'[^']*'"

syn case match
syn region    rustComment     start="/\*" end="\*/"
syn region    rustComment     start="//" skip="\\$" end="$" keepend

hi def link rustString        String
hi def link rustCharacter     Character
hi def link rustNumber        Number
hi def link rustBoolean       Boolean
hi def link rustFloat         Float
hi def link rustKeyword       Keyword
hi def link rustComment       Comment
hi def link rustMacro         Macro
hi def link rustType          Type

let b:current_syntax = "rust"