Unnamed repository; edit this file 'description' to name the repository.
reverse zig highlights (#12777)
| -rw-r--r-- | runtime/queries/zig/highlights.scm | 382 |
1 files changed, 196 insertions, 186 deletions
diff --git a/runtime/queries/zig/highlights.scm b/runtime/queries/zig/highlights.scm index 0b683158..07960d18 100644 --- a/runtime/queries/zig/highlights.scm +++ b/runtime/queries/zig/highlights.scm @@ -1,105 +1,133 @@ -; Comments +; Variables -((comment) @comment.block.documentation - (#match? @comment.block.documentation "^//!")) +(identifier) @variable -(comment) @comment.line +; Parameters -; Punctuation +(parameter + name: (identifier) @variable.parameter) + +(payload + (identifier) @variable.parameter) + +; Types + +(parameter + type: (identifier) @type) + +((identifier) @type + (#match? @type "^[A-Z_][a-zA-Z0-9_]*")) + +(variable_declaration + (identifier) @type + "=" + [ + (struct_declaration) + (enum_declaration) + (union_declaration) + (opaque_declaration) + ]) [ - "[" - "]" - "(" - ")" - "{" - "}" -] @punctuation.bracket + (builtin_type) + "anyframe" +] @type.builtin + +; Constants + +((identifier) @constant + (#match? @constant "^[A-Z][A-Z_0-9]+$")) [ - ";" - "." - "," - ":" - "=>" - "->" -] @punctuation.delimiter + "null" + "unreachable" + "undefined" +] @constant.builtin -(payload "|" @punctuation.bracket) +(field_expression + . + member: (identifier) @constant) -; Literals +(enum_declaration + (container_field + type: (identifier) @constant)) -(character) @constant.character +; Labels -[ - (string) - (multiline_string) -] @string +(block_label + (identifier) @label) -(integer) @constant.numeric.integer +(break_label + (identifier) @label) -(float) @constant.numeric.float +; Fields -(boolean) @constant.builtin.boolean +(field_initializer + . + (identifier) @variable.other.member) -(escape_sequence) @constant.character.escape +(field_expression + (_) + member: (identifier) @variable.other.member) -; Operator +(field_expression + (_) + member: (identifier) @type (#match? @type "^[A-Z_][a-zA-Z0-9_]*")) + +(field_expression + (_) + member: (identifier) @constant (#match? @constant "^[A-Z][A-Z_0-9]+$")) + +(container_field + name: (identifier) @variable.other.member) + +(initializer_list + (assignment_expression + left: (field_expression + . + member: (identifier) @variable.other.member))) + +; Functions + +(builtin_identifier) @function.builtin + +(call_expression + function: (identifier) @function) + +(call_expression + function: (field_expression + member: (identifier) @function.method)) + +(function_declaration + name: (identifier) @function) + +; Modules + +(variable_declaration + (_) + (builtin_function + (builtin_identifier) @keyword.control.import + (#any-of? @keyword.control.import "@import" "@cImport"))) + +(variable_declaration + (_) + (field_expression + object: (builtin_function + (builtin_identifier) @keyword.control.import + (#any-of? @keyword.control.import "@import" "@cImport")))) + +; Builtins [ - "=" - "*=" - "*%=" - "*|=" - "/=" - "%=" - "+=" - "+%=" - "+|=" - "-=" - "-%=" - "-|=" - "<<=" - "<<|=" - ">>=" - "&=" - "^=" - "|=" - "!" - "~" - "-" - "-%" - "&" - "==" - "!=" - ">" - ">=" - "<=" - "<" - "&" - "^" - "|" - "<<" - ">>" - "<<|" - "+" - "++" - "+%" - "-%" - "+|" - "-|" - "*" - "/" - "%" - "**" - "*%" - "*|" - "||" - ".*" - ".?" - "?" - ".." -] @operator + "c" + "..." +] @variable.builtin + +((identifier) @variable.builtin + (#eq? @variable.builtin "_")) + +(calling_convention + (identifier) @variable.builtin) ; Keywords @@ -182,123 +210,105 @@ "threadlocal" ] @keyword.storage.modifier -; Builtins +; Operator [ - "c" - "..." -] @variable.builtin - -((identifier) @variable.builtin - (#eq? @variable.builtin "_")) - -(calling_convention - (identifier) @variable.builtin) - -; Modules - -(variable_declaration - (identifier) @variable ; TODO: module - (builtin_function - (builtin_identifier) @keyword.control.import - (#any-of? @keyword.control.import "@import" "@cImport"))) - -(variable_declaration - (identifier) @variable ; TODO: module - (field_expression - object: (builtin_function - (builtin_identifier) @keyword.control.import - (#any-of? @keyword.control.import "@import" "@cImport")))) - -; Functions - -(call_expression - function: (field_expression - member: (identifier) @function.method)) - -(call_expression - function: (identifier) @function) - -(function_declaration - name: (identifier) @function) - -(builtin_identifier) @function.builtin - -; Fields - -(field_initializer - . - (identifier) @variable.other.member) - -(field_expression - (_) - member: (identifier) @type (#match? @type "^[A-Z_][a-zA-Z0-9_]*")) - -(field_expression - (_) - member: (identifier) @variable.other.member) - -(container_field - name: (identifier) @variable.other.member) - -(initializer_list - (assignment_expression - left: (field_expression - . - member: (identifier) @variable.other.member))) - -; Labels - -(block_label (identifier) @label) - -(break_label (identifier) @label) + "=" + "*=" + "*%=" + "*|=" + "/=" + "%=" + "+=" + "+%=" + "+|=" + "-=" + "-%=" + "-|=" + "<<=" + "<<|=" + ">>=" + "&=" + "^=" + "|=" + "!" + "~" + "-" + "-%" + "&" + "==" + "!=" + ">" + ">=" + "<=" + "<" + "&" + "^" + "|" + "<<" + ">>" + "<<|" + "+" + "++" + "+%" + "-%" + "+|" + "-|" + "*" + "/" + "%" + "**" + "*%" + "*|" + "||" + ".*" + ".?" + "?" + ".." +] @operator -; Constants +; Literals -((identifier) @constant - (#match? @constant "^[A-Z][A-Z_0-9]+$")) +(character) @constant.character [ - "null" - "undefined" -] @constant.builtin + (string) + (multiline_string) +] @string -(field_expression - . - member: (identifier) @constant) +(integer) @constant.numeric.integer -(enum_declaration - (container_field - type: (identifier) @constant)) +(float) @constant.numeric.float -; Types +(boolean) @constant.builtin.boolean -(parameter - type: (identifier) @type) +(escape_sequence) @constant.character.escape -((identifier) @type - (#match? @type "^[A-Z_][a-zA-Z0-9_]*")) +; Punctuation -(variable_declaration - (identifier) @type - "=" - [ - (struct_declaration) - (enum_declaration) - (union_declaration) - (opaque_declaration) - ]) +[ + "[" + "]" + "(" + ")" + "{" + "}" +] @punctuation.bracket [ - (builtin_type) - "anyframe" -] @type.builtin + ";" + "." + "," + ":" + "=>" + "->" +] @punctuation.delimiter -; Parameters +(payload "|" @punctuation.bracket) -(parameter - name: (identifier) @variable.parameter) +; Comments -; Variables +(comment) @comment.line -(identifier) @variable +((comment) @comment.block.documentation + (#match? @comment.block.documentation "^//!")) |