]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/rust.yaml
Improve Rust syntax highlighting (#1820)
[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|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     - comment:
37         start: "//"
38         end: "$"
39         rules:
40             - todo: "(TODO|XXX|FIXME):?"
41
42     - comment:
43         start: "/\\*"
44         end: "\\*/"
45         rules:
46             - todo: "(TODO|XXX|FIXME):?"
47
48     - special:
49         start: "#!\\["
50         end: "\\]"
51         rules: []
52