Update v.yaml (#1925)

Improvements:
 - Use proper scope names for better colorization
 - Better regex to detect binary, octal, decimal and hexadecimal numbers
 - Extend some definitions based on the Vlang docs

Co-authored-by: AAAA <dev@onerbs.com>
This commit is contained in:
AAAA 2021-08-06 19:37:42 -05:00 committed by GitHub
parent e290ce2de5
commit cbe339da07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,34 +3,35 @@ filetype: v
detect: detect:
rules: rules:
# Conditionals and control flow # Conditionals and control flow
- keywords: "\\b(import|go|defer)\\b" - preproc: "\\b(module|import)\\b"
- special: "\\b(or|break|continue|match|case|goto|return|none)\\b" - statement: "\\b(if|else|for|match|select|defer|or|unsafe)\\b"
- function: "\\b(fn)\\b" - statement: "\\b(break|continue|goto|return)\\b"
- main_function: "\\b(fn main\\(\\))" - type.keyword: "\\b(assert|const|enum|fn|struct|interface|type)\\b"
- optionals: "\\b(none|error\\()" - type.keyword: "\\b(pub|mut|__global)\\b"
- statement: "\\b(if|else|for|match)\\b"
- assert: "\\b(assert)\\b"
- symbol.operator: "\\b([-+/*=<>!~%&|^])\\b"
- symbol.operator: "\\b(:=)\\b"
- symbol.operator: "\\b(\\|\\|)\b"
- symbol.operator: "\\b(\\&\\&)\\b"
- compile_if: "\\b(\\$if|\\$else)\\b" - preproc: "\\$\\b(if|else)\\b"
- oses: "\\b(mac|macos|linux|windows|freebsd|openbsd|netbsd|dragonfly|js|android|solaris|haiku)\\b" - identifier.os: "\\b(mac|macos|linux|windows|freebsd|openbsd|netbsd|dragonfly|android|solaris|haiku)\\b"
- identifier.compiler: "\\b(gcc|tinyc|clang|mingw|msvc|cplusplus)\\b"
- identifier.platform: "\\b(amd64|aarch64|x64|x32|little_endian|big_endian)\\b"
- identifier.other: "\\b(debug|test|js|glibc|prealloc|no_bounds_checking)\\b"
- identifier.class: "\\b([A-Z][A-Za-z0-9_]*)\\b"
- identifier.function: "\\b([a-z_]+\\()"
- symbol.operator: "\\b(i[ns])\\b|[-+/*<>!=~*%&:|,.?]"
- symbol.attribute:
start: "^\\["
end: "\\]$"
rules:
- default: ".*"
- symbol: "\\b(deprecated|direct_array_access|if|inline|live|ref_only|typedef|windows_stdcall)\\b"
# Types # Types
- symbol: "(,|\\.)" - type: "\\b(byte|u(16|32|64|128)|i(nt|8|16|64|128)|f(32|64))\\b"
- btype: "\\b(bool)\\b" - type: "\\b(bool|cha[nr]|map|rune|string)\\b"
- ztype: "\\b(char|byte)\\b" - type: "\\b(any(_int|_float)?|size_t|(uint|byte|char|void)ptr)\\b"
- itype: "\\b(int|i(8|16|64)|u(8|16|32|64))\\b"
- ftype: "\\b(f(32|64))\\b"
- ptype: "\\b(uintptr|charptr|byteptr|voidptr)\\b"
- atype: "\\b(array)\\b"
- stype: "\\b(string|ustring)\\b"
- mtype: "\\b(map)\\b"
- type.keyword: "\\b(pub|mut|struct|enum|interface|module|type|const)\\b"
- constant.bool: "\\b(true|false)\\b" - constant.bool: "\\b(true|false)\\b"
- constant.none: "\\b(none)\\b"
# Brackets # Brackets
- symbol.brackets: "(\\{|\\})" - symbol.brackets: "(\\{|\\})"
@ -38,7 +39,10 @@ rules:
- symbol.brackets: "(\\[|\\])" - symbol.brackets: "(\\[|\\])"
# Numbers and strings # Numbers and strings
- constant.number: "\\b([0-9]+|0x[0-9a-fA-F]*)\\b|'.'" - constant.number: "\\b(0b[01_]+)\\b"
- constant.number: "\\b(0o[0-7_]+)\\b"
- constant.number: "\\b(0x[0-9a-fA-F_]+)\\b"
- constant.number: "\\b([0-9_]+)\\b"
- constant.string: - constant.string:
start: "\"" start: "\""
@ -46,7 +50,7 @@ rules:
skip: "\\\\." skip: "\\\\."
rules: rules:
- constant.specialChar: "%." - constant.specialChar: "%."
- constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]" - constant.specialChar: "\\\\[abefnrtv'\\\"\\\\]"
- constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})" - constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
- constant.string: - constant.string:
@ -54,9 +58,8 @@ rules:
end: "'" end: "'"
skip: "\\\\." skip: "\\\\."
rules: rules:
- error: "..+"
- constant.specialChar: "%." - constant.specialChar: "%."
- constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]" - constant.specialChar: "\\\\[abefnrtv'\\\"\\\\]"
- constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})" - constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
- constant.string: - constant.string:
@ -75,10 +78,3 @@ rules:
end: "\\*/" end: "\\*/"
rules: rules:
- todo: "(TODO|XXX|FIXME):?" - todo: "(TODO|XXX|FIXME):?"
- function.attribute:
start: "^\\["
end: "\\]$"
rules:
- known: "\\b(deprecated|inline|typedef|if)\\b"