| 1 |
filetype: v |
| 2 |
|
| 3 |
detect: |
| 4 |
|
| 5 |
rules: |
| 6 |
# Conditionals and control flow |
| 7 |
- preproc: "\\b(module|import)\\b" |
| 8 |
- statement: "\\b(if|else|for|match|select|defer|or|unsafe)\\b" |
| 9 |
- statement: "\\b(break|continue|goto|return)\\b" |
| 10 |
- type.keyword: "\\b(assert|const|enum|fn|struct|interface|type)\\b" |
| 11 |
- type.keyword: "\\b(pub|mut|__global)\\b" |
| 12 |
|
| 13 |
- preproc: "\\$\\b(if|else)\\b" |
| 14 |
- identifier.os: "\\b(mac|macos|linux|windows|freebsd|openbsd|netbsd|dragonfly|android|solaris|haiku)\\b" |
| 15 |
- identifier.compiler: "\\b(gcc|tinyc|clang|mingw|msvc|cplusplus)\\b" |
| 16 |
- identifier.platform: "\\b(amd64|aarch64|x64|x32|little_endian|big_endian)\\b" |
| 17 |
- identifier.other: "\\b(debug|test|js|glibc|prealloc|no_bounds_checking)\\b" |
| 18 |
|
| 19 |
- identifier.class: "\\b([A-Z][A-Za-z0-9_]*)\\b" |
| 20 |
- identifier.function: "\\b([a-z_]+\\()" |
| 21 |
- symbol.operator: "\\b(i[ns])\\b|[-+/*<>!=~*%&:|,.?]" |
| 22 |
- symbol.attribute: |
| 23 |
start: "^\\[" |
| 24 |
end: "\\]$" |
| 25 |
rules: |
| 26 |
- default: ".*" |
| 27 |
- symbol: "\\b(deprecated|direct_array_access|if|inline|live|ref_only|typedef|windows_stdcall)\\b" |
| 28 |
|
| 29 |
# Types |
| 30 |
- type: "\\b(byte|u(16|32|64|128)|i(nt|8|16|64|128)|f(32|64))\\b" |
| 31 |
- type: "\\b(bool|cha[nr]|map|rune|string)\\b" |
| 32 |
- type: "\\b(any(_int|_float)?|size_t|(uint|byte|char|void)ptr)\\b" |
| 33 |
- constant.bool: "\\b(true|false)\\b" |
| 34 |
- constant.none: "\\b(none)\\b" |
| 35 |
|
| 36 |
# Brackets |
| 37 |
- symbol.brackets: "(\\{|\\})" |
| 38 |
- symbol.brackets: "(\\(|\\))" |
| 39 |
- symbol.brackets: "(\\[|\\])" |
| 40 |
|
| 41 |
# Numbers and strings |
| 42 |
- constant.number: "\\b(0b[01_]+)\\b" |
| 43 |
- constant.number: "\\b(0o[0-7_]+)\\b" |
| 44 |
- constant.number: "\\b(0x[0-9a-fA-F_]+)\\b" |
| 45 |
- constant.number: "\\b([0-9_]+)\\b" |
| 46 |
|
| 47 |
- constant.string: |
| 48 |
start: "\"" |
| 49 |
end: "\"" |
| 50 |
skip: "\\\\." |
| 51 |
rules: |
| 52 |
- constant.specialChar: "%." |
| 53 |
- constant.specialChar: "\\\\[abefnrtv'\\\"\\\\]" |
| 54 |
- constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})" |
| 55 |
|
| 56 |
- constant.string: |
| 57 |
start: "'" |
| 58 |
end: "'" |
| 59 |
skip: "\\\\." |
| 60 |
rules: |
| 61 |
- constant.specialChar: "%." |
| 62 |
- constant.specialChar: "\\\\[abefnrtv'\\\"\\\\]" |
| 63 |
- constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})" |
| 64 |
|
| 65 |
- constant.string: |
| 66 |
start: "`" |
| 67 |
end: "`" |
| 68 |
rules: [] |
| 69 |
|
| 70 |
- comment: |
| 71 |
start: "//" |
| 72 |
end: "$" |
| 73 |
rules: |
| 74 |
- todo: "(TODO|XXX|FIXME):?" |
| 75 |
|
| 76 |
- comment: |
| 77 |
start: "/\\*" |
| 78 |
end: "\\*/" |
| 79 |
rules: |
| 80 |
- todo: "(TODO|XXX|FIXME):?" |