filetype: rust
-detect:
- filename: "\\.rs"
+detect:
+ filename: "\\.rs$"
rules:
- - identifier.class: "fn [a-z0-9_]+"
- - statement: "\\b(abstract|alignof|as|become|box|break|const|continue|crate|do|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"
- - identifier.macro: "[a-z_]+!"
- - constant: "[A-Z][A-Z_]+"
+ # function definition
+ - identifier: "fn [a-z0-9_]+"
+ # Reserved words
+ - 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"
+ # macros
+ - special: "[a-z_]+!"
+ # Constants
+ - constant: "\\b[A-Z][A-Z_0-9]+\\b"
+ # Numbers
- constant.number: "\\b[0-9]+\\b"
- - type: "[A-Z][a-z]+"
- - constant.string: "\\\".*\\\""
+ # Booleans
+ - constant: "\\b(true|false)\\b"
+ # Traits/Enums/Structs/Types/etc.
+ - type: "\\b[A-Z]+[a-zA-Z_0-9]*[a-z]+[a-zA-Z_0-9]*\\b"
+ # Builtin types that start with lowercase.
+ - type: "\\b(bool|str|isize|usize|((i|u)(8|16|32|64))|f32|f64)\\b"
+
- constant.string:
- start: "\\\".*\\\\$"
- end: ".*\\\""
- rules: []
+ start: "\""
+ end: "\""
+ skip: "\\\\."
+ rules:
+ - constant.specialChar: "\\\\."
- - special:
- start: "r#+\\\""
- end: "\\\"#+"
+ - constant.string:
+ start: "r#+\""
+ end: "\"#+"
rules: []
- - comment: "//.*"
+ - comment:
+ start: "//"
+ end: "$"
+ rules:
+ - todo: "(TODO|XXX|FIXME):?"
+
- comment:
start: "/\\*"
end: "\\*/"
- rules: []
+ rules:
+ - todo: "(TODO|XXX|FIXME):?"
- special:
start: "#!\\["
end: "\\]"
rules: []
- - todo: "(XXX|TODO|FIXME|\\?\\?\\?)"