]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/rust.yaml
Add support for rust async/await keywords
[micro.git] / runtime / syntax / rust.yaml
1 filetype: rust
2
3 detect:
4     filename: "\\.rs$"
5
6 rules:
7     # function definition
8     - identifier: "fn [a-z0-9_]+"
9       # Reserved words
10     - statement: "\\b(abstract|alignof|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\\b"
11       # macros
12     - special: "[a-z_]+!"
13       # Constants
14     - constant: "\\b[A-Z][A-Z_0-9]+\\b"
15       # Numbers
16     - constant.number: "\\b[0-9]+\\b"
17       # Booleans
18     - constant: "\\b(true|false)\\b"
19       # Traits/Enums/Structs/Types/etc.
20     - type: "\\b[A-Z]+[a-zA-Z_0-9]*[a-z]+[a-zA-Z_0-9]*\\b"
21       # Builtin types that start with lowercase.
22     - type: "\\b(bool|str|isize|usize|((i|u)(8|16|32|64))|f32|f64)\\b"
23
24     - constant.string:
25         start: "\""
26         end: "\""
27         skip: '\\.'
28         rules:
29             - constant.specialChar: '\\.'
30
31     - constant.string:
32         start: "r#+\""
33         end: "\"#+"
34         rules: []
35
36     # Character literals
37     # NOTE: This is an ugly hack to work around the fact that rust uses
38     # single quotes both for character literals and lifetimes.
39     # Match all character literals.
40     - constant.string: "'(\\\\.|.)'"
41     # Match the '"' literal which would otherwise match
42     # as a double quoted string and destroy the highlighting.
43     - constant.string:
44         start: "'\""
45         end: "'"
46         rules: []
47
48     - comment:
49         start: "//"
50         end: "$"
51         rules:
52             - todo: "(TODO|XXX|FIXME):?"
53
54     - comment:
55         start: "/\\*"
56         end: "\\*/"
57         rules:
58             - todo: "(TODO|XXX|FIXME):?"
59
60     - special:
61         start: "#!\\["
62         end: "\\]"
63         rules: []