diff options
Diffstat (limited to 'runtime/queries')
1152 files changed, 64147 insertions, 0 deletions
diff --git a/runtime/queries/ada/folds.scm b/runtime/queries/ada/folds.scm new file mode 100644 index 000000000..8e3defac4 --- /dev/null +++ b/runtime/queries/ada/folds.scm @@ -0,0 +1,13 @@ +; Support for folding in Ada +; za toggles folding a package, subprogram, if statement or loop +[ + (package_declaration) + (generic_package_declaration) + (package_body) + (subprogram_body) + (block_statement) + (if_statement) + (loop_statement) + (gnatprep_declarative_if_statement) + (gnatprep_if_statement) +] @fold diff --git a/runtime/queries/ada/highlights.scm b/runtime/queries/ada/highlights.scm new file mode 100644 index 000000000..0d42b70f9 --- /dev/null +++ b/runtime/queries/ada/highlights.scm @@ -0,0 +1,286 @@ +; highlight queries. +; See the syntax at https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries +; See also https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#parser-configurations +; for a list of recommended @ tags, though not all of them have matching +; highlights in neovim. +[ + "abort" + "abs" + "abstract" + "accept" + "access" + "all" + "array" + "at" + "begin" + "body" + "declare" + "delay" + "delta" + "digits" + "do" + "end" + "entry" + "exit" + "generic" + "interface" + "is" + "limited" + "mod" + "new" + "null" + "of" + "others" + "out" + "overriding" + "package" + "pragma" + "private" + "protected" + "range" + "separate" + "subtype" + "synchronized" + "tagged" + "task" + "terminate" + "type" + "until" + "when" +] @keyword + +"record" @keyword.type + +[ + "aliased" + "constant" + "renames" +] @keyword.modifier + +[ + "with" + "use" +] @keyword.import + +[ + "function" + "procedure" +] @keyword.function + +[ + "and" + "in" + "not" + "or" + "xor" +] @keyword.operator + +[ + "while" + "loop" + "for" + "parallel" + "reverse" + "some" +] @keyword.repeat + +"return" @keyword.return + +[ + "case" + "if" + "else" + "then" + "elsif" + "select" +] @keyword.conditional + +[ + "exception" + "raise" +] @keyword.exception + +(comment) @comment @spell + +(string_literal) @string + +(character_literal) @string + +(numeric_literal) @number + +; Highlight the name of subprograms +(procedure_specification + name: (_) @function) + +(function_specification + name: (_) @function) + +(package_declaration + name: (_) @function) + +(package_body + name: (_) @function) + +(generic_instantiation + name: (_) @function) + +(entry_declaration + . + (identifier) @function) + +; Some keywords should take different categories depending on the context +(use_clause + "use" @keyword.import + "type" @keyword.import) + +(with_clause + "private" @keyword.import) + +(with_clause + "limited" @keyword.import) + +(use_clause + (_) @module) + +(with_clause + (_) @module) + +(loop_statement + "end" @keyword.repeat) + +(if_statement + "end" @keyword.conditional) + +(loop_parameter_specification + "in" @keyword.repeat) + +(loop_parameter_specification + "in" @keyword.repeat) + +(iterator_specification + [ + "in" + "of" + ] @keyword.repeat) + +(range_attribute_designator + "range" @keyword.repeat) + +(raise_statement + "with" @keyword.exception) + +(gnatprep_declarative_if_statement) @keyword.directive + +(gnatprep_if_statement) @keyword.directive + +(gnatprep_identifier) @keyword.directive + +(subprogram_declaration + "is" @keyword.function + "abstract" @keyword.function) + +(aspect_specification + "with" @keyword.function) + +(full_type_declaration + "is" @keyword.type) + +(subtype_declaration + "is" @keyword.type) + +(record_definition + "end" @keyword.type) + +(full_type_declaration + (_ + "access" @keyword.type)) + +(array_type_definition + "array" @keyword.type + "of" @keyword.type) + +(access_to_object_definition + "access" @keyword.type) + +(access_to_object_definition + "access" @keyword.type + [ + (general_access_modifier + "constant" @keyword.type) + (general_access_modifier + "all" @keyword.type) + ]) + +(range_constraint + "range" @keyword.type) + +(signed_integer_type_definition + "range" @keyword.type) + +(index_subtype_definition + "range" @keyword.type) + +(record_type_definition + "abstract" @keyword.type) + +(record_type_definition + "tagged" @keyword.type) + +(record_type_definition + "limited" @keyword.type) + +(record_type_definition + (record_definition + "null" @keyword.type)) + +(private_type_declaration + "is" @keyword.type + "private" @keyword.type) + +(private_type_declaration + "tagged" @keyword.type) + +(private_type_declaration + "limited" @keyword.type) + +(task_type_declaration + "task" @keyword.type + "is" @keyword.type) + +; Gray the body of expression functions +(expression_function_declaration + (function_specification) + "is" + (_) @attribute) + +(subprogram_declaration + (aspect_specification) @attribute) + +; Highlight full subprogram specifications +;(subprogram_body +; [ +; (procedure_specification) +; (function_specification) +; ] @function.spec +;) +((comment) @comment.documentation + . + [ + (entry_declaration) + (subprogram_declaration) + (parameter_specification) + ]) + +(compilation_unit + . + (comment) @comment.documentation) + +(component_list + (component_declaration) + . + (comment) @comment.documentation) + +(enumeration_type_definition + (identifier) + . + (comment) @comment.documentation) diff --git a/runtime/queries/ada/injections.scm b/runtime/queries/ada/injections.scm new file mode 100644 index 000000000..f9754504e --- /dev/null +++ b/runtime/queries/ada/injections.scm @@ -0,0 +1,5 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((doc_block) @injection.content + (#set! injection.language "markdown")) diff --git a/runtime/queries/ada/locals.scm b/runtime/queries/ada/locals.scm new file mode 100644 index 000000000..bdfc38be8 --- /dev/null +++ b/runtime/queries/ada/locals.scm @@ -0,0 +1,91 @@ +; Better highlighting by referencing to the definition, for variable +; references. However, this is not yet supported by neovim +; See https://tree-sitter.github.io/tree-sitter/syntax-highlighting#local-variables +(compilation) @local.scope + +(package_declaration) @local.scope + +(package_body) @local.scope + +(subprogram_declaration) @local.scope + +(subprogram_body) @local.scope + +(block_statement) @local.scope + +(with_clause + (identifier) @local.definition.import) + +(procedure_specification + name: (_) @local.definition.function) + +(function_specification + name: (_) @local.definition.function) + +(package_declaration + name: (_) @local.definition.var) + +(package_body + name: (_) @local.definition.var) + +(generic_instantiation + . + name: (_) @local.definition.var) + +(component_declaration + . + (identifier) @local.definition.var) + +(exception_declaration + . + (identifier) @local.definition.var) + +(formal_object_declaration + . + (identifier) @local.definition.var) + +(object_declaration + . + (identifier) @local.definition.var) + +(parameter_specification + . + (identifier) @local.definition.var) + +(full_type_declaration + . + (identifier) @local.definition.type) + +(private_type_declaration + . + (identifier) @local.definition.type) + +(private_extension_declaration + . + (identifier) @local.definition.type) + +(incomplete_type_declaration + . + (identifier) @local.definition.type) + +(protected_type_declaration + . + (identifier) @local.definition.type) + +(formal_complete_type_declaration + . + (identifier) @local.definition.type) + +(formal_incomplete_type_declaration + . + (identifier) @local.definition.type) + +(task_type_declaration + . + (identifier) @local.definition.type) + +(subtype_declaration + . + (identifier) @local.definition.type) + +(identifier) @local.reference diff --git a/runtime/queries/agda/folds.scm b/runtime/queries/agda/folds.scm new file mode 100644 index 000000000..5e1051f8f --- /dev/null +++ b/runtime/queries/agda/folds.scm @@ -0,0 +1,4 @@ +[ + (record) + (module) +] @fold diff --git a/runtime/queries/agda/highlights.scm b/runtime/queries/agda/highlights.scm new file mode 100644 index 000000000..4626a8c12 --- /dev/null +++ b/runtime/queries/agda/highlights.scm @@ -0,0 +1,87 @@ +; Constants +(integer) @number + +; Variables and Symbols +(typed_binding + (atom + (qid) @variable)) + +(untyped_binding) @variable + +(typed_binding + (expr) @type) + +(id) @function + +(bid) @function + +(function_name + (atom + (qid) @function)) + +(field_name) @function + +[ + (data_name) + (record_name) +] @constructor + +; Set +(SetN) @type.builtin + +(expr + . + (atom) @function) + +((atom) @boolean + (#any-of? @boolean "true" "false" "True" "False")) + +; Imports and Module Declarations +"import" @keyword.import + +(module_name) @module + +; Pragmas and comments +(pragma) @keyword.directive + +(comment) @comment @spell + +; Keywords +[ + "where" + "data" + "rewrite" + "postulate" + "public" + "private" + "tactic" + "Prop" + "quote" + "renaming" + "open" + "in" + "hiding" + "constructor" + "abstract" + "let" + "field" + "mutual" + "module" + "infix" + "infixl" + "infixr" +] @keyword + +"record" @keyword.type + +;(expr +; f_name: (atom) @function) +; Brackets +[ + "(" + ")" + "{" + "}" +] @punctuation.bracket + +"=" @operator diff --git a/runtime/queries/agda/injections.scm b/runtime/queries/agda/injections.scm new file mode 100644 index 000000000..a772e0bd9 --- /dev/null +++ b/runtime/queries/agda/injections.scm @@ -0,0 +1,14 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((comment) @injection.content + (#lua-match? @injection.content "^///[^/]") + (#set! injection.language "doxygen")) + +((comment) @injection.content + (#lua-match? @injection.content "^///$") + (#set! injection.language "doxygen")) + +((comment) @injection.content + (#lua-match? @injection.content "^/[*][*][^*].*[*]/$") + (#set! injection.language "doxygen")) diff --git a/runtime/queries/angular/folds.scm b/runtime/queries/angular/folds.scm new file mode 100644 index 000000000..1f2129cf9 --- /dev/null +++ b/runtime/queries/angular/folds.scm @@ -0,0 +1 @@ +; inherits: html diff --git a/runtime/queries/angular/highlights.scm b/runtime/queries/angular/highlights.scm new file mode 100644 index 000000000..271e352e5 --- /dev/null +++ b/runtime/queries/angular/highlights.scm @@ -0,0 +1,154 @@ +; inherits: html_tags + +(identifier) @variable + +(pipe_operator) @operator + +[ + (string) + (static_member_expression) +] @string + +(number) @number + +(pipe_call + name: (identifier) @function) + +(pipe_call + arguments: (pipe_arguments + (identifier) @variable.parameter)) + +(structural_directive + "*" @keyword + (identifier) @keyword) + +(attribute + (attribute_name) @variable.member + (#lua-match? @variable.member "#.*")) + +(binding_name + (identifier) @keyword) + +(event_binding + (binding_name + (identifier) @keyword)) + +(event_binding + "\"" @punctuation.delimiter) + +(property_binding + "\"" @punctuation.delimiter) + +(structural_assignment + operator: (identifier) @keyword) + +(member_expression + property: (identifier) @property) + +(call_expression + function: (identifier) @function) + +(call_expression + function: ((identifier) @function.builtin + (#eq? @function.builtin "$any"))) + +(pair + key: ((identifier) @variable.builtin + (#eq? @variable.builtin "$implicit"))) + +[ + (control_keyword) + (special_keyword) +] @keyword + +((control_keyword) @keyword.repeat + (#any-of? @keyword.repeat "for" "empty")) + +((control_keyword) @keyword.conditional + (#any-of? @keyword.conditional "if" "else" "switch" "case" "default")) + +((control_keyword) @keyword.coroutine + (#any-of? @keyword.coroutine "defer" "placeholder" "loading")) + +((control_keyword) @keyword.exception + (#eq? @keyword.exception "error")) + +((identifier) @boolean + (#any-of? @boolean "true" "false")) + +((identifier) @variable.builtin + (#any-of? @variable.builtin "this" "$event")) + +((identifier) @constant.builtin + (#eq? @constant.builtin "null")) + +[ + (ternary_operator) + (conditional_operator) +] @keyword.conditional.ternary + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "@" +] @punctuation.bracket + +(two_way_binding + [ + "[(" + ")]" + ] @punctuation.bracket) + +[ + "{{" + "}}" +] @punctuation.special + +(template_substitution + [ + "${" + "}" + ] @punctuation.special) + +(template_chars) @string + +[ + ";" + "." + "," + "?." +] @punctuation.delimiter + +(nullish_coalescing_expression + (coalescing_operator) @operator) + +(concatenation_expression + "+" @operator) + +(icu_clause) @keyword.operator + +(icu_category) @keyword.conditional + +(binary_expression + [ + "-" + "&&" + "+" + "<" + "<=" + "=" + "==" + "===" + "!=" + "!==" + ">" + ">=" + "*" + "/" + "||" + "%" + ] @operator) diff --git a/runtime/queries/angular/indents.scm b/runtime/queries/angular/indents.scm new file mode 100644 index 000000000..2f46aa5bc --- /dev/null +++ b/runtime/queries/angular/indents.scm @@ -0,0 +1,16 @@ +; inherits: html_tags + +[ + (statement_block) + (switch_statement) +] @indent.begin + +(statement_block + "{" @indent.branch) + +(statement_block + "}" @indent.end) + +"}" @indent.branch + +"}" @indent.end diff --git a/runtime/queries/angular/injections.scm b/runtime/queries/angular/injections.scm new file mode 100644 index 000000000..448e94275 --- /dev/null +++ b/runtime/queries/angular/injections.scm @@ -0,0 +1 @@ +; inherits: html_tags diff --git a/runtime/queries/angular/locals.scm b/runtime/queries/angular/locals.scm new file mode 100644 index 000000000..1f2129cf9 --- /dev/null +++ b/runtime/queries/angular/locals.scm @@ -0,0 +1 @@ +; inherits: html diff --git a/runtime/queries/apex/folds.scm b/runtime/queries/apex/folds.scm new file mode 100644 index 000000000..fdfc2a1ed --- /dev/null +++ b/runtime/queries/apex/folds.scm @@ -0,0 +1,6 @@ +[ + (class_body) + (constructor_declaration) + (argument_list) + (annotation_argument_list) +] @fold diff --git a/runtime/queries/apex/highlights.scm b/runtime/queries/apex/highlights.scm new file mode 100644 index 000000000..82ce23414 --- /dev/null +++ b/runtime/queries/apex/highlights.scm @@ -0,0 +1,257 @@ +; inherits: soql + +; Apex + SOQL +[ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket + +[ + "," + "." + ":" + "?" + ";" +] @punctuation.delimiter + +; Default general color definition +(identifier) @variable + +(type_identifier) @type + +; Methods +(method_declaration + name: (identifier) @function.method) + +(method_invocation + name: (identifier) @function.method.call) + +(super) @function.builtin + +; Annotations +(annotation + name: (identifier) @attribute) + +; Types +(interface_declaration + name: (identifier) @type) + +(class_declaration + name: (identifier) @type) + +(class_declaration + (superclass) @type) + +(enum_declaration + name: (identifier) @type) + +(enum_constant + name: (identifier) @constant) + +(type_arguments + "<" @punctuation.delimiter) + +(type_arguments + ">" @punctuation.delimiter) + +(field_access + object: (identifier) @type) + +(field_access + field: (identifier) @property) + +((scoped_identifier + scope: (identifier) @type) + (#match? @type "^[A-Z]")) + +((method_invocation + object: (identifier) @type) + (#match? @type "^[A-Z]")) + +(method_declaration + (formal_parameters + (formal_parameter + name: (identifier) @variable.parameter))) + +(constructor_declaration + name: (identifier) @constructor) + +(dml_type) @function.builtin + +(assignment_operator) @operator + +(update_operator) @operator + +(trigger_declaration + name: (identifier) @type + object: (identifier) @type + (trigger_event) @keyword + ("," + (trigger_event) @keyword)*) + +[ + "@" + "=" + "!=" + "<=" + ">=" +] @operator + +(binary_expression + operator: [ + ">" + "<" + "==" + "===" + "!==" + "&&" + "||" + "+" + "-" + "*" + "/" + "&" + "|" + "^" + "%" + "<<" + ">>" + ">>>" + ] @operator) + +(unary_expression + operator: [ + "+" + "-" + "!" + "~" + ]) @operator + +"=>" @operator + +[ + (boolean_type) + (void_type) +] @type.builtin + +; Fields +(field_declaration + declarator: (variable_declarator + name: (identifier) @variable.member)) + +(field_access + field: (identifier) @variable.member) + +; Variables +(variable_declarator + (identifier) @property) + +(field_declaration + (modifiers + (modifier + [ + (final) + (static) + ]) + (modifier + [ + (final) + (static) + ])) + (variable_declarator + name: (identifier) @constant)) + +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z0-9_]+$")) ; SCREAM SNAKE CASE + +(this) @variable.builtin + +; Literals +[ + (int) + (decimal) + (currency_literal) +] @number + +(string_literal) @string + +[ + (line_comment) + (block_comment) +] @comment + +(null_literal) @constant.builtin + +; ;; Keywords +[ + "abstract" + "final" + "private" + "protected" + "public" + "static" +] @keyword.modifier + +[ + "if" + "else" + "switch" +] @keyword.conditional + +[ + "for" + "while" + "do" + "break" +] @keyword.repeat + +"return" @keyword.return + +[ + "throw" + "finally" + "try" + "catch" +] @keyword.exception + +"new" @keyword.operator + +[ + (abstract) + (all_rows_clause) + "continue" + "extends" + (final) + "get" + (global) + "implements" + "instanceof" + "on" + (override) + (private) + (protected) + (public) + "set" + (static) + (testMethod) + (webservice) + (transient) + "trigger" + (virtual) + "when" + (with_sharing) + (without_sharing) + (inherited_sharing) +] @keyword + +[ + "interface" + "class" + "enum" +] @keyword.type + +"System.runAs" @function.builtin diff --git a/runtime/queries/apex/injections.scm b/runtime/queries/apex/injections.scm new file mode 100644 index 000000000..3cd6aac8e --- /dev/null +++ b/runtime/queries/apex/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/apex/locals.scm b/runtime/queries/apex/locals.scm new file mode 100644 index 000000000..d758f14cf --- /dev/null +++ b/runtime/queries/apex/locals.scm @@ -0,0 +1,67 @@ +; declarations +(class_declaration) @local.scope + +(method_declaration) @local.scope + +(constructor_declaration) @local.scope + +(enum_declaration) @local.scope + +(enhanced_for_statement) @local.scope + +; if/else +(if_statement) @local.scope + +(if_statement + consequence: (_) @local.scope) ; if body in case there are no braces + +(if_statement + alternative: (_) @local.scope) ; else body in case there are no braces + +; try/catch +(try_statement) @local.scope ; covers try+catch, individual try and catch are covered by (block) + +(catch_clause) @local.scope ; needed because `Exception` variable + +; loops +(for_statement) @local.scope + +(for_statement ; "for" body in case there are no braces + body: (_) @local.scope) + +(do_statement + body: (_) @local.scope) + +(while_statement + body: (_) @local.scope) + +; Functions +(constructor_declaration) @local.scope + +(method_declaration) @local.scope + +; definitions +(enum_declaration + name: (identifier) @local.definition.enum) + +(method_declaration + name: (identifier) @local.definition.method) + +(local_variable_declaration + declarator: (variable_declarator + name: (identifier) @local.definition.var)) + +(enhanced_for_statement + name: (identifier) @local.definition.var) + +(formal_parameter + name: (identifier) @local.definition.parameter) + +(field_declaration + declarator: (variable_declarator + name: (identifier) @local.definition.field)) + +; REFERENCES +(identifier) @local.reference + +(type_identifier) @local.reference diff --git a/runtime/queries/arduino/folds.scm b/runtime/queries/arduino/folds.scm new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/runtime/queries/arduino/folds.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/runtime/queries/arduino/highlights.scm b/runtime/queries/arduino/highlights.scm new file mode 100644 index 000000000..e6bf14784 --- /dev/null +++ b/runtime/queries/arduino/highlights.scm @@ -0,0 +1,53 @@ +; inherits: cpp + +((identifier) @function.builtin + (#any-of? @function.builtin + ; Digital I/O + "digitalRead" "digitalWrite" "pinMode" + ; Analog I/O + "analogRead" "analogReference" "analogWrite" + ; Zero, Due & MKR Family + "analogReadResolution" "analogWriteResolution" + ; Advanced I/O + "noTone" "pulseIn" "pulseInLong" "shiftIn" "shiftOut" "tone" + ; Time + "delay" "delayMicroseconds" "micros" "millis" + ; Math + "abs" "constrain" "map" "max" "min" "pow" "sq" "sqrt" + ; Trigonometry + "cos" "sin" "tan" + ; Characters + "isAlpha" "isAlphaNumeric" "isAscii" "isControl" "isDigit" "isGraph" "isHexadecimalDigit" + "isLowerCase" "isPrintable" "isPunct" "isSpace" "isUpperCase" "isWhitespace" + ; Random Numbers + "random" "randomSeed" + ; Bits and Bytes + "bit" "bitClear" "bitRead" "bitSet" "bitWrite" "highByte" "lowByte" + ; External Interrupts + "attachInterrupt" "detachInterrupt" + ; Interrupts + "interrupts" "noInterrupts")) + +((identifier) @type.builtin + (#any-of? @type.builtin "Serial" "SPI" "Stream" "Wire" "Keyboard" "Mouse" "String")) + +((identifier) @constant.builtin + (#any-of? @constant.builtin "HIGH" "LOW" "INPUT" "OUTPUT" "INPUT_PULLUP" "LED_BUILTIN")) + +(function_definition + (function_declarator + declarator: (identifier) @function.builtin) + (#any-of? @function.builtin "loop" "setup")) + +(call_expression + function: (primitive_type) @function.builtin) + +(call_expression + function: (identifier) @constructor + (#any-of? @constructor "SPISettings" "String")) + +(declaration + (type_identifier) @type.builtin + (function_declarator + declarator: (identifier) @constructor) + (#eq? @type.builtin "SPISettings")) diff --git a/runtime/queries/arduino/indents.scm b/runtime/queries/arduino/indents.scm new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/runtime/queries/arduino/indents.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/runtime/queries/arduino/injections.scm b/runtime/queries/arduino/injections.scm new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/runtime/queries/arduino/injections.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/runtime/queries/arduino/locals.scm b/runtime/queries/arduino/locals.scm new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/runtime/queries/arduino/locals.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/runtime/queries/asm/highlights.scm b/runtime/queries/asm/highlights.scm new file mode 100644 index 000000000..eccf9c996 --- /dev/null +++ b/runtime/queries/asm/highlights.scm @@ -0,0 +1,66 @@ +; General +(label + [ + (ident) + (word) + ] @label) + +(reg) @variable.builtin + +(meta + kind: (_) @function.builtin) + +(instruction + kind: (_) @function.builtin) + +(const + name: (word) @constant) + +; Comments +[ + (line_comment) + (block_comment) +] @comment @spell + +; Literals +(int) @number + +(float) @number.float + +(string) @string + +; Keywords +[ + "byte" + "word" + "dword" + "qword" + "ptr" + "rel" + "label" + "const" +] @keyword + +; Operators & Punctuation +[ + "+" + "-" + "*" + "/" + "%" + "|" + "^" + "&" +] @operator + +[ + "(" + ")" + "[" + "]" +] @punctuation.bracket + +[ + "," + ":" +] @punctuation.delimiter diff --git a/runtime/queries/asm/injections.scm b/runtime/queries/asm/injections.scm new file mode 100644 index 000000000..3cd6aac8e --- /dev/null +++ b/runtime/queries/asm/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/astro/folds.scm b/runtime/queries/astro/folds.scm new file mode 100644 index 000000000..1f2129cf9 --- /dev/null +++ b/runtime/queries/astro/folds.scm @@ -0,0 +1 @@ +; inherits: html diff --git a/runtime/queries/astro/highlights.scm b/runtime/queries/astro/highlights.scm new file mode 100644 index 000000000..e2917ad4d --- /dev/null +++ b/runtime/queries/astro/highlights.scm @@ -0,0 +1,29 @@ +; inherits: html_tags + +(doctype) @constant + +"<!" @tag.delimiter + +"---" @punctuation.delimiter + +[ + "{" + "}" +] @punctuation.special + +; custom components get `@type` highlighting +((start_tag + (tag_name) @type) + (#lua-match? @type "^[A-Z]")) + +((end_tag + (tag_name) @type) + (#lua-match? @type "^[A-Z]")) + +((self_closing_tag + (tag_name) @type) + (#lua-match? @type "^[A-Z]")) + +((erroneous_end_tag + (erroneous_end_tag_name) @type) + (#lua-match? @type "^[A-Z]")) diff --git a/runtime/queries/astro/indents.scm b/runtime/queries/astro/indents.scm new file mode 100644 index 000000000..1f2129cf9 --- /dev/null +++ b/runtime/queries/astro/indents.scm @@ -0,0 +1 @@ +; inherits: html diff --git a/runtime/queries/astro/injections.scm b/runtime/queries/astro/injections.scm new file mode 100644 index 000000000..d4f15ba56 --- /dev/null +++ b/runtime/queries/astro/injections.scm @@ -0,0 +1,32 @@ +; inherits: html_tags + +(frontmatter + (frontmatter_js_block) @injection.content + (#set! injection.language "typescript")) + +(attribute_interpolation + (attribute_js_expr) @injection.content + (#set! injection.language "typescript")) + +(attribute + (attribute_backtick_string) @injection.content + (#set! injection.language "typescript")) + +(html_interpolation + (permissible_text) @injection.content + (#set! injection.language "typescript")) + +(script_element + (raw_text) @injection.content + (#set! injection.language "typescript")) + +(style_element + (start_tag + (attribute + (attribute_name) @_lang_attr + (quoted_attribute_value + (attribute_value) @_lang_value))) + (raw_text) @injection.content + (#eq? @_lang_attr "lang") + (#eq? @_lang_value "scss") + (#set! injection.language "scss")) diff --git a/runtime/queries/astro/locals.scm b/runtime/queries/astro/locals.scm new file mode 100644 index 000000000..1f2129cf9 --- /dev/null +++ b/runtime/queries/astro/locals.scm @@ -0,0 +1 @@ +; inherits: html diff --git a/runtime/queries/authzed/highlights.scm b/runtime/queries/authzed/highlights.scm new file mode 100644 index 000000000..fb946caaf --- /dev/null +++ b/runtime/queries/authzed/highlights.scm @@ -0,0 +1,60 @@ +(identifier) @function + +(block + (relation + (relation_literal) @function.builtin + (identifier) @constant)) + +(block + (permission + (permission_literal) @variable.builtin + (identifier) @type)) + +; relations +(rel_expression + (identifier) @property) + +(relation + (rel_expression + (hash_literal) + . + (identifier) @constant)) + +; permissions +(perm_expression + (identifier) @property) + +(call_expression + function: (selector_expression + operand: (identifier) @constant + field: (field_identifier) @function.method)) + +(perm_expression + (stabby) @operator + . + (identifier) @function) + +; misc +[ + (plus_literal) + (minus_literal) + (amp_literal) + (pipe_literal) +] @operator + +[ + (true) + (false) +] @boolean + +(nil) @constant.builtin + +[ + (caveat_literal) + (definition_literal) +] @keyword + +[ + (hash_literal) + (comment) +] @comment diff --git a/runtime/queries/authzed/injections.scm b/runtime/queries/authzed/injections.scm new file mode 100644 index 000000000..298a8d070 --- /dev/null +++ b/runtime/queries/authzed/injections.scm @@ -0,0 +1,26 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((function_call + name: (ident) @_name + . + (simplexpr) + . + (simplexpr + (string + (string_fragment) @injection.content)+)) + (#any-of? @_name "replace" "search" "matches" "captures") + (#set! injection.language "regex") + (#set! injection.combined)) + +((function_call + name: (ident) @_name + . + (simplexpr) + . + (simplexpr + (string + (string_fragment) @injection.content)+)) + (#eq? @_name "jq") + (#set! injection.language "jq") + (#set! injection.combined)) diff --git a/runtime/queries/awk/highlights.scm b/runtime/queries/awk/highlights.scm new file mode 100644 index 000000000..51ec9c08e --- /dev/null +++ b/runtime/queries/awk/highlights.scm @@ -0,0 +1,233 @@ +; adapted from https://github.com/Beaglefoot/tree-sitter-awk +[ + (identifier) + (field_ref) +] @variable + +(field_ref + (_) @variable) + +; https://www.gnu.org/software/gawk/manual/html_node/Auto_002dset.html +((identifier) @constant.builtin + (#any-of? @constant.builtin + "ARGC" "ARGV" "ARGIND" "ENVIRON" "ERRNO" "FILENAME" "FNR" "NF" "FUNCTAB" "NR" "PROCINFO" + "RLENGTH" "RSTART" "RT" "SYMTAB")) + +; https://www.gnu.org/software/gawk/manual/html_node/User_002dmodified.html +((identifier) @variable.builtin + (#any-of? @variable.builtin + "BINMODE" "CONVFMT" "FIELDWIDTHS" "FPAT" "FS" "IGNORECASE" "LINT" "OFMT" "OFS" "ORS" "PREC" + "ROUNDMODE" "RS" "SUBSEP" "TEXTDOMAIN")) + +(number) @number + +(string) @string + +(regex) @string.regexp + +(escape_sequence) @string.escape + +(comment) @comment @spell + +((program + . + (comment) @keyword.directive @nospell) + (#lua-match? @keyword.directive "^#!/")) + +(ns_qualified_name + (namespace) @module) + +(ns_qualified_name + "::" @punctuation.delimiter) + +(func_def + name: (_ + (identifier) @function) @function) + +(func_call + name: (_ + (identifier) @function) @function) + +(func_def + (param_list + (identifier) @variable.parameter)) + +[ + "asort" + "asorti" + "bindtextdomain" + "compl" + "cos" + "dcgettext" + "dcngettext" + "exp" + "gensub" + "gsub" + "index" + "int" + "isarray" + "length" + "log" + "lshift" + "match" + "mktime" + "patsplit" + "rand" + "rshift" + "sin" + "split" + "sprintf" + "sqrt" + "srand" + "strftime" + "strtonum" + "sub" + "substr" + "systime" + "tolower" + "toupper" + "typeof" + "print" + "printf" + "getline" +] @function.builtin + +[ + (delete_statement) + (break_statement) + (continue_statement) + (next_statement) + (nextfile_statement) +] @keyword + +[ + "func" + "function" +] @keyword.function + +[ + "return" + "exit" +] @keyword.return + +[ + "do" + "while" + "for" + "in" +] @keyword.repeat + +[ + "if" + "else" + "switch" + "case" + "default" +] @keyword.conditional + +[ + "@include" + "@load" +] @keyword.import + +"@namespace" @keyword.directive + +[ + "BEGIN" + "END" + "BEGINFILE" + "ENDFILE" +] @label + +(binary_exp + [ + "^" + "**" + "*" + "/" + "%" + "+" + "-" + "<" + ">" + "<=" + ">=" + "==" + "!=" + "~" + "!~" + "in" + "&&" + "||" + ] @operator) + +(unary_exp + [ + "!" + "+" + "-" + ] @operator) + +(assignment_exp + [ + "=" + "+=" + "-=" + "*=" + "/=" + "%=" + "^=" + ] @operator) + +(ternary_exp + [ + "?" + ":" + ] @keyword.conditional.ternary) + +(update_exp + [ + "++" + "--" + ] @operator) + +(redirected_io_statement + [ + ">" + ">>" + ] @operator) + +(piped_io_statement + [ + "|" + "|&" + ] @operator) + +(piped_io_exp + [ + "|" + "|&" + ] @operator) + +(field_ref + "$" @punctuation.delimiter) + +(regex + "/" @punctuation.delimiter) + +(regex_constant + "@" @punctuation.delimiter) + +[ + ";" + "," +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket diff --git a/runtime/queries/awk/injections.scm b/runtime/queries/awk/injections.scm new file mode 100644 index 000000000..3e67da245 --- /dev/null +++ b/runtime/queries/awk/injections.scm @@ -0,0 +1,17 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((regex) @injection.content + (#set! injection.language "regex")) + +((print_statement + (exp_list + . + (string) @injection.content)) + (#set! injection.language "printf")) + +((printf_statement + (exp_list + . + (string) @injection.content)) + (#set! injection.language "printf")) diff --git a/runtime/queries/bash/folds.scm b/runtime/queries/bash/folds.scm new file mode 100644 index 000000000..766dbe598 --- /dev/null +++ b/runtime/queries/bash/folds.scm @@ -0,0 +1,9 @@ +[ + (function_definition) + (if_statement) + (case_statement) + (for_statement) + (while_statement) + (c_style_for_statement) + (heredoc_redirect) +] @fold diff --git a/runtime/queries/bash/highlights.scm b/runtime/queries/bash/highlights.scm new file mode 100644 index 000000000..58d57d9e5 --- /dev/null +++ b/runtime/queries/bash/highlights.scm @@ -0,0 +1,261 @@ +[ + "(" + ")" + "{" + "}" + "[" + "]" + "[[" + "]]" + "((" + "))" +] @punctuation.bracket + +[ + ";" + ";;" + ";&" + ";;&" + "&" +] @punctuation.delimiter + +[ + ">" + ">>" + "<" + "<<" + "&&" + "|" + "|&" + "||" + "=" + "+=" + "=~" + "==" + "!=" + "&>" + "&>>" + "<&" + ">&" + ">|" + "<&-" + ">&-" + "<<-" + "<<<" + ".." + "!" +] @operator + +; Do *not* spell check strings since they typically have some sort of +; interpolation in them, or, are typically used for things like filenames, URLs, +; flags and file content. +[ + (string) + (raw_string) + (ansi_c_string) + (heredoc_body) +] @string + +[ + (heredoc_start) + (heredoc_end) +] @label + +(variable_assignment + (word) @string) + +(command + argument: "$" @string) ; bare dollar + +(concatenation + (word) @string) + +[ + "if" + "then" + "else" + "elif" + "fi" + "case" + "in" + "esac" +] @keyword.conditional + +[ + "for" + "do" + "done" + "select" + "until" + "while" +] @keyword.repeat + +[ + "declare" + "typeset" + "readonly" + "local" + "unset" + "unsetenv" +] @keyword + +"export" @keyword.import + +"function" @keyword.function + +(special_variable_name) @constant + +; trap -l +((word) @constant.builtin + (#any-of? @constant.builtin + "SIGHUP" "SIGINT" "SIGQUIT" "SIGILL" "SIGTRAP" "SIGABRT" "SIGBUS" "SIGFPE" "SIGKILL" "SIGUSR1" + "SIGSEGV" "SIGUSR2" "SIGPIPE" "SIGALRM" "SIGTERM" "SIGSTKFLT" "SIGCHLD" "SIGCONT" "SIGSTOP" + "SIGTSTP" "SIGTTIN" "SIGTTOU" "SIGURG" "SIGXCPU" "SIGXFSZ" "SIGVTALRM" "SIGPROF" "SIGWINCH" + "SIGIO" "SIGPWR" "SIGSYS" "SIGRTMIN" "SIGRTMIN+1" "SIGRTMIN+2" "SIGRTMIN+3" "SIGRTMIN+4" + "SIGRTMIN+5" "SIGRTMIN+6" "SIGRTMIN+7" "SIGRTMIN+8" "SIGRTMIN+9" "SIGRTMIN+10" "SIGRTMIN+11" + "SIGRTMIN+12" "SIGRTMIN+13" "SIGRTMIN+14" "SIGRTMIN+15" "SIGRTMAX-14" "SIGRTMAX-13" + "SIGRTMAX-12" "SIGRTMAX-11" "SIGRTMAX-10" "SIGRTMAX-9" "SIGRTMAX-8" "SIGRTMAX-7" "SIGRTMAX-6" + "SIGRTMAX-5" "SIGRTMAX-4" "SIGRTMAX-3" "SIGRTMAX-2" "SIGRTMAX-1" "SIGRTMAX")) + +((word) @boolean + (#any-of? @boolean "true" "false")) + +(comment) @comment @spell + +(test_operator) @operator + +(command_substitution + "$(" @punctuation.special + ")" @punctuation.special) + +(process_substitution + [ + "<(" + ">(" + ] @punctuation.special + ")" @punctuation.special) + +(arithmetic_expansion + [ + "$((" + "((" + ] @punctuation.special + "))" @punctuation.special) + +(arithmetic_expansion + "," @punctuation.delimiter) + +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +(binary_expression + operator: _ @operator) + +(unary_expression + operator: _ @operator) + +(postfix_expression + operator: _ @operator) + +(function_definition + name: (word) @function) + +(command_name + (word) @function.call) + +(command_name + (word) @function.builtin + (#any-of? @function.builtin + "." ":" "alias" "bg" "bind" "break" "builtin" "caller" "cd" "command" "compgen" "complete" + "compopt" "continue" "coproc" "dirs" "disown" "echo" "enable" "eval" "exec" "exit" "false" "fc" + "fg" "getopts" "hash" "help" "history" "jobs" "kill" "let" "logout" "mapfile" "popd" "printf" + "pushd" "pwd" "read" "readarray" "return" "set" "shift" "shopt" "source" "suspend" "test" "time" + "times" "trap" "true" "type" "typeset" "ulimit" "umask" "unalias" "wait")) + +(command + argument: [ + (word) @variable.parameter + (concatenation + (word) @variable.parameter) + ]) + +(declaration_command + (word) @variable.parameter) + +(unset_command + (word) @variable.parameter) + +(number) @number + +((word) @number + (#lua-match? @number "^[0-9]+$")) + +(file_redirect + (word) @string.special.path) + +(herestring_redirect + (word) @string) + +(file_descriptor) @operator + +(simple_expansion + "$" @punctuation.special) @none + +(expansion + "${" @punctuation.special + "}" @punctuation.special) @none + +(expansion + operator: _ @punctuation.special) + +(expansion + "@" + . + operator: _ @character.special) + +((expansion + (subscript + index: (word) @character.special)) + (#any-of? @character.special "@" "*")) + +"``" @punctuation.special + +(variable_name) @variable + +((variable_name) @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + +((variable_name) @variable.builtin + (#any-of? @variable.builtin + ; https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Variables.html + "CDPATH" "HOME" "IFS" "MAIL" "MAILPATH" "OPTARG" "OPTIND" "PATH" "PS1" "PS2" + ; https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html + "_" "BASH" "BASHOPTS" "BASHPID" "BASH_ALIASES" "BASH_ARGC" "BASH_ARGV" "BASH_ARGV0" "BASH_CMDS" + "BASH_COMMAND" "BASH_COMPAT" "BASH_ENV" "BASH_EXECUTION_STRING" "BASH_LINENO" + "BASH_LOADABLES_PATH" "BASH_REMATCH" "BASH_SOURCE" "BASH_SUBSHELL" "BASH_VERSINFO" + "BASH_VERSION" "BASH_XTRACEFD" "CHILD_MAX" "COLUMNS" "COMP_CWORD" "COMP_LINE" "COMP_POINT" + "COMP_TYPE" "COMP_KEY" "COMP_WORDBREAKS" "COMP_WORDS" "COMPREPLY" "COPROC" "DIRSTACK" "EMACS" + "ENV" "EPOCHREALTIME" "EPOCHSECONDS" "EUID" "EXECIGNORE" "FCEDIT" "FIGNORE" "FUNCNAME" + "FUNCNEST" "GLOBIGNORE" "GROUPS" "histchars" "HISTCMD" "HISTCONTROL" "HISTFILE" "HISTFILESIZE" + "HISTIGNORE" "HISTSIZE" "HISTTIMEFORMAT" "HOSTFILE" "HOSTNAME" "HOSTTYPE" "IGNOREEOF" "INPUTRC" + "INSIDE_EMACS" "LANG" "LC_ALL" "LC_COLLATE" "LC_CTYPE" "LC_MESSAGES" "LC_NUMERIC" "LC_TIME" + "LINENO" "LINES" "MACHTYPE" "MAILCHECK" "MAPFILE" "OLDPWD" "OPTERR" "OSTYPE" "PIPESTATUS" + "POSIXLY_CORRECT" "PPID" "PROMPT_COMMAND" "PROMPT_DIRTRIM" "PS0" "PS3" "PS4" "PWD" "RANDOM" + "READLINE_ARGUMENT" "READLINE_LINE" "READLINE_MARK" "READLINE_POINT" "REPLY" "SECONDS" "SHELL" + "SHELLOPTS" "SHLVL" "SRANDOM" "TIMEFORMAT" "TMOUT" "TMPDIR" "UID")) + +(case_item + value: (word) @variable.parameter) + +[ + (regex) + (extglob_pattern) +] @string.regexp + +((program + . + (comment) @keyword.directive @nospell) + (#lua-match? @keyword.directive "^#!/")) diff --git a/runtime/queries/bash/injections.scm b/runtime/queries/bash/injections.scm new file mode 100644 index 000000000..9b86e351a --- /dev/null +++ b/runtime/queries/bash/injections.scm @@ -0,0 +1,79 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((regex) @injection.content + (#set! injection.language "regex")) + +((heredoc_redirect + (heredoc_body) @injection.content + (heredoc_end) @injection.language) + (#downcase! @injection.language)) + +; printf 'format' +((command + name: (command_name) @_command + . + argument: [ + (string) @injection.content + (concatenation + (string) @injection.content) + (raw_string) @injection.content + (concatenation + (raw_string) @injection.content) + ]) + (#eq? @_command "printf") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "printf")) + +; printf -v var 'format' +((command + name: (command_name) @_command + argument: (word) @_arg + . + (_) + . + argument: [ + (string) @injection.content + (concatenation + (string) @injection.content) + (raw_string) @injection.content + (concatenation + (raw_string) @injection.content) + ]) + (#eq? @_command "printf") + (#eq? @_arg "-v") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "printf")) + +; printf -- 'format' +((command + name: (command_name) @_command + argument: (word) @_arg + . + argument: [ + (string) @injection.content + (concatenation + (string) @injection.content) + (raw_string) @injection.content + (concatenation + (raw_string) @injection.content) + ]) + (#eq? @_command "printf") + (#eq? @_arg "--") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "printf")) + +((command + name: (command_name) @_command + . + argument: [ + (string) + (raw_string) + ] @injection.content) + (#eq? @_command "bind") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "readline")) diff --git a/runtime/queries/bash/locals.scm b/runtime/queries/bash/locals.scm new file mode 100644 index 000000000..347f51fa2 --- /dev/null +++ b/runtime/queries/bash/locals.scm @@ -0,0 +1,14 @@ +; Scopes +(function_definition) @local.scope + +; Definitions +(variable_assignment + name: (variable_name) @local.definition.var) + +(function_definition + name: (word) @local.definition.function) + +; References +(variable_name) @local.reference + +(word) @local.reference diff --git a/runtime/queries/bass/folds.scm b/runtime/queries/bass/folds.scm new file mode 100644 index 000000000..d99e0c1ac --- /dev/null +++ b/runtime/queries/bass/folds.scm @@ -0,0 +1,5 @@ +[ + (list) + (scope) + (cons) +] @fold diff --git a/runtime/queries/bass/highlights.scm b/runtime/queries/bass/highlights.scm new file mode 100644 index 000000000..f84993af1 --- /dev/null +++ b/runtime/queries/bass/highlights.scm @@ -0,0 +1,126 @@ +; Variables +(list + (symbol) @variable) + +(cons + (symbol) @variable) + +(scope + (symbol) @variable) + +(symbind + (symbol) @variable) + +; Constants +((symbol) @constant + (#lua-match? @constant "^_*[A-Z][A-Z0-9_]*$")) + +; Functions +(list + . + (symbol) @function) + +; Namespaces +(symbind + (symbol) @module + . + (keyword)) + +; Includes +((symbol) @keyword.import + (#any-of? @keyword.import "use" "import" "load")) + +; Keywords +((symbol) @keyword + (#any-of? @keyword "do" "doc")) + +; Special Functions +; Keywords construct a symbol +(keyword) @constructor + +((list + . + (symbol) @keyword.function + . + (symbol) @function + (symbol)? @variable.parameter) + (#any-of? @keyword.function "def" "defop" "defn" "fn")) + +((cons + . + (symbol) @keyword.function + . + (symbol) @function + (symbol)? @variable.parameter) + (#any-of? @keyword.function "def" "defop" "defn" "fn")) + +((symbol) @function.builtin + (#any-of? @function.builtin + "dump" "mkfs" "json" "log" "error" "now" "cons" "wrap" "unwrap" "eval" "make-scope" "bind" + "meta" "with-meta" "null?" "ignore?" "boolean?" "number?" "string?" "symbol?" "scope?" "sink?" + "source?" "list?" "pair?" "applicative?" "operative?" "combiner?" "path?" "empty?" "thunk?" "+" + "*" "quot" "-" "max" "min" "=" ">" ">=" "<" "<=" "list->source" "across" "emit" "next" + "reduce-kv" "assoc" "symbol->string" "string->symbol" "str" "substring" "trim" "scope->list" + "string->fs-path" "string->cmd-path" "string->dir" "subpath" "path-name" "path-stem" + "with-image" "with-dir" "with-args" "with-cmd" "with-stdin" "with-env" "with-insecure" + "with-label" "with-port" "with-tls" "with-mount" "thunk-cmd" "thunk-args" "resolve" "start" + "addr" "wait" "read" "cache-dir" "binds?" "recall-memo" "store-memo" "mask" "list" "list*" + "first" "rest" "length" "second" "third" "map" "map-pairs" "foldr" "foldl" "append" "filter" + "conj" "list->scope" "merge" "apply" "id" "always" "vals" "keys" "memo" "succeeds?" "run" "last" + "take" "take-all" "insecure!" "from" "cd" "wrap-cmd" "mkfile" "path-base" "not")) + +((symbol) @function.macro + (#any-of? @function.macro + "op" "current-scope" "quote" "let" "provide" "module" "or" "and" "curryfn" "for" "$" "linux")) + +; Conditionals +((symbol) @keyword.conditional + (#any-of? @keyword.conditional "if" "case" "cond" "when")) + +; Repeats +((symbol) @keyword.repeat + (#any-of? @keyword.repeat "each")) + +; Operators +((symbol) @operator + (#any-of? @operator "&" "*" "+" "-" "<" "<=" "=" ">" ">=")) + +; Punctuation +[ + "(" + ")" +] @punctuation.bracket + +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +((symbol) @punctuation.delimiter + (#eq? @punctuation.delimiter "->")) + +; Literals +(string) @string + +(escape_sequence) @string.escape + +(path) @string.special.url + +(number) @number + +(boolean) @boolean + +[ + (ignore) + (null) +] @constant.builtin + +"^" @character.special + +; Comments +(comment) @comment @spell diff --git a/runtime/queries/bass/indents.scm b/runtime/queries/bass/indents.scm new file mode 100644 index 000000000..27b976f21 --- /dev/null +++ b/runtime/queries/bass/indents.scm @@ -0,0 +1,31 @@ +[ + (list) + (scope) + (cons) +] @indent.begin + +[ + ")" + "}" + "]" +] @indent.end + +[ + "(" + ")" +] @indent.branch + +[ + "{" + "}" +] @indent.branch + +[ + "[" + "]" +] @indent.branch + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/runtime/queries/bass/injections.scm b/runtime/queries/bass/injections.scm new file mode 100644 index 000000000..1c2fe3cc9 --- /dev/null +++ b/runtime/queries/bass/injections.scm @@ -0,0 +1,5 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((block_comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/bass/locals.scm b/runtime/queries/bass/locals.scm new file mode 100644 index 000000000..daed7e5e1 --- /dev/null +++ b/runtime/queries/bass/locals.scm @@ -0,0 +1,26 @@ +; Scopes +[ + (list) + (scope) + (cons) +] @local.scope + +; References +(symbol) @local.reference + +; Definitions +((list + . + (symbol) @_fnkw + . + (symbol) @local.definition.function + (symbol)? @local.definition.parameter) + (#any-of? @_fnkw "def" "defop" "defn" "fn")) + +((cons + . + (symbol) @_fnkw + . + (symbol) @local.definition.function + (symbol)? @local.definition.parameter) + (#any-of? @_fnkw "def" "defop" "defn" "fn")) diff --git a/runtime/queries/beancount/folds.scm b/runtime/queries/beancount/folds.scm new file mode 100644 index 000000000..9f1b6cbed --- /dev/null +++ b/runtime/queries/beancount/folds.scm @@ -0,0 +1,4 @@ +[ + (transaction) + (section) +] @fold diff --git a/runtime/queries/beancount/highlights.scm b/runtime/queries/beancount/highlights.scm new file mode 100644 index 000000000..1e23d28f4 --- /dev/null +++ b/runtime/queries/beancount/highlights.scm @@ -0,0 +1,57 @@ +(date) @variable.member + +(txn) @attribute + +(account) @type + +(amount) @number + +(incomplete_amount) @number + +(compound_amount) @number + +(amount_tolerance) @number + +(currency) @property + +(key) @label + +(string) @string + +(narration) @string @spell + +(payee) @string @spell + +(tag) @constant + +(link) @constant + +[ + (minus) + (plus) + (slash) + (asterisk) +] @operator + +(comment) @comment @spell + +[ + (balance) + (open) + (close) + (commodity) + (pad) + (event) + (price) + (note) + (document) + (query) + (custom) + (pushtag) + (poptag) + (pushmeta) + (popmeta) + (option) + (include) + (plugin) +] @keyword diff --git a/runtime/queries/beancount/injections.scm b/runtime/queries/beancount/injections.scm new file mode 100644 index 000000000..05aa24d8f --- /dev/null +++ b/runtime/queries/beancount/injections.scm @@ -0,0 +1,5 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((macro_text) @injection.content + (#set! injection.language "verilog")) diff --git a/runtime/queries/bibtex/folds.scm b/runtime/queries/bibtex/folds.scm new file mode 100644 index 000000000..321a045c9 --- /dev/null +++ b/runtime/queries/bibtex/folds.scm @@ -0,0 +1 @@ +(entry) @fold diff --git a/runtime/queries/bibtex/highlights.scm b/runtime/queries/bibtex/highlights.scm new file mode 100644 index 000000000..2231a17db --- /dev/null +++ b/runtime/queries/bibtex/highlights.scm @@ -0,0 +1,57 @@ +; CREDITS @pfoerster (adapted from https://github.com/latex-lsp/tree-sitter-bibtex) +[ + (string_type) + (preamble_type) + (entry_type) +] @keyword + +[ + (junk) + (comment) +] @comment + +(comment) @spell + +[ + "=" + "#" +] @operator + +(command) @function.builtin + +(number) @number + +(field + name: (identifier) @property) + +(token + (identifier) @variable.parameter) + +[ + (brace_word) + (quote_word) +] @string + +((field + name: (identifier) @_url + value: (value + (token + (brace_word) @string.special.url))) + (#any-of? @_url "url" "doi")) + +[ + (key_brace) + (key_paren) +] @markup.link.label + +(string + name: (identifier) @constant) + +[ + "{" + "}" + "(" + ")" +] @punctuation.bracket + +"," @punctuation.delimiter diff --git a/runtime/queries/bibtex/indents.scm b/runtime/queries/bibtex/indents.scm new file mode 100644 index 000000000..764172a76 --- /dev/null +++ b/runtime/queries/bibtex/indents.scm @@ -0,0 +1,8 @@ +(entry) @indent.begin + +[ + "{" + "}" +] @indent.branch + +(comment) @indent.ignore diff --git a/runtime/queries/bibtex/injections.scm b/runtime/queries/bibtex/injections.scm new file mode 100644 index 000000000..98ad387d9 --- /dev/null +++ b/runtime/queries/bibtex/injections.scm @@ -0,0 +1,2 @@ +((junk) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/bicep/folds.scm b/runtime/queries/bicep/folds.scm new file mode 100644 index 000000000..217a86d6a --- /dev/null +++ b/runtime/queries/bicep/folds.scm @@ -0,0 +1,19 @@ +[ + (module_declaration) + (metadata_declaration) + (output_declaration) + (parameter_declaration) + (resource_declaration) + (type_declaration) + (variable_declaration) + (parenthesized_expression) + (decorators) + (array) + (object) + (if_statement) + (for_statement) + (subscript_expression) + (ternary_expression) + (string) + (comment) +] @fold diff --git a/runtime/queries/bicep/highlights.scm b/runtime/queries/bicep/highlights.scm new file mode 100644 index 000000000..35c9d6c17 --- /dev/null +++ b/runtime/queries/bicep/highlights.scm @@ -0,0 +1,234 @@ +; Includes +[ + "import" + "provider" + "with" + "as" + "from" +] @keyword.import + +; Namespaces +(module_declaration + (identifier) @module) + +; Builtins +(primitive_type) @type.builtin + +((member_expression + object: (identifier) @type.builtin) + (#eq? @type.builtin "sys")) + +; Functions +(call_expression + function: (identifier) @function.call) + +(user_defined_function + name: (identifier) @function) + +; Properties +(object_property + (identifier) @property + ":" @punctuation.delimiter + (_)) + +(object_property + (compatible_identifier) @property + ":" @punctuation.delimiter + (_)) + +(property_identifier) @property + +; Attributes +(decorator + "@" @attribute) + +(decorator + (call_expression + (identifier) @attribute)) + +(decorator + (call_expression + (member_expression + object: (identifier) @attribute + property: (property_identifier) @attribute))) + +; Types +(type_declaration + (identifier) @type) + +(type_declaration + (identifier) + "=" + (identifier) @type) + +(type + (identifier) @type) + +(resource_declaration + (identifier) @type) + +(resource_expression + (identifier) @type) + +; Parameters +(parameter_declaration + (identifier) @variable.parameter + (_)) + +(call_expression + function: (_) + (arguments + (identifier) @variable.parameter)) + +(call_expression + function: (_) + (arguments + (member_expression + object: (identifier) @variable.parameter))) + +(parameter + . + (identifier) @variable.parameter) + +; Variables +(variable_declaration + (identifier) @variable + (_)) + +(metadata_declaration + (identifier) @variable + (_)) + +(output_declaration + (identifier) @variable + (_)) + +(object_property + (_) + ":" + (identifier) @variable) + +(for_statement + "for" + (for_loop_parameters + (loop_variable) @variable + (loop_enumerator) @variable)) + +; Conditionals +"if" @keyword.conditional + +(ternary_expression + "?" @keyword.conditional.ternary + ":" @keyword.conditional.ternary) + +; Loops +(for_statement + "for" @keyword.repeat + "in" + ":" @punctuation.delimiter) + +; Keywords +[ + "module" + "metadata" + "output" + "param" + "resource" + "existing" + "targetScope" + "type" + "var" + "using" + "test" +] @keyword + +"func" @keyword.function + +"assert" @keyword.exception + +; Operators +[ + "+" + "-" + "*" + "/" + "%" + "||" + "&&" + "|" + "==" + "!=" + "=~" + "!~" + ">" + ">=" + "<=" + "<" + "??" + "=" + "!" + ".?" +] @operator + +(subscript_expression + "?" @operator) + +(nullable_type + "?" @operator) + +"in" @keyword.operator + +; Literals +(string) @string + +(escape_sequence) @string.escape + +(number) @number + +(boolean) @boolean + +(null) @constant.builtin + +; Misc +(compatible_identifier + "?" @punctuation.special) + +(nullable_return_type) @punctuation.special + +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "." + ":" + "::" + "=>" +] @punctuation.delimiter + +; Interpolation +(interpolation) @none + +(interpolation + "${" @punctuation.special + "}" @punctuation.special) + +(interpolation + (identifier) @variable) + +; Comments +[ + (comment) + (diagnostic_comment) +] @comment @spell diff --git a/runtime/queries/bicep/indents.scm b/runtime/queries/bicep/indents.scm new file mode 100644 index 000000000..055e51b23 --- /dev/null +++ b/runtime/queries/bicep/indents.scm @@ -0,0 +1,27 @@ +[ + (array) + (object) +] @indent.begin + +"}" @indent.end + +[ + "{" + "}" +] @indent.branch + +[ + "[" + "]" +] @indent.branch + +[ + "(" + ")" +] @indent.branch + +[ + (ERROR) + (comment) + (diagnostic_comment) +] @indent.auto diff --git a/runtime/queries/bicep/injections.scm b/runtime/queries/bicep/injections.scm new file mode 100644 index 000000000..5c2d4a57b --- /dev/null +++ b/runtime/queries/bicep/injections.scm @@ -0,0 +1,5 @@ +([ + (comment) + (diagnostic_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/bicep/locals.scm b/runtime/queries/bicep/locals.scm new file mode 100644 index 000000000..cc9c3c2cf --- /dev/null +++ b/runtime/queries/bicep/locals.scm @@ -0,0 +1,73 @@ +; Scopes +[ + (infrastructure) + (call_expression) + (lambda_expression) + (subscript_expression) + (if_statement) + (for_statement) + (array) + (object) + (interpolation) +] @local.scope + +; References +(property_identifier) @local.reference + +(call_expression + (identifier) @local.reference) + +(object_property + (_) + ":" + (identifier) @local.reference) + +(resource_expression + (identifier) @local.reference) + +; Definitions +(type) @local.definition.associated + +(object_property + (identifier) @local.definition.field + (_)) + +(object_property + (compatible_identifier) @local.definition.field + (_)) + +(user_defined_function + name: (identifier) @local.definition.function) + +(module_declaration + (identifier) @local.definition.namespace) + +(parameter_declaration + (identifier) @local.definition.parameter + (_)) + +(parameter + . + (identifier) @local.definition.parameter) + +(type_declaration + (identifier) @local.definition.type + (_)) + +(variable_declaration + (identifier) @local.definition.var + (_)) + +(metadata_declaration + (identifier) @local.definition.var + (_)) + +(output_declaration + (identifier) @local.definition.var + (_)) + +(for_statement + "for" + (for_loop_parameters + (loop_variable) @local.definition.var + (loop_enumerator) @local.definition.var)) diff --git a/runtime/queries/bitbake/folds.scm b/runtime/queries/bitbake/folds.scm new file mode 100644 index 000000000..85d226348 --- /dev/null +++ b/runtime/queries/bitbake/folds.scm @@ -0,0 +1,24 @@ +[ + (function_definition) + (anonymous_python_function) + (python_function_definition) + (while_statement) + (for_statement) + (if_statement) + (with_statement) + (try_statement) + (import_from_statement) + (parameters) + (argument_list) + (parenthesized_expression) + (generator_expression) + (list_comprehension) + (set_comprehension) + (dictionary_comprehension) + (tuple) + (list) + (set) + (dictionary) + (string) + (python_string) +] @fold diff --git a/runtime/queries/bitbake/highlights.scm b/runtime/queries/bitbake/highlights.scm new file mode 100644 index 000000000..c7316de6e --- /dev/null +++ b/runtime/queries/bitbake/highlights.scm @@ -0,0 +1,406 @@ +; Includes +[ + "inherit" + "include" + "require" + "export" + "import" +] @keyword.import + +; Keywords +[ + "unset" + "EXPORT_FUNCTIONS" + "python" + "assert" + "exec" + "global" + "nonlocal" + "pass" + "print" + "with" + "as" +] @keyword + +[ + "async" + "await" +] @keyword.coroutine + +[ + "return" + "yield" +] @keyword.return + +(yield + "from" @keyword.return) + +(future_import_statement + "from" @keyword.import + "__future__" @constant.builtin) + +(import_from_statement + "from" @keyword.import) + +"import" @keyword.import + +(aliased_import + "as" @keyword.import) + +[ + "if" + "elif" + "else" +] @keyword.conditional + +[ + "for" + "while" + "break" + "continue" +] @keyword.repeat + +[ + "try" + "except" + "except*" + "raise" + "finally" +] @keyword.exception + +(raise_statement + "from" @keyword.exception) + +(try_statement + (else_clause + "else" @keyword.exception)) + +[ + "addtask" + "deltask" + "addhandler" + "def" + "lambda" +] @keyword.function + +[ + "before" + "after" +] @keyword.modifier + +[ + "append" + "prepend" + "remove" +] @keyword.modifier + +; Variables +[ + (identifier) + (python_identifier) +] @variable + +[ + "noexec" + "OVERRIDES" + "$BB_ENV_PASSTHROUGH" + "$BB_ENV_PASSTHROUGH_ADDITIONS" +] @variable.builtin + +; Reset highlighting in f-string interpolations +(interpolation) @none + +; Identifier naming conventions +((python_identifier) @type + (#lua-match? @type "^[A-Z].*[a-z]")) + +([ + (identifier) + (python_identifier) +] @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + +((python_identifier) @constant.builtin + (#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$")) + +((python_identifier) @constant.builtin + (#any-of? @constant.builtin + ; https://docs.python.org/3/library/constants.html + "NotImplemented" "Ellipsis" "quit" "exit" "copyright" "credits" "license")) + +((assignment + left: (python_identifier) @type.definition + (type + (python_identifier) @_annotation)) + (#eq? @_annotation "TypeAlias")) + +((assignment + left: (python_identifier) @type.definition + right: (call + function: (python_identifier) @_func)) + (#any-of? @_func "TypeVar" "NewType")) + +; Fields +(flag) @variable.member + +((attribute + attribute: (python_identifier) @variable.member) + (#lua-match? @variable.member "^[%l_].*$")) + +; Functions +(call + function: (python_identifier) @function.call) + +(call + function: (attribute + attribute: (python_identifier) @function.method.call)) + +((call + function: (python_identifier) @constructor) + (#lua-match? @constructor "^%u")) + +((call + function: (attribute + attribute: (python_identifier) @constructor)) + (#lua-match? @constructor "^%u")) + +((call + function: (python_identifier) @function.builtin) + (#any-of? @function.builtin + "abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" "bytes" "callable" "chr" + "classmethod" "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "exec" + "filter" "float" "format" "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id" + "input" "int" "isinstance" "issubclass" "iter" "len" "list" "locals" "map" "max" "memoryview" + "min" "next" "object" "oct" "open" "ord" "pow" "print" "property" "range" "repr" "reversed" + "round" "set" "setattr" "slice" "sorted" "staticmethod" "str" "sum" "super" "tuple" "type" + "vars" "zip" "__import__")) + +(python_function_definition + name: (python_identifier) @function) + +(type + (python_identifier) @type) + +(type + (subscript + (python_identifier) @type)) ; type subscript: Tuple[int] + +((call + function: (python_identifier) @_isinstance + arguments: (argument_list + (_) + (python_identifier) @type)) + (#eq? @_isinstance "isinstance")) + +(anonymous_python_function + (identifier) @function) + +(function_definition + (identifier) @function) + +(addtask_statement + (identifier) @function) + +(deltask_statement + (identifier) @function) + +(export_functions_statement + (identifier) @function) + +(addhandler_statement + (identifier) @function) + +(python_function_definition + body: (block + . + (expression_statement + (python_string) @string.documentation @spell))) + +; Namespace +(inherit_path) @module + +; Normal parameters +(parameters + (python_identifier) @variable.parameter) + +; Lambda parameters +(lambda_parameters + (python_identifier) @variable.parameter) + +(lambda_parameters + (tuple_pattern + (python_identifier) @variable.parameter)) + +; Default parameters +(keyword_argument + name: (python_identifier) @variable.parameter) + +; Naming parameters on call-site +(default_parameter + name: (python_identifier) @variable.parameter) + +(typed_parameter + (python_identifier) @variable.parameter) + +(typed_default_parameter + (python_identifier) @variable.parameter) + +; Variadic parameters *args, **kwargs +(parameters + (list_splat_pattern + ; *args + (python_identifier) @variable.parameter)) + +(parameters + (dictionary_splat_pattern + ; **kwargs + (python_identifier) @variable.parameter)) + +; Literals +(none) @constant.builtin + +[ + (true) + (false) +] @boolean + +((python_identifier) @variable.builtin + (#any-of? @variable.builtin "self" "cls")) + +(integer) @number + +(float) @number.float + +; Operators +[ + "?=" + "??=" + ":=" + "=+" + ".=" + "=." + "-" + "-=" + ":=" + "!=" + "*" + "**" + "**=" + "*=" + "/" + "//" + "//=" + "/=" + "&" + "&=" + "%" + "%=" + "^" + "^=" + "+" + "+=" + "<" + "<<" + "<<=" + "<=" + "<>" + "=" + "==" + ">" + ">=" + ">>" + ">>=" + "@" + "@=" + "|" + "|=" + "~" + "->" +] @operator + +[ + "and" + "in" + "is" + "not" + "or" + "is not" + "not in" + "del" +] @keyword.operator + +; Literals +[ + (string) + (python_string) + "\"" +] @string + +(include_path) @string.special.path + +[ + (escape_sequence) + (escape_interpolation) +] @string.escape + +; Punctuation +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + ":" + "->" + ";" + "." + "," + (ellipsis) +] @punctuation.delimiter + +(variable_expansion + [ + "${" + "}" + ] @punctuation.special) + +(inline_python + [ + "${@" + "}" + ] @punctuation.special) + +(interpolation + "{" @punctuation.special + "}" @punctuation.special) + +(type_conversion) @function.macro + +([ + (identifier) + (python_identifier) +] @type.builtin + (#any-of? @type.builtin + ; https://docs.python.org/3/library/exceptions.html + "BaseException" "Exception" "ArithmeticError" "BufferError" "LookupError" "AssertionError" + "AttributeError" "EOFError" "FloatingPointError" "GeneratorExit" "ImportError" + "ModuleNotFoundError" "IndexError" "KeyError" "KeyboardInterrupt" "MemoryError" "NameError" + "NotImplementedError" "OSError" "OverflowError" "RecursionError" "ReferenceError" "RuntimeError" + "StopIteration" "StopAsyncIteration" "SyntaxError" "IndentationError" "TabError" "SystemError" + "SystemExit" "TypeError" "UnboundLocalError" "UnicodeError" "UnicodeEncodeError" + "UnicodeDecodeError" "UnicodeTranslateError" "ValueError" "ZeroDivisionError" "EnvironmentError" + "IOError" "WindowsError" "BlockingIOError" "ChildProcessError" "ConnectionError" + "BrokenPipeError" "ConnectionAbortedError" "ConnectionRefusedError" "ConnectionResetError" + "FileExistsError" "FileNotFoundError" "InterruptedError" "IsADirectoryError" + "NotADirectoryError" "PermissionError" "ProcessLookupError" "TimeoutError" "Warning" + "UserWarning" "DeprecationWarning" "PendingDeprecationWarning" "SyntaxWarning" "RuntimeWarning" + "FutureWarning" "ImportWarning" "UnicodeWarning" "BytesWarning" "ResourceWarning" + ; https://docs.python.org/3/library/stdtypes.html + "bool" "int" "float" "complex" "list" "tuple" "range" "str" "bytes" "bytearray" "memoryview" + "set" "frozenset" "dict" "type" "object")) + +(comment) @comment @spell diff --git a/runtime/queries/bitbake/indents.scm b/runtime/queries/bitbake/indents.scm new file mode 100644 index 000000000..5f2081868 --- /dev/null +++ b/runtime/queries/bitbake/indents.scm @@ -0,0 +1,172 @@ +[ + (import_from_statement) + (parenthesized_expression) + (generator_expression) + (list_comprehension) + (set_comprehension) + (dictionary_comprehension) + (tuple_pattern) + (list_pattern) + (binary_operator) + (lambda) + (concatenated_string) +] @indent.begin + +((list) @indent.align + (#set! indent.open_delimiter "[") + (#set! indent.close_delimiter "]")) + +((dictionary) @indent.align + (#set! indent.open_delimiter "{") + (#set! indent.close_delimiter "}")) + +((set) @indent.align + (#set! indent.open_delimiter "{") + (#set! indent.close_delimiter "}")) + +((for_statement) @indent.begin + (#set! indent.immediate 1)) + +((if_statement) @indent.begin + (#set! indent.immediate 1)) + +((while_statement) @indent.begin + (#set! indent.immediate 1)) + +((try_statement) @indent.begin + (#set! indent.immediate 1)) + +(ERROR + "try" + ":" @indent.begin + (#set! indent.immediate 1)) + +((python_function_definition) @indent.begin + (#set! indent.immediate 1)) + +(function_definition) @indent.begin + +(anonymous_python_function) @indent.begin + +((with_statement) @indent.begin + (#set! indent.immediate 1)) + +(if_statement + condition: (parenthesized_expression) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")") + (#set! indent.avoid_last_matching_next 1)) + +(while_statement + condition: (parenthesized_expression) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")") + (#set! indent.avoid_last_matching_next 1)) + +(ERROR + "(" @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")") + . + (_)) + +((argument_list) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +((parameters) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")") + (#set! indent.avoid_last_matching_next 1)) + +((tuple) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +(ERROR + "[" @indent.align + (#set! indent.open_delimiter "[") + (#set! indent.close_delimiter "]") + . + (_)) + +(ERROR + "{" @indent.align + (#set! indent.open_delimiter "{") + (#set! indent.close_delimiter "}") + . + (_)) + +[ + (break_statement) + (continue_statement) +] @indent.dedent + +(ERROR + (_) @indent.branch + ":" + . + (#lua-match? @indent.branch "^else")) + +(ERROR + (_) @indent.branch @indent.dedent + ":" + . + (#lua-match? @indent.branch "^elif")) + +(parenthesized_expression + ")" @indent.end) + +(generator_expression + ")" @indent.end) + +(list_comprehension + "]" @indent.end) + +(set_comprehension + "}" @indent.end) + +(dictionary_comprehension + "}" @indent.end) + +(tuple_pattern + ")" @indent.end) + +(list_pattern + "]" @indent.end) + +(function_definition + "}" @indent.end) + +(anonymous_python_function + "}" @indent.end) + +(return_statement + [ + (_) @indent.end + (_ + [ + (_) + ")" + "}" + "]" + ] @indent.end .) + (attribute + attribute: (_) @indent.end) + (call + arguments: (_ + ")" @indent.end)) + "return" @indent.end + ] .) + +[ + ")" + "]" + "}" + (elif_clause) + (else_clause) + (except_clause) + (finally_clause) +] @indent.branch + +(string) @indent.auto diff --git a/runtime/queries/bitbake/injections.scm b/runtime/queries/bitbake/injections.scm new file mode 100644 index 000000000..35c984a5b --- /dev/null +++ b/runtime/queries/bitbake/injections.scm @@ -0,0 +1,15 @@ +(call + function: (attribute + object: (python_identifier) @_re) + arguments: (argument_list + (python_string + (string_content) @injection.content) @_string) + (#eq? @_re "re") + (#lua-match? @_string "^r.*") + (#set! injection.language "regex")) + +((shell_content) @injection.content + (#set! injection.language "bash")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/bitbake/locals.scm b/runtime/queries/bitbake/locals.scm new file mode 100644 index 000000000..e4726ec51 --- /dev/null +++ b/runtime/queries/bitbake/locals.scm @@ -0,0 +1,117 @@ +; References +[ + (python_identifier) + (identifier) +] @local.reference + +; Imports +(aliased_import + alias: (python_identifier) @local.definition.import) + +(import_statement + name: (dotted_name + (python_identifier) @local.definition.import)) + +(import_from_statement + name: (dotted_name + (python_identifier) @local.definition.import)) + +; Function with parameters, defines parameters +(parameters + (python_identifier) @local.definition.parameter) + +(default_parameter + (python_identifier) @local.definition.parameter) + +(typed_parameter + (python_identifier) @local.definition.parameter) + +(typed_default_parameter + (python_identifier) @local.definition.parameter) + +; *args parameter +(parameters + (list_splat_pattern + (python_identifier) @local.definition.parameter)) + +; **kwargs parameter +(parameters + (dictionary_splat_pattern + (python_identifier) @local.definition.parameter)) + +; Function defines function and scope +((python_function_definition + name: (python_identifier) @local.definition.function) @local.scope + (#set! definition.function.scope "parent")) + +(function_definition + (identifier) @local.definition.function) + +(anonymous_python_function + (identifier) @local.definition.function) + +; Loops +; not a scope! +(for_statement + left: (pattern_list + (python_identifier) @local.definition.var)) + +(for_statement + left: (tuple_pattern + (python_identifier) @local.definition.var)) + +(for_statement + left: (python_identifier) @local.definition.var) + +; not a scope! +;(while_statement) @local.scope +; for in list comprehension +(for_in_clause + left: (python_identifier) @local.definition.var) + +(for_in_clause + left: (tuple_pattern + (python_identifier) @local.definition.var)) + +(for_in_clause + left: (pattern_list + (python_identifier) @local.definition.var)) + +(dictionary_comprehension) @local.scope + +(list_comprehension) @local.scope + +(set_comprehension) @local.scope + +; Assignments +(assignment + left: (python_identifier) @local.definition.var) + +(assignment + left: (pattern_list + (python_identifier) @local.definition.var)) + +(assignment + left: (tuple_pattern + (python_identifier) @local.definition.var)) + +(assignment + left: (attribute + (python_identifier) + (python_identifier) @local.definition.field)) + +(variable_assignment + (identifier) + operator: [ + "=" + "?=" + "??=" + ":=" + ] @local.definition.var) + +; Walrus operator x := 1 +(named_expression + (python_identifier) @local.definition.var) + +(as_pattern + alias: (as_pattern_target) @local.definition.var) diff --git a/runtime/queries/blade/folds.scm b/runtime/queries/blade/folds.scm new file mode 100644 index 000000000..cc081a754 --- /dev/null +++ b/runtime/queries/blade/folds.scm @@ -0,0 +1,14 @@ +[ + (authorization) + (conditional) + (envoy) + (fragment) + (livewire) + (loop) + (once) + (php_statement) + (section) + (stack) + (switch) + (verbatim) +] @fold diff --git a/runtime/queries/blade/highlights.scm b/runtime/queries/blade/highlights.scm new file mode 100644 index 000000000..c05d2845f --- /dev/null +++ b/runtime/queries/blade/highlights.scm @@ -0,0 +1,15 @@ +([ + (directive) + (directive_start) + (directive_end) +] @tag + (#set! priority 101)) + +([ + (bracket_start) + (bracket_end) +] @tag.delimiter + (#set! priority 101)) + +((comment) @comment @spell + (#set! priority 101)) diff --git a/runtime/queries/blade/indents.scm b/runtime/queries/blade/indents.scm new file mode 100644 index 000000000..bd3e84d16 --- /dev/null +++ b/runtime/queries/blade/indents.scm @@ -0,0 +1,3 @@ +(directive_start) @indent.begin + +(directive_end) @indent.end diff --git a/runtime/queries/blade/injections.scm b/runtime/queries/blade/injections.scm new file mode 100644 index 000000000..12fa9f953 --- /dev/null +++ b/runtime/queries/blade/injections.scm @@ -0,0 +1,15 @@ +((text) @injection.content + (#set! injection.combined) + (#set! injection.language html)) + +((text) @injection.content + (#has-ancestor? @injection.content "envoy") + (#set! injection.combined) + (#set! injection.language bash)) + +((php_only) @injection.content + (#set! injection.combined) + (#set! injection.language php_only)) + +((parameter) @injection.content + (#set! injection.language php_only)) diff --git a/runtime/queries/blueprint/highlights.scm b/runtime/queries/blueprint/highlights.scm new file mode 100644 index 000000000..f3c39f232 --- /dev/null +++ b/runtime/queries/blueprint/highlights.scm @@ -0,0 +1,75 @@ +(object_id) @variable + +(string) @string + +(escape_sequence) @string.escape + +(comment) @comment @spell + +(constant) @constant.builtin + +(boolean) @boolean + +(using) @keyword.import + +(template) @keyword + +(decorator) @attribute + +(property_definition + (property_name) @property) + +(object) @type + +(signal_binding + (signal_name) @function.builtin) + +(signal_binding + (function + (identifier)) @function) + +(signal_binding + "swapped" @keyword) + +(styles_list + "styles" @function.macro) + +(layout_definition + "layout" @function.macro) + +(gettext_string + "_" @function.builtin) + +(menu_definition + "menu" @keyword) + +(menu_section + "section" @keyword) + +(menu_item + "item" @function.macro) + +(import_statement + (gobject_library) @module) + +(import_statement + (version_number) @number.float) + +(float) @number.float + +(number) @number + +[ + ";" + "." + "," +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket diff --git a/runtime/queries/blueprint/injections.scm b/runtime/queries/blueprint/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/blueprint/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/bp/folds.scm b/runtime/queries/bp/folds.scm new file mode 100644 index 000000000..c40ea3df4 --- /dev/null +++ b/runtime/queries/bp/folds.scm @@ -0,0 +1,6 @@ +[ + (list_expression) + (map_expression) + (module) + (select_expression) +] @fold diff --git a/runtime/queries/bp/highlights.scm b/runtime/queries/bp/highlights.scm new file mode 100644 index 000000000..5f94f4c11 --- /dev/null +++ b/runtime/queries/bp/highlights.scm @@ -0,0 +1,56 @@ +(comment) @comment @spell + +(operator) @operator + +(integer_literal + "-" @operator) + +[ + "," + ":" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(boolean_literal) @boolean + +(integer_literal) @number + +[ + (raw_string_literal) + (interpreted_string_literal) +] @string + +(escape_sequence) @string.escape + +(identifier) @variable + +(module + type: (identifier) @function.call) + +(module + (property + field: (identifier) @variable.parameter)) + +[ + (unset) + (default) + (any) +] @variable.builtin + +(condition + name: (identifier) @function.builtin) + +(map_expression + (property + field: (identifier) @property)) + +(select_expression + "select" @keyword.conditional) diff --git a/runtime/queries/bp/indents.scm b/runtime/queries/bp/indents.scm new file mode 100644 index 000000000..8cf8adc83 --- /dev/null +++ b/runtime/queries/bp/indents.scm @@ -0,0 +1,38 @@ +(list_expression) @indent.begin + +(list_expression + "]" @indent.branch) + +(map_expression) @indent.begin + +(map_expression + "}" @indent.branch) + +(select_expression) @indent.begin + +(select_expression + ")" @indent.branch) + +(select_value) @indent.begin + +(select_value + ")" @indent.branch) + +(select_pattern + "(" @indent.begin) + +(select_pattern + ")" @indent.branch) + +(select_cases) @indent.begin + +(select_cases + "}" @indent.branch) + +(module) @indent.begin + +(module + ")" @indent.branch) + +(module + "}" @indent.branch) diff --git a/runtime/queries/bp/injections.scm b/runtime/queries/bp/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/bp/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/bp/locals.scm b/runtime/queries/bp/locals.scm new file mode 100644 index 000000000..c8a5a1719 --- /dev/null +++ b/runtime/queries/bp/locals.scm @@ -0,0 +1,15 @@ +(module + (property + field: (identifier) @local.definition.parameter)) + +(map_expression + (property + field: (identifier) @local.definition.field)) + +(assignment + left: (identifier) @local.definition.var) + +(pattern_binding + binding: (identifier) @local.definition.var) + +(identifier) @local.reference diff --git a/runtime/queries/brightscript/folds.scm b/runtime/queries/brightscript/folds.scm new file mode 100644 index 000000000..56b7d575b --- /dev/null +++ b/runtime/queries/brightscript/folds.scm @@ -0,0 +1,8 @@ +[ + (function_statement) + (sub_statement) + (while_statement) + (for_statement) + (if_statement) + (try_statement) +] @fold diff --git a/runtime/queries/brightscript/highlights.scm b/runtime/queries/brightscript/highlights.scm new file mode 100644 index 000000000..5758f565b --- /dev/null +++ b/runtime/queries/brightscript/highlights.scm @@ -0,0 +1,177 @@ +; Identifiers +(identifier) @variable + +; Function declaration +(function_statement + name: (identifier) @function) + +; Sub declaration +(sub_statement + name: (identifier) @function) + +[ + (sub_start) + (function_start) + (end_sub) + (end_function) +] @keyword.function + +; Parameters +(parameter + name: (identifier) @variable.parameter) + +; Types +(type_specifier) @type + +; Variables +; Base variable in variable declarator (immediate child of prefix_exp) +(variable_declarator + (prefix_exp + (identifier) @variable + (#not-has-ancestor? @variable prefix_exp))) + +; Properties in variable declarator +(variable_declarator + (prefix_exp) + (identifier) @property) + +(multiplicative_expression + operator: (_) @keyword.operator) + +(logical_not_expression + operator: (_) @keyword.operator) + +(logical_expression + operator: (_) @keyword.operator) + +; Property access +; First identifier in a chain (base variable) +(prefix_exp + . + (identifier) @variable + (#not-has-ancestor? @variable prefix_exp)) + +; All other identifiers in a chain (properties) +(prefix_exp + (prefix_exp) + (identifier) @property) + +; Function calls +(function_call + function: (prefix_exp + (identifier) @function.call)) + +; Statements +[ + (if_start) + (else) + (else_if) + (end_if) + (then) + (conditional_compl_end_if) +] @keyword.conditional + +[ + (for_start) + (while_start) + (for_each) + (for_in) + (for_to) + (for_step) + (end_for) + (end_while) + (exit_while_statement) + (exit_for_statement) +] @keyword.repeat + +; Statements +[ + (try_start) + (try_catch) + (throw) + (end_try) +] @keyword.exception + +(return) @keyword.return + +(print) @function.builtin + +(constant) @constant + +; Operators +[ + "=" + "<>" + "<" + "<=" + ">" + ">=" + "+" + "-" + "*" + "/" +] @operator + +; Literals +(boolean) @boolean + +(number) @number + +(string) @string + +(invalid) @constant.builtin + +; Comments +(comment) @comment @spell + +; Punctuation +[ + "(" + ")" + "[" + "]" + "{" + "}" + "?[" +] @punctuation.bracket + +[ + "." + "," + "?." +] @punctuation.delimiter + +; Special highlights for library statements +(library_statement) @keyword.import + +(library_statement + path: (string) @module) + +; Array and associative array literals +(array) @constructor + +(assoc_array) @constructor + +(assoc_array_element + key: (identifier) @property) + +; Increment/decrement operators +[ + (prefix_increment_expression) + (prefix_decrement_expression) + (postfix_increment_expression) + (postfix_decrement_expression) +] @operator + +; Comparison operators +(comparison_expression + [ + "=" + "<>" + "<" + "<=" + ">" + ">=" + ] @operator) + +(as) @keyword.operator diff --git a/runtime/queries/brightscript/indents.scm b/runtime/queries/brightscript/indents.scm new file mode 100644 index 000000000..e54bf52c1 --- /dev/null +++ b/runtime/queries/brightscript/indents.scm @@ -0,0 +1,39 @@ +; Start indentation for block-level constructs +[ + (sub_statement) + (function_statement) + (annonymous_sub) + (annonymous_function) + (conditional_compl) + (multi_line_if) + (for_statement) + (while_statement) + (try_statement) + (array) + (assoc_array) +] @indent.begin + +; End indentation for all end statements +[ + (end_sub) + (end_function) + (end_if) + (end_for) + (end_while) + (end_try) + (conditional_compl_end_if) + "]" + "}" +] @indent.branch @indent.end + +; Handle branching constructs +[ + (else_if_clause) + (else_clause) + (conditional_compl_else_if_clause) + (conditional_compl_else_clause) + (catch_clause) +] @indent.branch + +; Ignore comments for indentation +(comment) @indent.ignore diff --git a/runtime/queries/brightscript/injections.scm b/runtime/queries/brightscript/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/brightscript/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/c/folds.scm b/runtime/queries/c/folds.scm new file mode 100644 index 000000000..bb26a62eb --- /dev/null +++ b/runtime/queries/c/folds.scm @@ -0,0 +1,23 @@ +[ + (for_statement) + (if_statement) + (while_statement) + (do_statement) + (switch_statement) + (case_statement) + (function_definition) + (struct_specifier) + (enum_specifier) + (comment) + (preproc_if) + (preproc_elif) + (preproc_else) + (preproc_ifdef) + (preproc_function_def) + (initializer_list) + (gnu_asm_expression) + (preproc_include)+ +] @fold + +(compound_statement + (compound_statement) @fold) diff --git a/runtime/queries/c/highlights.scm b/runtime/queries/c/highlights.scm new file mode 100644 index 000000000..ea65075f2 --- /dev/null +++ b/runtime/queries/c/highlights.scm @@ -0,0 +1,341 @@ +; Lower priority to prefer @variable.parameter when identifier appears in parameter_declaration. +((identifier) @variable + (#set! priority 95)) + +(preproc_def + (preproc_arg) @variable) + +[ + "default" + "goto" + "asm" + "__asm__" +] @keyword + +[ + "enum" + "struct" + "union" + "typedef" +] @keyword.type + +[ + "sizeof" + "offsetof" +] @keyword.operator + +(alignof_expression + . + _ @keyword.operator) + +"return" @keyword.return + +[ + "while" + "for" + "do" + "continue" + "break" +] @keyword.repeat + +[ + "if" + "else" + "case" + "switch" +] @keyword.conditional + +[ + "#if" + "#ifdef" + "#ifndef" + "#else" + "#elif" + "#endif" + "#elifdef" + "#elifndef" + (preproc_directive) +] @keyword.directive + +"#define" @keyword.directive.define + +"#include" @keyword.import + +[ + ";" + ":" + "," + "." + "::" +] @punctuation.delimiter + +"..." @punctuation.special + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "=" + "-" + "*" + "/" + "+" + "%" + "~" + "|" + "&" + "^" + "<<" + ">>" + "->" + "<" + "<=" + ">=" + ">" + "==" + "!=" + "!" + "&&" + "||" + "-=" + "+=" + "*=" + "/=" + "%=" + "|=" + "&=" + "^=" + ">>=" + "<<=" + "--" + "++" +] @operator + +; Make sure the comma operator is given a highlight group after the comma +; punctuator so the operator is highlighted properly. +(comma_expression + "," @operator) + +[ + (true) + (false) +] @boolean + +(conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +(string_literal) @string + +(system_lib_string) @string + +(escape_sequence) @string.escape + +(null) @constant.builtin + +(number_literal) @number + +(char_literal) @character + +(preproc_defined) @function.macro + +((field_expression + (field_identifier) @property) @_parent + (#not-has-parent? @_parent template_method function_declarator call_expression)) + +(field_designator) @property + +((field_identifier) @property + (#has-ancestor? @property field_declaration) + (#not-has-ancestor? @property function_declarator)) + +(statement_identifier) @label + +(declaration + type: (type_identifier) @_type + declarator: (identifier) @label + (#eq? @_type "__label__")) + +[ + (type_identifier) + (type_descriptor) +] @type + +(storage_class_specifier) @keyword.modifier + +[ + (type_qualifier) + (gnu_asm_qualifier) + "__extension__" +] @keyword.modifier + +(linkage_specification + "extern" @keyword.modifier) + +(type_definition + declarator: (type_identifier) @type.definition) + +(primitive_type) @type.builtin + +(sized_type_specifier + _ @type.builtin + type: _?) + +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z0-9_]+$")) + +(preproc_def + (preproc_arg) @constant + (#lua-match? @constant "^[A-Z][A-Z0-9_]+$")) + +(enumerator + name: (identifier) @constant) + +(case_statement + value: (identifier) @constant) + +((identifier) @constant.builtin + ; format-ignore + (#any-of? @constant.builtin + "stderr" "stdin" "stdout" + "__FILE__" "__LINE__" "__DATE__" "__TIME__" + "__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__" + "__cplusplus" "__OBJC__" "__ASSEMBLER__" + "__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__" + "__TIMESTAMP__" "__clang__" "__clang_major__" + "__clang_minor__" "__clang_patchlevel__" + "__clang_version__" "__clang_literal_encoding__" + "__clang_wide_literal_encoding__" + "__FUNCTION__" "__func__" "__PRETTY_FUNCTION__" + "__VA_ARGS__" "__VA_OPT__")) + +(preproc_def + (preproc_arg) @constant.builtin + ; format-ignore + (#any-of? @constant.builtin + "stderr" "stdin" "stdout" + "__FILE__" "__LINE__" "__DATE__" "__TIME__" + "__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__" + "__cplusplus" "__OBJC__" "__ASSEMBLER__" + "__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__" + "__TIMESTAMP__" "__clang__" "__clang_major__" + "__clang_minor__" "__clang_patchlevel__" + "__clang_version__" "__clang_literal_encoding__" + "__clang_wide_literal_encoding__" + "__FUNCTION__" "__func__" "__PRETTY_FUNCTION__" + "__VA_ARGS__" "__VA_OPT__")) + +(attribute_specifier + (argument_list + (identifier) @variable.builtin)) + +(attribute_specifier + (argument_list + (call_expression + function: (identifier) @variable.builtin))) + +((call_expression + function: (identifier) @function.builtin) + (#lua-match? @function.builtin "^__builtin_")) + +((call_expression + function: (identifier) @function.builtin) + (#has-ancestor? @function.builtin attribute_specifier)) + +; Preproc def / undef +(preproc_def + name: (_) @constant.macro) + +(preproc_call + directive: (preproc_directive) @_u + argument: (_) @constant.macro + (#eq? @_u "#undef")) + +(preproc_ifdef + name: (identifier) @constant.macro) + +(preproc_elifdef + name: (identifier) @constant.macro) + +(preproc_defined + (identifier) @constant.macro) + +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (field_expression + field: (field_identifier) @function.call)) + +(function_declarator + declarator: (identifier) @function) + +(function_declarator + declarator: (parenthesized_declarator + (pointer_declarator + declarator: (field_identifier) @function))) + +(preproc_function_def + name: (identifier) @function.macro) + +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +; Parameters +(parameter_declaration + declarator: (identifier) @variable.parameter) + +(parameter_declaration + declarator: (array_declarator) @variable.parameter) + +(parameter_declaration + declarator: (pointer_declarator) @variable.parameter) + +; K&R functions +; To enable support for K&R functions, +; add the following lines to your own query config and uncomment them. +; They are commented out as they'll conflict with C++ +; Note that you'll need to have `; extends` at the top of your query file. +; +; (parameter_list (identifier) @variable.parameter) +; +; (function_definition +; declarator: _ +; (declaration +; declarator: (identifier) @variable.parameter)) +; +; (function_definition +; declarator: _ +; (declaration +; declarator: (array_declarator) @variable.parameter)) +; +; (function_definition +; declarator: _ +; (declaration +; declarator: (pointer_declarator) @variable.parameter)) +(preproc_params + (identifier) @variable.parameter) + +[ + "__attribute__" + "__declspec" + "__based" + "__cdecl" + "__clrcall" + "__stdcall" + "__fastcall" + "__thiscall" + "__vectorcall" + (ms_pointer_modifier) + (attribute_declaration) +] @attribute diff --git a/runtime/queries/c/indents.scm b/runtime/queries/c/indents.scm new file mode 100644 index 000000000..1932ce8d6 --- /dev/null +++ b/runtime/queries/c/indents.scm @@ -0,0 +1,99 @@ +[ + (compound_statement) + (field_declaration_list) + (case_statement) + (enumerator_list) + (compound_literal_expression) + (initializer_list) + (init_declarator) +] @indent.begin + +; With current indent logic, if we capture expression_statement with @indent.begin +; It will be affected by _parent_ node with error subnodes deep down the tree +; So narrow indent capture to check for error inside expression statement only, +(expression_statement + (_) @indent.begin + ";" @indent.end) + +(ERROR + "for" + "(" @indent.begin + ";" + ";" + ")" @indent.end) + +((for_statement + body: (_) @_body) @indent.begin + (#not-kind-eq? @_body "compound_statement")) + +(while_statement + condition: (_) @indent.begin) + +((while_statement + body: (_) @_body) @indent.begin + (#not-kind-eq? @_body "compound_statement")) + +((if_statement) + . + (ERROR + "else" @indent.begin)) + +(if_statement + condition: (_) @indent.begin) + +; Supports if without braces (but not both if-else without braces) +(if_statement + consequence: (_ + ";" @indent.end) @_consequence + (#not-kind-eq? @_consequence "compound_statement") + alternative: (else_clause + "else" @indent.branch + [ + (if_statement + (compound_statement) @indent.dedent)? @indent.dedent + (compound_statement)? @indent.dedent + (_)? @indent.dedent + ])?) @indent.begin + +(else_clause + (_ + . + "{" @indent.branch)) + +(compound_statement + "}" @indent.end) + +[ + ")" + "}" + (statement_identifier) +] @indent.branch + +[ + "#define" + "#ifdef" + "#ifndef" + "#elif" + "#if" + "#else" + "#endif" +] @indent.zero + +[ + (preproc_arg) + (string_literal) +] @indent.ignore + +((ERROR + (parameter_declaration)) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +([ + (argument_list) + (parameter_list) +] @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +(comment) @indent.auto diff --git a/runtime/queries/c/injections.scm b/runtime/queries/c/injections.scm new file mode 100644 index 000000000..24634864e --- /dev/null +++ b/runtime/queries/c/injections.scm @@ -0,0 +1,128 @@ +((preproc_arg) @injection.content + (#set! injection.self)) + +((comment) @injection.content + (#set! injection.language "comment")) + +((comment) @injection.content + (#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c") + (#set! injection.language "re2c")) + +((comment) @injection.content + (#lua-match? @injection.content "/[*\/][!*\/]<?[^a-zA-Z]") + (#set! injection.language "doxygen")) + +((call_expression + function: (identifier) @_function + arguments: (argument_list + . + [ + (string_literal + (string_content) @injection.content) + (concatenated_string + (string_literal + (string_content) @injection.content)) + ])) + ; format-ignore + (#any-of? @_function + "printf" "printf_s" + "vprintf" "vprintf_s" + "scanf" "scanf_s" + "vscanf" "vscanf_s" + "wprintf" "wprintf_s" + "vwprintf" "vwprintf_s" + "wscanf" "wscanf_s" + "vwscanf" "vwscanf_s" + "cscanf" "_cscanf" + "printw" + "scanw") + (#set! injection.language "printf")) + +((call_expression + function: (identifier) @_function + arguments: (argument_list + (_) + . + [ + (string_literal + (string_content) @injection.content) + (concatenated_string + (string_literal + (string_content) @injection.content)) + ])) + ; format-ignore + (#any-of? @_function + "fprintf" "fprintf_s" + "sprintf" + "dprintf" + "fscanf" "fscanf_s" + "sscanf" "sscanf_s" + "vsscanf" "vsscanf_s" + "vfprintf" "vfprintf_s" + "vsprintf" + "vdprintf" + "fwprintf" "fwprintf_s" + "vfwprintf" "vfwprintf_s" + "fwscanf" "fwscanf_s" + "swscanf" "swscanf_s" + "vswscanf" "vswscanf_s" + "vfscanf" "vfscanf_s" + "vfwscanf" "vfwscanf_s" + "wprintw" + "vw_printw" "vwprintw" + "wscanw" + "vw_scanw" "vwscanw") + (#set! injection.language "printf")) + +((call_expression + function: (identifier) @_function + arguments: (argument_list + (_) + . + (_) + . + [ + (string_literal + (string_content) @injection.content) + (concatenated_string + (string_literal + (string_content) @injection.content)) + ])) + ; format-ignore + (#any-of? @_function + "sprintf_s" + "snprintf" "snprintf_s" + "vsprintf_s" + "vsnprintf" "vsnprintf_s" + "swprintf" "swprintf_s" + "snwprintf_s" + "vswprintf" "vswprintf_s" + "vsnwprintf_s" + "mvprintw" + "mvscanw") + (#set! injection.language "printf")) + +((call_expression + function: (identifier) @_function + arguments: (argument_list + (_) + . + (_) + . + (_) + . + [ + (string_literal + (string_content) @injection.content) + (concatenated_string + (string_literal + (string_content) @injection.content)) + ])) + (#any-of? @_function "mvwprintw" "mvwscanw") + (#set! injection.language "printf")) + +; TODO: add when asm is added +; (gnu_asm_expression assembly_code: (string_literal) @injection.content +; (#set! injection.language "asm")) +; (gnu_asm_expression assembly_code: (concatenated_string (string_literal) @injection.content) +; (#set! injection.language "asm")) diff --git a/runtime/queries/c/locals.scm b/runtime/queries/c/locals.scm new file mode 100644 index 000000000..13a122790 --- /dev/null +++ b/runtime/queries/c/locals.scm @@ -0,0 +1,67 @@ +; Functions definitions +(function_declarator + declarator: (identifier) @local.definition.function) + +(preproc_function_def + name: (identifier) @local.definition.macro) @local.scope + +(preproc_def + name: (identifier) @local.definition.macro) + +(pointer_declarator + declarator: (identifier) @local.definition.var) + +(parameter_declaration + declarator: (identifier) @local.definition.parameter) + +(init_declarator + declarator: (identifier) @local.definition.var) + +(array_declarator + declarator: (identifier) @local.definition.var) + +(declaration + declarator: (identifier) @local.definition.var) + +(enum_specifier + name: (_) @local.definition.type + (enumerator_list + (enumerator + name: (identifier) @local.definition.var))) + +; Type / Struct / Enum +(field_declaration + declarator: (field_identifier) @local.definition.field) + +(type_definition + declarator: (type_identifier) @local.definition.type) + +(struct_specifier + name: (type_identifier) @local.definition.type) + +; goto +(labeled_statement + (statement_identifier) @local.definition) + +; References +(identifier) @local.reference + +((field_identifier) @local.reference + (#set! reference.kind "field")) + +((type_identifier) @local.reference + (#set! reference.kind "type")) + +(goto_statement + (statement_identifier) @local.reference) + +; Scope +[ + (for_statement) + (if_statement) + (while_statement) + (translation_unit) + (function_definition) + (compound_statement) ; a block in curly braces + (struct_specifier) +] @local.scope diff --git a/runtime/queries/c_sharp/folds.scm b/runtime/queries/c_sharp/folds.scm new file mode 100644 index 000000000..16967b69d --- /dev/null +++ b/runtime/queries/c_sharp/folds.scm @@ -0,0 +1,17 @@ +body: [ + (declaration_list) + (switch_body) + (enum_member_declaration_list) +] @fold + +accessors: (accessor_list) @fold + +initializer: (initializer_expression) @fold + +[ + (block) + (preproc_if) + (preproc_elif) + (preproc_else) + (using_directive)+ +] @fold diff --git a/runtime/queries/c_sharp/highlights.scm b/runtime/queries/c_sharp/highlights.scm new file mode 100644 index 000000000..f23d7ec65 --- /dev/null +++ b/runtime/queries/c_sharp/highlights.scm @@ -0,0 +1,577 @@ +[ + (identifier) + (preproc_arg) +] @variable + +((preproc_arg) @constant.macro + (#lua-match? @constant.macro "^[_A-Z][_A-Z0-9]*$")) + +((identifier) @keyword + (#eq? @keyword "value") + (#has-ancestor? @keyword accessor_declaration)) + +(method_declaration + name: (identifier) @function.method) + +(local_function_statement + name: (identifier) @function.method) + +(method_declaration + returns: [ + (identifier) @type + (generic_name + (identifier) @type) + ]) + +(event_declaration + type: (identifier) @type) + +(event_declaration + name: (identifier) @variable.member) + +(event_field_declaration + (variable_declaration + (variable_declarator + name: (identifier) @variable.member))) + +(declaration_pattern + type: (identifier) @type) + +(local_function_statement + type: (identifier) @type) + +(interpolation) @none + +(member_access_expression + name: (identifier) @variable.member) + +(invocation_expression + (member_access_expression + name: (identifier) @function.method.call)) + +(invocation_expression + function: (conditional_access_expression + (member_binding_expression + name: (identifier) @function.method.call))) + +(namespace_declaration + name: [ + (qualified_name) + (identifier) + ] @module) + +(qualified_name + (identifier) @type) + +(namespace_declaration + name: (identifier) @module) + +(file_scoped_namespace_declaration + name: (identifier) @module) + +(qualified_name + (identifier) @module + (#not-has-ancestor? @module method_declaration) + (#not-has-ancestor? @module record_declaration) + (#has-ancestor? @module namespace_declaration file_scoped_namespace_declaration)) + +(invocation_expression + (identifier) @function.method.call) + +(field_declaration + (variable_declaration + (variable_declarator + (identifier) @variable.member))) + +(initializer_expression + (assignment_expression + left: (identifier) @variable.member)) + +(parameter + name: (identifier) @variable.parameter) + +(parameter_list + name: (identifier) @variable.parameter) + +(bracketed_parameter_list + name: (identifier) @variable.parameter) + +(implicit_parameter) @variable.parameter + +(parameter_list + (parameter + type: (identifier) @type)) + +(integer_literal) @number + +(real_literal) @number.float + +(null_literal) @constant.builtin + +(calling_convention + [ + (identifier) + "Cdecl" + "Stdcall" + "Thiscall" + "Fastcall" + ] @attribute.builtin) + +(character_literal) @character + +[ + (string_literal) + (raw_string_literal) + (verbatim_string_literal) + (interpolated_string_expression) +] @string + +(escape_sequence) @string.escape + +[ + "true" + "false" +] @boolean + +(predefined_type) @type.builtin + +(implicit_type) @keyword + +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) + +(using_directive + (identifier) @type) + +(using_directive + (type) @type.definition) + +(property_declaration + name: (identifier) @property) + +(property_declaration + type: (identifier) @type) + +(nullable_type + type: (identifier) @type) + +(array_type + type: (identifier) @type) + +(ref_type + type: (identifier) @type) + +(pointer_type + type: (identifier) @type) + +(catch_declaration + type: (identifier) @type) + +(interface_declaration + name: (identifier) @type) + +(class_declaration + name: (identifier) @type) + +(record_declaration + name: (identifier) @type) + +(struct_declaration + name: (identifier) @type) + +(enum_declaration + name: (identifier) @type) + +(enum_member_declaration + name: (identifier) @variable.member) + +(operator_declaration + type: (identifier) @type) + +(conversion_operator_declaration + type: (identifier) @type) + +(explicit_interface_specifier + [ + (identifier) @type + (generic_name + (identifier) @type) + ]) + +(explicit_interface_specifier + (identifier) @type) + +(primary_constructor_base_type + type: (identifier) @type) + +[ + "assembly" + "module" + "this" + "base" +] @variable.builtin + +(constructor_declaration + name: (identifier) @constructor) + +(destructor_declaration + name: (identifier) @constructor) + +(constructor_initializer + "base" @constructor) + +(variable_declaration + (identifier) @type) + +(object_creation_expression + (identifier) @type) + +; Generic Types. +(typeof_expression + (generic_name + (identifier) @type)) + +(type_argument_list + (generic_name + (identifier) @type)) + +(base_list + (generic_name + (identifier) @type)) + +(type_parameter_constraint + [ + (identifier) @type + (type + (generic_name + (identifier) @type)) + ]) + +(object_creation_expression + (generic_name + (identifier) @type)) + +(property_declaration + (generic_name + (identifier) @type)) + +(_ + type: (generic_name + (identifier) @type)) + +; Generic Method invocation with generic type +(invocation_expression + function: (generic_name + . + (identifier) @function.method.call)) + +(invocation_expression + (member_access_expression + (generic_name + (identifier) @function.method))) + +(base_list + (identifier) @type) + +(type_argument_list + (identifier) @type) + +(type_parameter_list + (type_parameter) @type) + +(type_parameter + name: (identifier) @type) + +(type_parameter_constraints_clause + "where" + . + (identifier) @type) + +(attribute + name: (identifier) @attribute) + +(foreach_statement + type: (identifier) @type) + +(goto_statement + (identifier) @label) + +(labeled_statement + (identifier) @label) + +(tuple_element + type: (identifier) @type) + +(tuple_expression + (argument + (declaration_expression + type: (identifier) @type))) + +(cast_expression + type: (identifier) @type) + +(lambda_expression + type: (identifier) @type) + +(as_expression + right: (identifier) @type) + +(typeof_expression + (identifier) @type) + +(preproc_error) @keyword.exception + +[ + "#define" + "#undef" +] @keyword.directive.define + +[ + "#if" + "#elif" + "#else" + "#endif" + "#region" + "#endregion" + "#line" + "#pragma" + "#nullable" + "#error" + (shebang_directive) +] @keyword.directive + +[ + (preproc_line) + (preproc_pragma) + (preproc_nullable) +] @constant.macro + +(preproc_pragma + (identifier) @constant) + +(preproc_if + (identifier) @constant) + +[ + "if" + "else" + "switch" + "break" + "case" + "when" +] @keyword.conditional + +[ + "while" + "for" + "do" + "continue" + "goto" + "foreach" +] @keyword.repeat + +[ + "try" + "catch" + "throw" + "finally" +] @keyword.exception + +[ + "+" + "?" + ":" + "++" + "-" + "--" + "&" + "&&" + "|" + "||" + "!" + "!=" + "==" + "*" + "/" + "%" + "<" + "<=" + ">" + ">=" + "=" + "-=" + "+=" + "*=" + "/=" + "%=" + "^" + "^=" + "&=" + "|=" + "~" + ">>" + ">>>" + "<<" + "<<=" + ">>=" + ">>>=" + "=>" + "??" + "??=" + ".." +] @operator + +(list_pattern + ".." @character.special) + +(discard) @character.special + +[ + ";" + "." + "," + ":" +] @punctuation.delimiter + +(conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +[ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket + +(interpolation_brace) @punctuation.special + +(type_argument_list + [ + "<" + ">" + ] @punctuation.bracket) + +[ + "using" + "as" +] @keyword.import + +(alias_qualified_name + (identifier + "global") @keyword.import) + +[ + "with" + "new" + "typeof" + "sizeof" + "is" + "and" + "or" + "not" + "stackalloc" + "__makeref" + "__reftype" + "__refvalue" + "in" + "out" + "ref" +] @keyword.operator + +[ + "lock" + "params" + "operator" + "default" + "implicit" + "explicit" + "override" + "get" + "set" + "init" + "where" + "add" + "remove" + "checked" + "unchecked" + "fixed" + "alias" + "file" + "unsafe" +] @keyword + +(attribute_target_specifier + . + _ @keyword) + +[ + "enum" + "record" + "class" + "struct" + "interface" + "namespace" + "event" + "delegate" +] @keyword.type + +[ + "async" + "await" +] @keyword.coroutine + +[ + "const" + "extern" + "readonly" + "static" + "volatile" + "required" + "managed" + "unmanaged" + "notnull" + "abstract" + "private" + "protected" + "internal" + "public" + "partial" + "sealed" + "virtual" + "global" +] @keyword.modifier + +(scoped_type + "scoped" @keyword.modifier) + +(query_expression + (_ + [ + "from" + "orderby" + "select" + "group" + "by" + "ascending" + "descending" + "equals" + "let" + ] @keyword)) + +[ + "return" + "yield" +] @keyword.return diff --git a/runtime/queries/c_sharp/injections.scm b/runtime/queries/c_sharp/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/c_sharp/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/c_sharp/locals.scm b/runtime/queries/c_sharp/locals.scm new file mode 100644 index 000000000..bef094007 --- /dev/null +++ b/runtime/queries/c_sharp/locals.scm @@ -0,0 +1,42 @@ +; Definitions +(variable_declarator + . + (identifier) @local.definition.var) + +(variable_declarator + (tuple_pattern + (identifier) @local.definition.var)) + +(declaration_expression + name: (identifier) @local.definition.var) + +(foreach_statement + left: (identifier) @local.definition.var) + +(foreach_statement + left: (tuple_pattern + (identifier) @local.definition.var)) + +(parameter + (identifier) @local.definition.parameter) + +(method_declaration + name: (identifier) @local.definition.method) + +(local_function_statement + name: (identifier) @local.definition.method) + +(property_declaration + name: (identifier) @local.definition) + +(type_parameter + (identifier) @local.definition.type) + +(class_declaration + name: (identifier) @local.definition) + +; References +(identifier) @local.reference + +; Scope +(block) @local.scope diff --git a/runtime/queries/caddy/folds.scm b/runtime/queries/caddy/folds.scm new file mode 100644 index 000000000..fd7d23999 --- /dev/null +++ b/runtime/queries/caddy/folds.scm @@ -0,0 +1 @@ +(block) @fold diff --git a/runtime/queries/caddy/highlights.scm b/runtime/queries/caddy/highlights.scm new file mode 100644 index 000000000..47a170f76 --- /dev/null +++ b/runtime/queries/caddy/highlights.scm @@ -0,0 +1,55 @@ +(comment) @comment @spell + +[ + (env) + (argv) + (block_variable) + (placeholder) +] @constant + +(value) @variable + +(directive + (keyword) @attribute) + +(global_options + (option + (keyword) @attribute)) + +(keyword) @keyword + +(boolean) @boolean + +(placeholder + [ + "{" + "}" + ] @punctuation.special) + +(auto) @variable.builtin + +[ + (string_literal) + (quoted_string_literal) + (address) +] @string + +[ + (matcher) + (route) + (snippet_name) +] @string.special + +[ + (numeric_literal) + (time) + (size) + (ip_literal) +] @number + +[ + "{" + "}" +] @punctuation.bracket + +"," @punctuation.delimiter diff --git a/runtime/queries/caddy/indents.scm b/runtime/queries/caddy/indents.scm new file mode 100644 index 000000000..b746788ab --- /dev/null +++ b/runtime/queries/caddy/indents.scm @@ -0,0 +1,8 @@ +(block) @indent.begin + +(block + "}" @indent.branch) + +(comment) @indent.auto + +(ERROR) @indent.auto diff --git a/runtime/queries/caddy/injections.scm b/runtime/queries/caddy/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/caddy/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/cairo/folds.scm b/runtime/queries/cairo/folds.scm new file mode 100644 index 000000000..9937da6f1 --- /dev/null +++ b/runtime/queries/cairo/folds.scm @@ -0,0 +1,26 @@ +[ + (mod_item) + (struct_item) + (trait_item) + (enum_item) + (impl_item) + (type_item) + (use_declaration) + (let_declaration) + (namespace_definition) + (arguments) + (implicit_arguments) + (tuple_type) + (import_statement) + (attribute_statement) + (with_statement) + (if_statement) + (function_definition) + (struct_definition) + (loop_expression) + (if_expression) + (match_expression) + (call_expression) + (tuple_expression) + (attribute_item) +] @fold diff --git a/runtime/queries/cairo/highlights.scm b/runtime/queries/cairo/highlights.scm new file mode 100644 index 000000000..1ea6245d3 --- /dev/null +++ b/runtime/queries/cairo/highlights.scm @@ -0,0 +1,414 @@ +; Preproc +[ + "%builtins" + "%lang" +] @keyword.directive + +; Includes +(import_statement + [ + "from" + "import" + ] @keyword.import + module_name: (dotted_name + (identifier) @module .)) + +[ + "as" + "use" + "mod" +] @keyword.import + +; Variables +(identifier) @variable + +; Namespaces +(namespace_definition + (identifier) @module) + +(mod_item + name: (identifier) @module) + +(use_list + (self) @module) + +(scoped_use_list + (self) @module) + +(scoped_identifier + path: (identifier) @module) + +(scoped_identifier + (scoped_identifier + name: (identifier) @module)) + +(scoped_type_identifier + path: (identifier) @module) + +((scoped_identifier + path: (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +((scoped_identifier + name: (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +((scoped_identifier + name: (identifier) @constant) + (#lua-match? @constant "^[A-Z][A-Z%d_]*$")) + +((scoped_identifier + path: (identifier) @type + name: (identifier) @constant) + (#lua-match? @type "^[A-Z]") + (#lua-match? @constant "^[A-Z]")) + +((scoped_type_identifier + path: (identifier) @type + name: (type_identifier) @constant) + (#lua-match? @type "^[A-Z]") + (#lua-match? @constant "^[A-Z]")) + +(scoped_use_list + path: (identifier) @module) + +(scoped_use_list + path: (scoped_identifier + (identifier) @module)) + +(use_list + (scoped_identifier + (identifier) @module + . + (_))) + +(use_list + (identifier) @type + (#lua-match? @type "^[A-Z]")) + +(use_as_clause + alias: (identifier) @type + (#lua-match? @type "^[A-Z]")) + +; Keywords +[ + ; 0.x + "using" + "let" + "const" + "local" + "rel" + "abs" + "dw" + "alloc_locals" + (inst_ret) + "with_attr" + "with" + "call" + "nondet" + ; 1.0 + "impl" + "implicits" + "of" + "ref" + "mut" +] @keyword + +[ + "struct" + "enum" + "namespace" + "type" + "trait" +] @keyword.type + +[ + "func" + "fn" + "end" +] @keyword.function + +"return" @keyword.return + +[ + "cast" + "new" + "and" +] @keyword.operator + +[ + "tempvar" + "extern" +] @keyword.modifier + +[ + "if" + "else" + "match" +] @keyword.conditional + +"loop" @keyword.repeat + +[ + "assert" + "static_assert" + "nopanic" +] @keyword.exception + +; Fields +(implicit_arguments + (typed_identifier + (identifier) @variable.member)) + +(member_expression + "." + (identifier) @variable.member) + +(call_expression + (assignment_expression + left: (identifier) @variable.member)) + +(tuple_expression + (assignment_expression + left: (identifier) @variable.member)) + +(field_identifier) @variable.member + +(shorthand_field_initializer + (identifier) @variable.member) + +; Parameters +(arguments + (typed_identifier + (identifier) @variable.parameter)) + +(call_expression + (tuple_expression + (assignment_expression + left: (identifier) @variable.parameter))) + +(return_type + (tuple_type + (named_type + . + (identifier) @variable.parameter))) + +(parameter + (identifier) @variable.parameter) + +; Builtins +(builtin_directive + (identifier) @variable.builtin) + +(lang_directive + (identifier) @variable.builtin) + +[ + "ap" + "fp" + (self) +] @variable.builtin + +; Functions +(function_definition + "func" + (identifier) @function) + +(function_definition + "fn" + (identifier) @function) + +(function_signature + "fn" + (identifier) @function) + +(extern_function_statement + (identifier) @function) + +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (scoped_identifier + (identifier) @function.call .)) + +(call_expression + function: (field_expression + field: (field_identifier) @function.call)) + +"jmp" @function.builtin + +; Types +(struct_definition + . + (identifier) @type + (typed_identifier + (identifier) @variable.member)?) + +(named_type + (identifier) @type .) + +[ + (builtin_type) + (primitive_type) +] @type.builtin + +((identifier) @type + (#lua-match? @type "^[A-Z][a-zA-Z0-9_]*$")) + +(type_identifier) @type + +; Constants +((identifier) @constant + (#lua-match? @constant "^[A-Z_][A-Z0-9_]*$")) + +(enum_variant + name: (identifier) @constant) + +(call_expression + function: (scoped_identifier + "::" + name: (identifier) @constant) + (#lua-match? @constant "^[A-Z]")) + +((match_arm + pattern: (match_pattern + (identifier) @constant)) + (#lua-match? @constant "^[A-Z]")) + +((match_arm + pattern: (match_pattern + (scoped_identifier + name: (identifier) @constant))) + (#lua-match? @constant "^[A-Z]")) + +((identifier) @constant.builtin + (#any-of? @constant.builtin "Some" "None" "Ok" "Err")) + +; Constructors +(unary_expression + "new" + (call_expression + . + (identifier) @constructor)) + +((call_expression + . + (identifier) @constructor) + (#lua-match? @constructor "^%u")) + +; Attributes +(decorator + "@" @attribute + (identifier) @attribute) + +(attribute_item + (identifier) @function.macro) + +(attribute_item + (scoped_identifier + (identifier) @function.macro .)) + +; Labels +(label + . + (identifier) @label) + +(inst_jmp_to_label + "jmp" + . + (identifier) @label) + +(inst_jnz_to_label + "jmp" + . + (identifier) @label) + +; Operators +[ + "+" + "-" + "*" + "/" + "**" + "==" + "!=" + "&" + "=" + "++" + "+=" + "@" + "!" + "~" + ".." + "&&" + "||" + "^" + "<" + "<=" + ">" + ">=" + "<<" + ">>" + "%" + "-=" + "*=" + "/=" + "%=" + "&=" + "|=" + "^=" + "<<=" + ">>=" + "?" +] @operator + +; Literals +(number) @number + +(boolean) @boolean + +[ + (string) + (short_string) +] @string + +; Punctuation +(attribute_item + "#" @punctuation.special) + +[ + "." + "," + ":" + ";" + "->" + "=>" + "::" +] @punctuation.delimiter + +[ + "{" + "}" + "(" + ")" + "[" + "]" + "%{" + "%}" +] @punctuation.bracket + +(type_parameters + [ + "<" + ">" + ] @punctuation.bracket) + +(type_arguments + [ + "<" + ">" + ] @punctuation.bracket) + +; Comment +(comment) @comment @spell diff --git a/runtime/queries/cairo/indents.scm b/runtime/queries/cairo/indents.scm new file mode 100644 index 000000000..f63ef36fe --- /dev/null +++ b/runtime/queries/cairo/indents.scm @@ -0,0 +1,57 @@ +[ + (mod_item) + (struct_item) + (enum_item) + (impl_item) + (struct_expression) + (match_expression) + (tuple_expression) + (match_arm) + (match_block) + (call_expression) + (assignment_expression) + (arguments) + (block) + (use_list) + (field_declaration_list) + (enum_variant_list) + (tuple_pattern) +] @indent.begin + +(import_statement + "(") @indent.begin + +(block + "}" @indent.end) + +(enum_item + body: (enum_variant_list + "}" @indent.end)) + +(match_expression + body: (match_block + "}" @indent.end)) + +(mod_item + body: (declaration_list + "}" @indent.end)) + +(struct_item + body: (field_declaration_list + "}" @indent.end)) + +(trait_item + body: (declaration_list + "}" @indent.end)) + +[ + ")" + "]" + "}" +] @indent.branch + +[ + (comment) + (string) + (short_string) +] @indent.ignore diff --git a/runtime/queries/cairo/injections.scm b/runtime/queries/cairo/injections.scm new file mode 100644 index 000000000..fbb66be38 --- /dev/null +++ b/runtime/queries/cairo/injections.scm @@ -0,0 +1,5 @@ +((python_code) @injection.content + (#set! injection.language "python")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/cairo/locals.scm b/runtime/queries/cairo/locals.scm new file mode 100644 index 000000000..0573cf6db --- /dev/null +++ b/runtime/queries/cairo/locals.scm @@ -0,0 +1,66 @@ +; References +(identifier) @local.reference + +((type_identifier) @local.reference + (#set! reference.kind "type")) + +((field_identifier) @local.reference + (#set! reference.kind "field")) + +; Scopes +[ + (program) + (block) + (function_definition) + (loop_expression) + (if_expression) + (match_expression) + (match_arm) + (struct_item) + (enum_item) + (impl_item) +] @local.scope + +(use_declaration + argument: (scoped_identifier + name: (identifier) @local.definition.import)) + +(use_as_clause + alias: (identifier) @local.definition.import) + +(use_list + (identifier) @local.definition.import) ; use std::process::{Child, Command, Stdio}; + +; Functions +(function_definition + (identifier) @local.definition.function) + +(function_definition + (identifier) @local.definition.method + (parameter + (self))) + +; Function with parameters, defines parameters +(parameter + [ + (identifier) + (self) + ] @local.definition.parameter) + +; Types +(struct_item + name: (type_identifier) @local.definition.type) + +(constrained_type_parameter + left: (type_identifier) @local.definition.type) ; the P in remove_file<P: AsRef<Path>>(path: P) + +(enum_item + name: (type_identifier) @local.definition.type) + +; Module +(mod_item + name: (identifier) @local.definition.namespace) + +; Variables +(assignment_expression + left: (identifier) @local.definition.var) diff --git a/runtime/queries/capnp/folds.scm b/runtime/queries/capnp/folds.scm new file mode 100644 index 000000000..6e3f9c187 --- /dev/null +++ b/runtime/queries/capnp/folds.scm @@ -0,0 +1,14 @@ +[ + (annotation_targets) + (const_list) + (enum) + (interface) + (implicit_generics) + (generics) + (group) + (method_parameters) + (named_return_types) + (struct) + (struct_shorthand) + (union) +] @fold diff --git a/runtime/queries/capnp/highlights.scm b/runtime/queries/capnp/highlights.scm new file mode 100644 index 000000000..a48c007ed --- /dev/null +++ b/runtime/queries/capnp/highlights.scm @@ -0,0 +1,141 @@ +; Preproc +[ + (unique_id) + (top_level_annotation_body) +] @keyword.directive + +; Includes +[ + "import" + "$import" + "embed" + "using" +] @keyword.import + +(import_path) @string.special.path + +; Keywords +"extends" @keyword + +[ + "struct" + "interface" + "union" + "enum" + "annotation" + "group" + "namespace" +] @keyword.type + +; Builtins +"const" @keyword.modifier + +[ + (primitive_type) + "List" +] @type.builtin + +; Typedefs +(type_definition) @type.definition + +; Labels (@number, @number!) +(field_version) @label + +; Methods +[ + (annotation_definition_identifier) + (method_identifier) +] @function.method + +; Fields +(field_identifier) @variable.member + +; Properties +(property) @property + +; Parameters +[ + (param_identifier) + (return_identifier) +] @variable.parameter + +(annotation_target) @variable.parameter.builtin + +; Constants +[ + (const_identifier) + (local_const) + (enum_member) +] @constant + +(void) @constant.builtin + +; Types +[ + (enum_identifier) + (extend_type) + (type_identifier) +] @type + +; Attributes +[ + (annotation_identifier) + (attribute) +] @attribute + +; Operators +"=" @operator + +; Literals +[ + (string) + (concatenated_string) + (block_text) + (namespace) +] @string + +(namespace) @string.special + +(escape_sequence) @string.escape + +(data_string) @string.special + +(number) @number + +(float) @number.float + +(boolean) @boolean + +(data_hex) @string.special.symbol + +; Punctuation +[ + "*" + "$" + ":" +] @punctuation.special + +[ + "{" + "}" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "." + "," + ";" + "->" +] @punctuation.delimiter + +; Comments +(comment) @comment @spell diff --git a/runtime/queries/capnp/indents.scm b/runtime/queries/capnp/indents.scm new file mode 100644 index 000000000..cc2f4d756 --- /dev/null +++ b/runtime/queries/capnp/indents.scm @@ -0,0 +1,40 @@ +[ + (annotation_targets) + (const) + (enum) + (interface) + (implicit_generics) + (generics) + (group) + (method_parameters) + (named_return_types) + (struct) + (union) + (field) +] @indent.begin + +((struct_shorthand + (property)) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +((method + (field_version)) @indent.align + (#set! indent.open_delimiter field_version)) + +((const_list + (const_value)) @indent.align + (#set! indent.open_delimiter "[") + (#set! indent.close_delimiter "]")) + +(concatenated_string) @indent.align + +[ + "}" + ")" +] @indent.end @indent.branch + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/runtime/queries/capnp/injections.scm b/runtime/queries/capnp/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/capnp/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/capnp/locals.scm b/runtime/queries/capnp/locals.scm new file mode 100644 index 000000000..d1f0ccacc --- /dev/null +++ b/runtime/queries/capnp/locals.scm @@ -0,0 +1,97 @@ +[ + (message) + (annotation_targets) + (const_list) + (enum) + (interface) + (implicit_generics) + (generics) + (group) + (method_parameters) + (named_return_types) + (struct) + (struct_shorthand) + (union) +] @local.scope + +[ + (extend_type) + (field_type) +] @local.reference + +(custom_type + (type_identifier) @local.reference) + +(custom_type + (generics + (generic_parameters + (generic_identifier) @local.reference))) + +(annotation_definition_identifier) @local.definition + +(const_identifier) @local.definition.constant + +(enum + (enum_identifier) @local.definition.enum) + +[ + (enum_member) + (field_identifier) +] @local.definition.field + +(method_identifier) @local.definition.method + +(namespace) @local.definition.namespace + +[ + (param_identifier) + (return_identifier) +] @local.definition.parameter + +(group + (type_identifier) @local.definition.type) + +(struct + (type_identifier) @local.definition.type) + +(union + (type_identifier) @local.definition.type) + +(interface + (type_identifier) @local.definition.type) + +; Generics Related (don't know how to combine these) +(struct + (generics + (generic_parameters + (generic_identifier) @local.definition.parameter))) + +(interface + (generics + (generic_parameters + (generic_identifier) @local.definition.parameter))) + +(method + (implicit_generics + (implicit_generic_parameters + (generic_identifier) @local.definition.parameter))) + +(method + (generics + (generic_parameters + (generic_identifier) @local.definition.parameter))) + +(annotation + (generics + (generic_parameters + (generic_identifier) @local.definition.type))) + +(replace_using + (generics + (generic_parameters + (generic_identifier) @local.definition.type))) + +(return_type + (generics + (generic_parameters + (generic_identifier) @local.definition.type))) diff --git a/runtime/queries/chatito/folds.scm b/runtime/queries/chatito/folds.scm new file mode 100644 index 000000000..052dd2064 --- /dev/null +++ b/runtime/queries/chatito/folds.scm @@ -0,0 +1,5 @@ +[ + (intent_def) + (slot_def) + (alias_def) +] @fold diff --git a/runtime/queries/chatito/highlights.scm b/runtime/queries/chatito/highlights.scm new file mode 100644 index 000000000..47113f2cf --- /dev/null +++ b/runtime/queries/chatito/highlights.scm @@ -0,0 +1,54 @@ +; Punctuation +[ + "%[" + "@[" + "~[" + "*[" + "]" + "(" + ")" +] @punctuation.bracket + +"," @punctuation.delimiter + +(eq) @operator + +([ + "\"" + "'" +] @punctuation.special + (#set! conceal "")) + +[ + "%" + "?" + "#" +] @character.special + +; Entities +(intent) @module + +(slot) @type + +(variation) @attribute + +(alias) @keyword.directive + +(number) @number + +(argument + key: (string) @property + value: (string) @string) + +(escape) @string.escape + +; Import +"import" @keyword.import + +(file) @string.special.path + +; Text +(word) @spell + +; Comment +(comment) @comment @spell diff --git a/runtime/queries/chatito/indents.scm b/runtime/queries/chatito/indents.scm new file mode 100644 index 000000000..dc9e13d78 --- /dev/null +++ b/runtime/queries/chatito/indents.scm @@ -0,0 +1,8 @@ +[ + (intent_def) + (slot_def) + (alias_def) +] @indent.begin + +(ERROR + "]") @indent.begin diff --git a/runtime/queries/chatito/injections.scm b/runtime/queries/chatito/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/chatito/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/chatito/locals.scm b/runtime/queries/chatito/locals.scm new file mode 100644 index 000000000..827447f57 --- /dev/null +++ b/runtime/queries/chatito/locals.scm @@ -0,0 +1,16 @@ +; Definitions +(intent_def + (intent) @local.definition) + +(slot_def + (slot) @local.definition) + +(alias_def + (alias) @local.definition) + +; References +(slot_ref + (slot) @local.reference) + +(alias_ref + (alias) @local.reference) diff --git a/runtime/queries/circom/folds.scm b/runtime/queries/circom/folds.scm new file mode 100644 index 000000000..47525b174 --- /dev/null +++ b/runtime/queries/circom/folds.scm @@ -0,0 +1,13 @@ +[ + (template_body) + (block_statement) + (if_statement) + (for_statement) + (while_statement) + (function_body) + (call_expression) + (array_expression) + (tuple_expression) + (comment) + (include_directive)+ +] @fold diff --git a/runtime/queries/circom/highlights.scm b/runtime/queries/circom/highlights.scm new file mode 100644 index 000000000..c61925e7a --- /dev/null +++ b/runtime/queries/circom/highlights.scm @@ -0,0 +1,137 @@ +; identifiers +; ----------- +(identifier) @variable + +; Pragma +; ----------- +[ + "pragma" + "circom" +] @keyword.directive + +(circom_version) @string.special + +; Include +; ----------- +[ + "public" + "signal" + "var" + "include" +] @keyword.import + +; Literals +; -------- +(string) @string + +(int_literal) @number + +; Definitions +; ----------- +(function_definition + name: (identifier) @function) + +(template_definition + name: (identifier) @function) + +; Use constructor coloring for special functions +"main" @constructor + +; Invocations +(call_expression + . + (identifier) @function.call) + +; Function parameters +(parameter + name: (identifier) @variable.parameter) + +; Members +(member_expression + property: (property_identifier) @property) + +; Tokens +; ------- +; Keywords +[ + "input" + "output" + "public" + "component" +] @keyword + +[ + "for" + "while" +] @keyword.repeat + +[ + "if" + "else" +] @keyword.conditional + +"return" @keyword.return + +[ + "function" + "template" +] @keyword.function + +; Punctuation +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "." + "," + ";" +] @punctuation.delimiter + +; Operators +[ + "&&" + "||" + ">>" + "<<" + "&" + "^" + "|" + "+" + "-" + "*" + "/" + "%" + "**" + "<" + "<=" + "=" + "==" + "!=" + "+=" + "-=" + ">=" + ">" + "!" + "~" + "-" + "+" + "++" + "--" + "<==" + "==>" + "<--" + "-->" + "===" +] @operator + +; Comments +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) diff --git a/runtime/queries/circom/injections.scm b/runtime/queries/circom/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/circom/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/circom/locals.scm b/runtime/queries/circom/locals.scm new file mode 100644 index 000000000..4c3a75152 --- /dev/null +++ b/runtime/queries/circom/locals.scm @@ -0,0 +1,12 @@ +(function_definition) @local.scope + +(template_definition) @local.scope + +(main_component_definition) @local.scope + +(block_statement) @local.scope + +(parameter + name: (identifier) @local.definition) @local.definition + +(identifier) @local.reference diff --git a/runtime/queries/clojure/folds.scm b/runtime/queries/clojure/folds.scm new file mode 100644 index 000000000..eceb69712 --- /dev/null +++ b/runtime/queries/clojure/folds.scm @@ -0,0 +1,2 @@ +(source + (list_lit) @fold) diff --git a/runtime/queries/clojure/highlights.scm b/runtime/queries/clojure/highlights.scm new file mode 100644 index 000000000..264276634 --- /dev/null +++ b/runtime/queries/clojure/highlights.scm @@ -0,0 +1,347 @@ +; >> Explanation +; Parsers for lisps are a bit weird in that they just return the raw forms. +; This means we have to do a bit of extra work in the queries to get things +; highlighted as they should be. +; +; For the most part this means that some things have to be assigned multiple +; groups. +; By doing this we can add a basic capture and then later refine it with more +; specialized captures. +; This can mean that sometimes things are highlighted weirdly because they +; have multiple highlight groups applied to them. +; >> Literals +((dis_expr) @comment + (#set! priority 105) + ; Higher priority to mark the whole sexpr as a comment + ) + +(kwd_lit) @string.special.symbol + +(str_lit) @string + +(num_lit) @number + +(char_lit) @character + +(bool_lit) @boolean + +(nil_lit) @constant.builtin + +(comment) @comment @spell + +(regex_lit) @string.regexp + +[ + "'" + "`" +] @string.escape + +[ + "~" + "~@" + "#" +] @punctuation.special + +[ + "{" + "}" + "[" + "]" + "(" + ")" +] @punctuation.bracket + +; >> Symbols +; General symbol highlighting +(sym_lit) @variable + +; General function calls +(list_lit + . + (sym_lit) @function.call) + +(anon_fn_lit + . + (sym_lit) @function.call) + +; Quoted symbols +(quoting_lit + (sym_lit) @string.special.symbol) + +(syn_quoting_lit + (sym_lit) @string.special.symbol) + +; Used in destructure pattern +((sym_lit) @variable.parameter + (#lua-match? @variable.parameter "^[&]")) + +; Inline function variables +((sym_lit) @variable.builtin + (#lua-match? @variable.builtin "^%%%d*$")) + +((sym_lit) @variable.builtin + (#eq? @variable.builtin "%&")) + +; Constructor +((sym_lit) @constructor + (#lua-match? @constructor "^-%>[^>].*")) + +; Builtin dynamic variables +((sym_lit) @variable.builtin + (#any-of? @variable.builtin + "*agent*" "*allow-unresolved-vars*" "*assert*" "*clojure-version*" "*command-line-args*" + "*compile-files*" "*compile-path*" "*compiler-options*" "*data-readers*" + "*default-data-reader-fn*" "*err*" "*file*" "*flush-on-newline*" "*fn-loader*" "*in*" + "*math-context*" "*ns*" "*out*" "*print-dup*" "*print-length*" "*print-level*" "*print-meta*" + "*print-namespace-maps*" "*print-readably*" "*read-eval*" "*reader-resolver*" "*source-path*" + "*suppress-read*" "*unchecked-math*" "*use-context-classloader*" "*verbose-defrecords*" + "*warn-on-reflection*")) + +; Builtin repl variables +((sym_lit) @variable.builtin + (#any-of? @variable.builtin "*1" "*2" "*3" "*e")) + +; Types +(sym_lit + name: (sym_name) @_name + (#lua-match? @_name "^[%u][^/%s]*$")) @type + +; Symbols with `.` but not `/` +(sym_lit + !namespace + name: (sym_name) @_name + (#lua-match? @_name "^[^.]+[.]")) @type + +; Interop +; (.instanceMember instance args*) +; (.instanceMember Classname args*) +((sym_lit + name: (sym_name) @_name) @function.method + (#lua-match? @_name "^%.[^-]")) + +; (.-instanceField instance) +((sym_name) @variable.member + (#lua-match? @variable.member "^%.%-%S*")) + +; Classname/staticField +(sym_lit + namespace: (sym_ns) @_namespace + (#lua-match? @_namespace "^[%u]%S*$")) @variable.member + +; (Classname/staticMethod args*) +(list_lit + . + (sym_lit + namespace: (sym_ns) @_namespace + (#lua-match? @_namespace "^%u")) @function.method) + +; TODO: Special casing for the `.` macro +; Operators +((sym_lit) @operator + (#any-of? @operator "*" "*'" "+" "+'" "-" "-'" "/" "<" "<=" ">" ">=" "=" "==")) + +((sym_lit) @keyword.operator + (#any-of? @keyword.operator "not" "not=" "and" "or")) + +; Definition functions +((sym_lit) @keyword + (#any-of? @keyword + "def" "defonce" "defrecord" "defmacro" "definline" "definterface" "defmulti" "defmethod" + "defstruct" "defprotocol" "deftype")) + +((sym_lit) @keyword + (#eq? @keyword "declare")) + +((sym_name) @keyword.coroutine + (#any-of? @keyword.coroutine + "alts!" "alts!!" "await" "await-for" "await1" "chan" "close!" "future" "go" "sync" "thread" + "timeout" "<!" "<!!" ">!" ">!!")) + +((sym_lit + name: (sym_name) @_keyword.function.name) @keyword.function + (#any-of? @_keyword.function.name "defn" "defn-" "fn" "fn*")) + +; Comment +((sym_lit) @comment + (#eq? @comment "comment")) + +; Conditionals +((sym_lit) @keyword.conditional + (#any-of? @keyword.conditional "case" "cond" "cond->" "cond->>" "condp")) + +((sym_lit) @keyword.conditional + (#any-of? @keyword.conditional "if" "if-let" "if-not" "if-some")) + +((sym_lit) @keyword.conditional + (#any-of? @keyword.conditional "when" "when-first" "when-let" "when-not" "when-some")) + +; Repeats +((sym_lit) @keyword.repeat + (#any-of? @keyword.repeat "doseq" "dotimes" "for" "loop" "recur" "while")) + +; Exception +((sym_lit) @keyword.exception + (#any-of? @keyword.exception "throw" "try" "catch" "finally")) + +; Includes +((sym_lit) @keyword.import + (#any-of? @keyword.import "ns" "import" "require" "use")) + +; Builtin macros +; TODO: Do all these items belong here? +((sym_lit + name: (sym_name) @function.macro) + (#any-of? @function.macro + "." ".." "->" "->>" "amap" "areduce" "as->" "assert" "binding" "bound-fn" "delay" "do" "dosync" + "doto" "extend-protocol" "extend-type" "gen-class" "gen-interface" "io!" "lazy-cat" "lazy-seq" + "let" "letfn" "locking" "memfn" "monitor-enter" "monitor-exit" "proxy" "proxy-super" "pvalues" + "refer-clojure" "reify" "set!" "some->" "some->>" "time" "unquote" "unquote-splicing" "var" + "vswap!" "with-bindings" "with-in-str" "with-loading-context" "with-local-vars" "with-open" + "with-out-str" "with-precision" "with-redefs")) + +; All builtin functions +; (->> (ns-publics *ns*) +; (keep (fn [[s v]] (when-not (:macro (meta v)) s))) +; sort +; clojure.pprint/pprint)) +; ...and then lots of manual filtering... +((sym_lit + name: (sym_name) @function.builtin) + (#any-of? @function.builtin + "->ArrayChunk" "->Eduction" "->Vec" "->VecNode" "->VecSeq" "-cache-protocol-fn" "-reset-methods" + "PrintWriter-on" "StackTraceElement->vec" "Throwable->map" "accessor" "aclone" "add-classpath" + "add-tap" "add-watch" "agent" "agent-error" "agent-errors" "aget" "alength" "alias" "all-ns" + "alter" "alter-meta!" "alter-var-root" "ancestors" "any?" "apply" "array-map" "aset" + "aset-boolean" "aset-byte" "aset-char" "aset-double" "aset-float" "aset-int" "aset-long" + "aset-short" "assoc" "assoc!" "assoc-in" "associative?" "atom" "bases" "bean" "bigdec" "bigint" + "biginteger" "bit-and" "bit-and-not" "bit-clear" "bit-flip" "bit-not" "bit-or" "bit-set" + "bit-shift-left" "bit-shift-right" "bit-test" "bit-xor" "boolean" "boolean-array" "boolean?" + "booleans" "bound-fn*" "bound?" "bounded-count" "butlast" "byte" "byte-array" "bytes" "bytes?" + "cast" "cat" "char" "char-array" "char-escape-string" "char-name-string" "char?" "chars" "chunk" + "chunk-append" "chunk-buffer" "chunk-cons" "chunk-first" "chunk-next" "chunk-rest" + "chunked-seq?" "class" "class?" "clear-agent-errors" "clojure-version" "coll?" "commute" "comp" + "comparator" "compare" "compare-and-set!" "compile" "complement" "completing" "concat" "conj" + "conj!" "cons" "constantly" "construct-proxy" "contains?" "count" "counted?" "create-ns" + "create-struct" "cycle" "dec" "dec'" "decimal?" "dedupe" "default-data-readers" "delay?" + "deliver" "denominator" "deref" "derive" "descendants" "destructure" "disj" "disj!" "dissoc" + "dissoc!" "distinct" "distinct?" "doall" "dorun" "double" "double-array" "eduction" "empty" + "empty?" "ensure" "ensure-reduced" "enumeration-seq" "error-handler" "error-mode" "eval" "even?" + "every-pred" "every?" "extend" "extenders" "extends?" "false?" "ffirst" "file-seq" "filter" + "filterv" "find" "find-keyword" "find-ns" "find-protocol-impl" "find-protocol-method" "find-var" + "first" "flatten" "float" "float-array" "float?" "floats" "flush" "fn?" "fnext" "fnil" "force" + "format" "frequencies" "future-call" "future-cancel" "future-cancelled?" "future-done?" + "future?" "gensym" "get" "get-in" "get-method" "get-proxy-class" "get-thread-bindings" + "get-validator" "group-by" "halt-when" "hash" "hash-combine" "hash-map" "hash-ordered-coll" + "hash-set" "hash-unordered-coll" "ident?" "identical?" "identity" "ifn?" "in-ns" "inc" "inc'" + "indexed?" "init-proxy" "inst-ms" "inst-ms*" "inst?" "instance?" "int" "int-array" "int?" + "integer?" "interleave" "intern" "interpose" "into" "into-array" "ints" "isa?" "iterate" + "iterator-seq" "juxt" "keep" "keep-indexed" "key" "keys" "keyword" "keyword?" "last" "line-seq" + "list" "list*" "list?" "load" "load-file" "load-reader" "load-string" "loaded-libs" "long" + "long-array" "longs" "macroexpand" "macroexpand-1" "make-array" "make-hierarchy" "map" + "map-entry?" "map-indexed" "map?" "mapcat" "mapv" "max" "max-key" "memoize" "merge" "merge-with" + "meta" "method-sig" "methods" "min" "min-key" "mix-collection-hash" "mod" "munge" "name" + "namespace" "namespace-munge" "nat-int?" "neg-int?" "neg?" "newline" "next" "nfirst" "nil?" + "nnext" "not-any?" "not-empty" "not-every?" "ns-aliases" "ns-imports" "ns-interns" "ns-map" + "ns-name" "ns-publics" "ns-refers" "ns-resolve" "ns-unalias" "ns-unmap" "nth" "nthnext" + "nthrest" "num" "number?" "numerator" "object-array" "odd?" "parents" "partial" "partition" + "partition-all" "partition-by" "pcalls" "peek" "persistent!" "pmap" "pop" "pop!" + "pop-thread-bindings" "pos-int?" "pos?" "pr" "pr-str" "prefer-method" "prefers" + "primitives-classnames" "print" "print-ctor" "print-dup" "print-method" "print-simple" + "print-str" "printf" "println" "println-str" "prn" "prn-str" "promise" "proxy-call-with-super" + "proxy-mappings" "proxy-name" "push-thread-bindings" "qualified-ident?" "qualified-keyword?" + "qualified-symbol?" "quot" "rand" "rand-int" "rand-nth" "random-sample" "range" "ratio?" + "rational?" "rationalize" "re-find" "re-groups" "re-matcher" "re-matches" "re-pattern" "re-seq" + "read" "read+string" "read-line" "read-string" "reader-conditional" "reader-conditional?" + "realized?" "record?" "reduce" "reduce-kv" "reduced" "reduced?" "reductions" "ref" + "ref-history-count" "ref-max-history" "ref-min-history" "ref-set" "refer" + "release-pending-sends" "rem" "remove" "remove-all-methods" "remove-method" "remove-ns" + "remove-tap" "remove-watch" "repeat" "repeatedly" "replace" "replicate" "requiring-resolve" + "reset!" "reset-meta!" "reset-vals!" "resolve" "rest" "restart-agent" "resultset-seq" "reverse" + "reversible?" "rseq" "rsubseq" "run!" "satisfies?" "second" "select-keys" "send" "send-off" + "send-via" "seq" "seq?" "seqable?" "seque" "sequence" "sequential?" "set" + "set-agent-send-executor!" "set-agent-send-off-executor!" "set-error-handler!" "set-error-mode!" + "set-validator!" "set?" "short" "short-array" "shorts" "shuffle" "shutdown-agents" + "simple-ident?" "simple-keyword?" "simple-symbol?" "slurp" "some" "some-fn" "some?" "sort" + "sort-by" "sorted-map" "sorted-map-by" "sorted-set" "sorted-set-by" "sorted?" "special-symbol?" + "spit" "split-at" "split-with" "str" "string?" "struct" "struct-map" "subs" "subseq" "subvec" + "supers" "swap!" "swap-vals!" "symbol" "symbol?" "tagged-literal" "tagged-literal?" "take" + "take-last" "take-nth" "take-while" "tap>" "test" "the-ns" "thread-bound?" "to-array" + "to-array-2d" "trampoline" "transduce" "transient" "tree-seq" "true?" "type" "unchecked-add" + "unchecked-add-int" "unchecked-byte" "unchecked-char" "unchecked-dec" "unchecked-dec-int" + "unchecked-divide-int" "unchecked-double" "unchecked-float" "unchecked-inc" "unchecked-inc-int" + "unchecked-int" "unchecked-long" "unchecked-multiply" "unchecked-multiply-int" + "unchecked-negate" "unchecked-negate-int" "unchecked-remainder-int" "unchecked-short" + "unchecked-subtract" "unchecked-subtract-int" "underive" "unquote" "unquote-splicing" + "unreduced" "unsigned-bit-shift-right" "update" "update-in" "update-proxy" "uri?" "uuid?" "val" + "vals" "var-get" "var-set" "var?" "vary-meta" "vec" "vector" "vector-of" "vector?" "volatile!" + "volatile?" "vreset!" "with-bindings*" "with-meta" "with-redefs-fn" "xml-seq" "zero?" "zipmap" + ; earlier + "drop" "drop-last" "drop-while" "double?" "doubles" "ex-data" "ex-info" + ; 1.10 + "ex-cause" "ex-message" + ; 1.11 + "NaN?" "abs" "infinite?" "iteration" "random-uuid" "parse-boolean" "parse-double" "parse-long" + "parse-uuid" "seq-to-map-for-destructuring" "update-keys" "update-vals" + ; 1.12 + "partitionv" "partitionv-all" "splitv-at")) + +; >> Context based highlighting +; def-likes +; Correctly highlight docstrings +;(list_lit +;. +;(sym_lit) @_keyword ; Don't really want to highlight twice +;(#any-of? @_keyword +;"def" "defonce" "defrecord" "defmacro" "definline" +;"defmulti" "defmethod" "defstruct" "defprotocol" +;"deftype") +;. +;(sym_lit) +;. +; TODO: Add @comment highlight +;(str_lit)? +;. +;(_)) +; Function definitions +(list_lit + . + ((sym_lit + name: (sym_name) @_keyword.function.name) + (#any-of? @_keyword.function.name "defn" "defn-" "fn" "fn*")) + . + (sym_lit)? @function + . + ; TODO: Add @comment highlight + (str_lit)?) + +; TODO: Fix parameter highlighting +; I think there's a bug here in nvim-treesitter +; TODO: Reproduce bug and file ticket +;. +;[(vec_lit +; (sym_lit)* @variable.parameter) +; (list_lit +; (vec_lit +; (sym_lit)* @variable.parameter))]) +;[((list_lit +; (vec_lit +; (sym_lit) @variable.parameter) +; (_) +; + +; ((vec_lit +; (sym_lit) @variable.parameter) +; (_))) +; Meta punctuation +; NOTE: When the above `Function definitions` query captures the +; the @function it also captures the child meta_lit +; We capture the meta_lit symbol (^) after so that the later +; highlighting overrides the former +"^" @punctuation.special + +; namespaces +(list_lit + . + (sym_lit) @_include + (#eq? @_include "ns") + . + (sym_lit) @module) diff --git a/runtime/queries/clojure/injections.scm b/runtime/queries/clojure/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/clojure/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/clojure/locals.scm b/runtime/queries/clojure/locals.scm new file mode 100644 index 000000000..e47adce45 --- /dev/null +++ b/runtime/queries/clojure/locals.scm @@ -0,0 +1 @@ +; placeholder file to get incremental selection to work diff --git a/runtime/queries/cmake/folds.scm b/runtime/queries/cmake/folds.scm new file mode 100644 index 000000000..ef153b911 --- /dev/null +++ b/runtime/queries/cmake/folds.scm @@ -0,0 +1,8 @@ +[ + (if_condition) + (foreach_loop) + (while_loop) + (function_def) + (macro_def) + (block_def) +] @fold diff --git a/runtime/queries/cmake/highlights.scm b/runtime/queries/cmake/highlights.scm new file mode 100644 index 000000000..fbbf0d542 --- /dev/null +++ b/runtime/queries/cmake/highlights.scm @@ -0,0 +1,221 @@ +(normal_command + (identifier) + (argument_list + (argument + (unquoted_argument)) @constant) + (#lua-match? @constant "^[%u@][%u%d_]+$")) + +[ + (quoted_argument) + (bracket_argument) +] @string + +(variable_ref) @none + +(variable) @variable + +[ + (bracket_comment) + (line_comment) +] @comment @spell + +(normal_command + (identifier) @function) + +[ + "ENV" + "CACHE" +] @module + +[ + "$" + "{" + "}" +] @punctuation.special + +[ + "(" + ")" +] @punctuation.bracket + +[ + (function) + (endfunction) + (macro) + (endmacro) +] @keyword.function + +[ + (if) + (elseif) + (else) + (endif) +] @keyword.conditional + +[ + (foreach) + (endforeach) + (while) + (endwhile) +] @keyword.repeat + +(normal_command + (identifier) @keyword.repeat + (#match? @keyword.repeat "\\c^(continue|break)$")) + +(normal_command + (identifier) @keyword.return + (#match? @keyword.return "\\c^return$")) + +(function_command + (function) + (argument_list + . + (argument) @function + (argument)* @variable.parameter)) + +(macro_command + (macro) + (argument_list + . + (argument) @function.macro + (argument)* @variable.parameter)) + +(block_def + (block_command + (block) @function.builtin + (argument_list + (argument + (unquoted_argument) @constant)) + (#any-of? @constant "SCOPE_FOR" "POLICIES" "VARIABLES" "PROPAGATE")) + (endblock_command + (endblock) @function.builtin)) + +; +((argument) @boolean + (#match? @boolean "\\c^(1|on|yes|true|y|0|off|no|false|n|ignore|notfound|.*-notfound)$")) + +; +(if_command + (if) + (argument_list + (argument) @keyword.operator) + (#any-of? @keyword.operator + "NOT" "AND" "OR" "COMMAND" "POLICY" "TARGET" "TEST" "DEFINED" "IN_LIST" "EXISTS" "IS_NEWER_THAN" + "IS_DIRECTORY" "IS_SYMLINK" "IS_ABSOLUTE" "MATCHES" "LESS" "GREATER" "EQUAL" "LESS_EQUAL" + "GREATER_EQUAL" "STRLESS" "STRGREATER" "STREQUAL" "STRLESS_EQUAL" "STRGREATER_EQUAL" + "VERSION_LESS" "VERSION_GREATER" "VERSION_EQUAL" "VERSION_LESS_EQUAL" "VERSION_GREATER_EQUAL")) + +(elseif_command + (elseif) + (argument_list + (argument) @keyword.operator) + (#any-of? @keyword.operator + "NOT" "AND" "OR" "COMMAND" "POLICY" "TARGET" "TEST" "DEFINED" "IN_LIST" "EXISTS" "IS_NEWER_THAN" + "IS_DIRECTORY" "IS_SYMLINK" "IS_ABSOLUTE" "MATCHES" "LESS" "GREATER" "EQUAL" "LESS_EQUAL" + "GREATER_EQUAL" "STRLESS" "STRGREATER" "STREQUAL" "STRLESS_EQUAL" "STRGREATER_EQUAL" + "VERSION_LESS" "VERSION_GREATER" "VERSION_EQUAL" "VERSION_LESS_EQUAL" "VERSION_GREATER_EQUAL")) + +(normal_command + (identifier) @function.builtin + (#match? @function.builtin + "\\c^(cmake_host_system_information|cmake_language|cmake_minimum_required|cmake_parse_arguments|cmake_path|cmake_policy|configure_file|execute_process|file|find_file|find_library|find_package|find_path|find_program|foreach|get_cmake_property|get_directory_property|get_filename_component|get_property|include|include_guard|list|macro|mark_as_advanced|math|message|option|separate_arguments|set|set_directory_properties|set_property|site_name|string|unset|variable_watch|add_compile_definitions|add_compile_options|add_custom_command|add_custom_target|add_definitions|add_dependencies|add_executable|add_library|add_link_options|add_subdirectory|add_test|aux_source_directory|build_command|create_test_sourcelist|define_property|enable_language|enable_testing|export|fltk_wrap_ui|get_source_file_property|get_target_property|get_test_property|include_directories|include_external_msproject|include_regular_expression|install|link_directories|link_libraries|load_cache|project|remove_definitions|set_source_files_properties|set_target_properties|set_tests_properties|source_group|target_compile_definitions|target_compile_features|target_compile_options|target_include_directories|target_link_directories|target_link_libraries|target_link_options|target_precompile_headers|target_sources|try_compile|try_run|ctest_build|ctest_configure|ctest_coverage|ctest_empty_binary_directory|ctest_memcheck|ctest_read_custom_files|ctest_run_script|ctest_sleep|ctest_start|ctest_submit|ctest_test|ctest_update|ctest_upload)$")) + +(normal_command + (identifier) @_function + (argument_list + . + (argument) @variable) + (#match? @_function "\\c^set$")) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^set$") + (argument_list + . + (argument) + ((argument) @_cache @keyword.modifier + . + (argument) @_type @type + (#any-of? @_cache "CACHE") + (#any-of? @_type "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL")))) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^unset$") + (argument_list + . + (argument) + (argument) @keyword.modifier + (#any-of? @keyword.modifier "CACHE" "PARENT_SCOPE"))) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + (argument_list + . + (argument) @constant + (#any-of? @constant "LENGTH" "GET" "JOIN" "SUBLIST" "FIND") + . + (argument) @variable + (argument) @variable .)) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + (argument_list + . + (argument) @constant + . + (argument) @variable + (#any-of? @constant + "APPEND" "FILTER" "INSERT" "POP_BACK" "POP_FRONT" "PREPEND" "REMOVE_ITEM" "REMOVE_AT" + "REMOVE_DUPLICATES" "REVERSE" "SORT"))) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + (argument_list + . + (argument) @_transform @constant + . + (argument) @variable + . + (argument) @_action @constant + (#eq? @_transform "TRANSFORM") + (#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE"))) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + (argument_list + . + (argument) @_transform @constant + . + (argument) @variable + . + (argument) @_action @constant + . + (argument)? @_selector @constant + (#eq? @_transform "TRANSFORM") + (#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE") + (#any-of? @_selector "AT" "FOR" "REGEX"))) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + (argument_list + . + (argument) @_transform @constant + (argument) @constant + . + (argument) @variable + (#eq? @_transform "TRANSFORM") + (#eq? @constant "OUTPUT_VARIABLE"))) + +(escape_sequence) @string.escape + +((source_file + . + (line_comment) @keyword.directive @nospell) + (#lua-match? @keyword.directive "^#!/")) diff --git a/runtime/queries/cmake/indents.scm b/runtime/queries/cmake/indents.scm new file mode 100644 index 000000000..cbd976c7a --- /dev/null +++ b/runtime/queries/cmake/indents.scm @@ -0,0 +1,26 @@ +[ + (normal_command) + (if_condition) + (foreach_loop) + (while_loop) + (function_def) + (macro_def) + (block_def) +] @indent.begin + +[ + (elseif_command) + (else_command) + (endif_command) + (endforeach_command) + (endwhile_command) + (endfunction_command) + (endmacro_command) + (endblock_command) +] @indent.branch + +")" @indent.branch + +")" @indent.end + +(argument_list) @indent.auto diff --git a/runtime/queries/cmake/injections.scm b/runtime/queries/cmake/injections.scm new file mode 100644 index 000000000..eb8e21503 --- /dev/null +++ b/runtime/queries/cmake/injections.scm @@ -0,0 +1,5 @@ +([ + (bracket_comment) + (line_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/comment/highlights.scm b/runtime/queries/comment/highlights.scm new file mode 100644 index 000000000..5d18b790a --- /dev/null +++ b/runtime/queries/comment/highlights.scm @@ -0,0 +1,49 @@ +((tag + (name) @comment.todo @nospell + ("(" @punctuation.bracket + (user) @constant + ")" @punctuation.bracket)? + ":" @punctuation.delimiter) + (#any-of? @comment.todo "TODO" "WIP")) + +("text" @comment.todo @nospell + (#any-of? @comment.todo "TODO" "WIP")) + +((tag + (name) @comment.note @nospell + ("(" @punctuation.bracket + (user) @constant + ")" @punctuation.bracket)? + ":" @punctuation.delimiter) + (#any-of? @comment.note "NOTE" "XXX" "INFO" "DOCS" "PERF" "TEST")) + +("text" @comment.note @nospell + (#any-of? @comment.note "NOTE" "XXX" "INFO" "DOCS" "PERF" "TEST")) + +((tag + (name) @comment.warning @nospell + ("(" @punctuation.bracket + (user) @constant + ")" @punctuation.bracket)? + ":" @punctuation.delimiter) + (#any-of? @comment.warning "HACK" "WARNING" "WARN" "FIX")) + +("text" @comment.warning @nospell + (#any-of? @comment.warning "HACK" "WARNING" "WARN" "FIX")) + +((tag + (name) @comment.error @nospell + ("(" @punctuation.bracket + (user) @constant + ")" @punctuation.bracket)? + ":" @punctuation.delimiter) + (#any-of? @comment.error "FIXME" "BUG" "ERROR")) + +("text" @comment.error @nospell + (#any-of? @comment.error "FIXME" "BUG" "ERROR")) + +; Issue number (#123) +("text" @number + (#lua-match? @number "^#[0-9]+$")) + +(uri) @string.special.url @nospell diff --git a/runtime/queries/commonlisp/folds.scm b/runtime/queries/commonlisp/folds.scm new file mode 100644 index 000000000..eceb69712 --- /dev/null +++ b/runtime/queries/commonlisp/folds.scm @@ -0,0 +1,2 @@ +(source + (list_lit) @fold) diff --git a/runtime/queries/commonlisp/highlights.scm b/runtime/queries/commonlisp/highlights.scm new file mode 100644 index 000000000..7236c84de --- /dev/null +++ b/runtime/queries/commonlisp/highlights.scm @@ -0,0 +1,315 @@ +(sym_lit) @variable + +; A highlighting for functions/macros in th cl namespace is available in theHamsta/nvim-treesitter-commonlisp +;(list_lit . (sym_lit) @function.builtin (#cl-standard-function? @function.builtin)) +;(list_lit . (sym_lit) @function.builtin (#cl-standard-macro? @function.macro)) +(dis_expr) @comment + +(defun_keyword) @function.macro + +(defun_header + function_name: (_) @function) + +(defun_header + lambda_list: (list_lit + (sym_lit) @variable.parameter)) + +(defun_header + keyword: (defun_keyword + "defmethod") + lambda_list: (list_lit + (list_lit + . + (sym_lit) + . + (sym_lit) @string.special.symbol))) + +(defun_header + lambda_list: (list_lit + (list_lit + . + (sym_lit) @variable.parameter + . + (_)))) + +(defun_header + specifier: (sym_lit) @string.special.symbol) + +[ + ":" + "::" + "." +] @punctuation.special + +[ + (accumulation_verb) + (for_clause_word) + "for" + "and" + "finally" + "thereis" + "always" + "when" + "if" + "unless" + "else" + "do" + "loop" + "below" + "in" + "from" + "across" + "repeat" + "being" + "into" + "with" + "as" + "while" + "until" + "return" + "initially" +] @function.macro + +"=" @operator + +(include_reader_macro) @string.special.symbol + +[ + "#C" + "#c" +] @number + +[ + (kwd_lit) + (self_referential_reader_macro) +] @string.special.symbol + +(package_lit + package: (_) @module) + +"cl" @module + +(str_lit) @string + +(num_lit) @number + +((sym_lit) @boolean + (#any-of? @boolean "t" "T")) + +(nil_lit) @constant.builtin + +(comment) @comment @spell + +; dynamic variables +((sym_lit) @variable.builtin + (#lua-match? @variable.builtin "^[*].+[*]$")) + +; quote +(format_specifier) @string.escape + +(quoting_lit + "'" @string.escape) + +(syn_quoting_lit + "`" @string.escape) + +(unquoting_lit + "," @string.escape) + +(unquote_splicing_lit + ",@" @string.escape) + +[ + "(" + ")" +] @punctuation.bracket + +(block_comment) @comment @spell + +(with_clause + type: (_) @type) + +(for_clause + type: (_) @type) + +; defun-like things +(list_lit + . + (sym_lit) @function.macro + . + (sym_lit) @function + (#eq? @function.macro "deftest")) + +; Macros and Special Operators +(list_lit + . + (sym_lit) @function.macro + ; Generated via https://github.com/theHamsta/nvim-treesitter-commonlisp/blob/22fdc9fd6ed594176cc7299cc6f68dd21c94c63b/scripts/generate-symbols.lisp#L1-L21 + (#any-of? @function.macro + "do*" "step" "handler-bind" "decf" "prog1" "destructuring-bind" "defconstant" "do" "lambda" + "with-standard-io-syntax" "case" "restart-bind" "ignore-errors" "with-slots" "prog2" "defclass" + "define-condition" "print-unreadable-object" "defvar" "when" "with-open-file" "prog" "incf" + "declaim" "and" "loop-finish" "multiple-value-bind" "pop" "psetf" "defmacro" "with-open-stream" + "define-modify-macro" "defsetf" "formatter" "call-method" "handler-case" "pushnew" "or" + "with-hash-table-iterator" "ecase" "cond" "defun" "remf" "ccase" "define-compiler-macro" + "dotimes" "multiple-value-list" "assert" "deftype" "with-accessors" "trace" + "with-simple-restart" "do-symbols" "nth-value" "define-symbol-macro" "psetq" "rotatef" "dolist" + "check-type" "multiple-value-setq" "push" "pprint-pop" "loop" "define-setf-expander" + "pprint-exit-if-list-exhausted" "with-condition-restarts" "defstruct" "with-input-from-string" + "with-compilation-unit" "defgeneric" "with-output-to-string" "untrace" "defparameter" + "ctypecase" "do-external-symbols" "etypecase" "do-all-symbols" "with-package-iterator" "unless" + "defmethod" "in-package" "defpackage" "return" "typecase" "shiftf" "setf" "pprint-logical-block" + "time" "restart-case" "prog*" "define-method-combination" "optimize")) + +; constant +((sym_lit) @constant + (#lua-match? @constant "^[+].+[+]$")) + +(var_quoting_lit + marker: "#'" @string.special.symbol + value: (_) @string.special.symbol) + +[ + "#" + "#p" + "#P" +] @string.special.symbol + +(list_lit + . + (sym_lit) @function.builtin + ; Generated via https://github.com/theHamsta/nvim-treesitter-commonlisp/blob/22fdc9fd6ed594176cc7299cc6f68dd21c94c63b/scripts/generate-symbols.lisp#L1-L21 + (#any-of? @function.builtin + "apropos-list" "subst" "substitute" "pprint-linear" "file-namestring" "write-char" "do*" + "slot-exists-p" "file-author" "macro-function" "rassoc" "make-echo-stream" + "arithmetic-error-operation" "position-if-not" "list" "cdadr" "lisp-implementation-type" + "vector-push" "let" "length" "string-upcase" "adjoin" "digit-char" "step" "member-if" + "handler-bind" "lognot" "apply" "gcd" "slot-unbound" "stringp" "values-list" "stable-sort" + "decode-float" "make-list" "rplaca" "isqrt" "export" "synonym-stream-symbol" "function-keywords" + "replace" "tanh" "maphash" "code-char" "decf" "array-displacement" "string-not-lessp" + "slot-value" "remove-if" "cell-error-name" "vectorp" "cdddar" "two-way-stream-output-stream" + "parse-integer" "get-internal-real-time" "fourth" "make-string" "slot-missing" "byte-size" + "string-trim" "nstring-downcase" "cdaddr" "<" "labels" "interactive-stream-p" "fifth" "max" + "logxor" "pathname-name" "function" "realp" "eql" "logand" "short-site-name" "prog1" + "user-homedir-pathname" "list-all-packages" "exp" "cadar" "read-char-no-hang" + "package-error-package" "stream-external-format" "bit-andc2" "nsubstitute-if" "mapcar" + "complement" "load-logical-pathname-translations" "pprint-newline" "oddp" "caaar" + "destructuring-bind" "copy-alist" "acos" "go" "bit-nor" "defconstant" "fceiling" "tenth" + "nreverse" "=" "nunion" "slot-boundp" "string>" "count-if" "atom" "char=" "random-state-p" + "row-major-aref" "bit-andc1" "translate-pathname" "simple-vector-p" "coerce" "substitute-if-not" + "zerop" "invalid-method-error" "compile" "realpart" "remove-if-not" "pprint-tab" + "hash-table-rehash-threshold" "invoke-restart" "if" "count" "/=" "do" "initialize-instance" + "abs" "schar" "simple-condition-format-control" "delete-package" "subst-if" "lambda" + "hash-table-count" "array-has-fill-pointer-p" "bit" "with-standard-io-syntax" "parse-namestring" + "proclaim" "array-in-bounds-p" "multiple-value-call" "rplacd" "some" "graphic-char-p" + "read-from-string" "consp" "cadaar" "acons" "every" "make-pathname" "mask-field" "case" + "set-macro-character" "bit-and" "restart-bind" "echo-stream-input-stream" "compile-file" + "fill-pointer" "numberp" "acosh" "array-dimensions" "documentation" "minusp" "inspect" + "copy-structure" "integer-length" "ensure-generic-function" "char>=" "quote" "lognor" + "make-two-way-stream" "ignore-errors" "tailp" "with-slots" "fboundp" + "logical-pathname-translations" "equal" "float-sign" "shadow" "sleep" "numerator" "prog2" "getf" + "ldb-test" "round" "locally" "echo-stream-output-stream" "log" "get-macro-character" + "alphanumericp" "find-method" "nintersection" "defclass" "define-condition" + "print-unreadable-object" "defvar" "broadcast-stream-streams" "floatp" "subst-if-not" "integerp" + "translate-logical-pathname" "subsetp" "when" "write-string" "with-open-file" "clrhash" + "apropos" "intern" "min" "string-greaterp" "import" "nset-difference" "prog" "incf" + "both-case-p" "multiple-value-prog1" "characterp" "streamp" "digit-char-p" "random" + "string-lessp" "make-string-input-stream" "copy-symbol" "read-sequence" "logcount" "bit-not" + "boundp" "encode-universal-time" "third" "declaim" "map" "cons" "set-syntax-from-char" "and" + "cis" "symbol-plist" "loop-finish" "standard-char-p" "multiple-value-bind" "asin" "string" "pop" + "complex" "fdefinition" "psetf" "type-error-datum" "output-stream-p" "floor" "write-line" "<=" + "defmacro" "rational" "hash-table-test" "with-open-stream" "read-char" "string-capitalize" + "get-properties" "y-or-n-p" "use-package" "remove" "compiler-macro-function" "read" + "package-nicknames" "remove-duplicates" "make-load-form-saving-slots" "dribble" + "define-modify-macro" "make-dispatch-macro-character" "close" "cosh" "open" "finish-output" + "string-downcase" "car" "nstring-capitalize" "software-type" "read-preserving-whitespace" "cadr" + "fround" "nsublis" "defsetf" "find-all-symbols" "char>" "no-applicable-method" + "compute-restarts" "pathname" "bit-orc2" "write-sequence" "pprint-tabular" "symbol-value" + "char-name" "get-decoded-time" "formatter" "bit-vector-p" "intersection" "pathname-type" + "clear-input" "call-method" "princ-to-string" "symbolp" "make-load-form" "nsubst" + "pprint-dispatch" "handler-case" "method-combination-error" "probe-file" "atan" "string<" + "type-error-expected-type" "pushnew" "unread-char" "print" "or" "with-hash-table-iterator" + "make-sequence" "ecase" "unwind-protect" "require" "sixth" "get-dispatch-macro-character" + "char-not-lessp" "read-byte" "tagbody" "file-error-pathname" "catch" "rationalp" "char-downcase" + "char-int" "array-rank" "cond" "last" "make-string-output-stream" "array-dimension" + "host-namestring" "input-stream-p" "decode-universal-time" "defun" "eval-when" "char-code" + "pathname-directory" "evenp" "subseq" "pprint" "ftruncate" "make-instance" "pathname-host" + "logbitp" "remf" "1+" "copy-pprint-dispatch" "char-upcase" "error" "read-line" "second" + "make-package" "directory" "special-operator-p" "open-stream-p" "rassoc-if-not" "ccase" "equalp" + "substitute-if" "*" "char/=" "cdr" "sqrt" "lcm" "logical-pathname" "eval" + "define-compiler-macro" "nsubstitute-if-not" "mapcon" "imagpart" "set-exclusive-or" + "simple-condition-format-arguments" "expt" "concatenate" "file-position" "macrolet" "keywordp" + "hash-table-rehash-size" "+" "eighth" "use-value" "char-equal" "bit-xor" "format" "byte" + "dotimes" "namestring" "char-not-equal" "multiple-value-list" "assert" "append" "notany" "typep" + "delete-file" "makunbound" "cdaar" "file-write-date" ">" "cdddr" "write-to-string" "funcall" + "member-if-not" "deftype" "readtable-case" "with-accessors" "truename" "constantp" "rassoc-if" + "caaadr" "tree-equal" "nset-exclusive-or" "nsubstitute" "make-instances-obsolete" + "package-use-list" "invoke-debugger" "provide" "count-if-not" "trace" "logandc1" "nthcdr" + "char<=" "functionp" "with-simple-restart" "set-dispatch-macro-character" "logorc2" "unexport" + "rest" "unbound-slot-instance" "make-hash-table" "hash-table-p" "reinitialize-instance" "nth" + "do-symbols" "nreconc" "macroexpand" "store-value" "float-precision" "remprop" "nth-value" + "define-symbol-macro" "update-instance-for-redefined-class" "identity" "progv" "progn" + "return-from" "readtablep" "rem" "symbol-name" "psetq" "wild-pathname-p" "char" "list*" "char<" + "plusp" "pairlis" "cddar" "pprint-indent" "union" "compiled-function-p" "rotatef" "abort" + "machine-type" "concatenated-stream-streams" "string-right-trim" "enough-namestring" + "arithmetic-error-operands" "ceiling" "dolist" "delete" "make-condition" "string-left-trim" + "integer-decode-float" "check-type" "notevery" "function-lambda-expression" "-" + "multiple-value-setq" "name-char" "push" "pprint-pop" "compile-file-pathname" "list-length" + "nstring-upcase" "eq" "find-if" "method-qualifiers" "caadr" "cddr" "string=" "let*" + "remove-method" "pathname-match-p" "find-package" "truncate" "caaddr" "get-setf-expansion" + "loop" "define-setf-expander" "caddr" "package-shadowing-symbols" "force-output" + "slot-makunbound" "string-not-greaterp" "cdadar" "cdaadr" "logandc2" "make-array" + "merge-pathnames" "sin" "1-" "machine-version" "ffloor" "packagep" "set-pprint-dispatch" "flet" + "gensym" "pprint-exit-if-list-exhausted" "cos" "get" "mapl" "delete-if" + "with-condition-restarts" "atanh" "copy-list" "fill" "char-not-greaterp" "bit-orc1" "mod" + "package-used-by-list" "warn" "add-method" "simple-string-p" "find-restart" "describe" + "pathname-version" "peek-char" "yes-or-no-p" "complexp" "aref" "not" "position-if" "string>=" + "defstruct" "float-radix" "ninth" "caadar" "subtypep" "set" "butlast" "allocate-instance" + "with-input-from-string" "assoc" "write" "make-random-state" "bit-eqv" "float-digits" + "long-site-name" "with-compilation-unit" "delete-duplicates" "make-symbol" "room" "cdar" + "pprint-fill" "defgeneric" "macroexpand-1" "scale-float" "cdaaar" + "update-instance-for-different-class" "array-row-major-index" "ed" "file-string-length" + "ensure-directories-exist" "copy-readtable" "string<=" "seventh" "with-output-to-string" + "signum" "elt" "untrace" "null" "defparameter" "block" "prin1" "revappend" "gentemp" "ctypecase" + "ash" "sxhash" "listp" "do-external-symbols" "bit-ior" "etypecase" "sort" "change-class" + "find-class" "alpha-char-p" "map-into" "terpri" "do-all-symbols" "ldb" "logorc1" "search" + "fmakunbound" "load" "character" "string-not-equal" "pathnamep" "make-broadcast-stream" "arrayp" + "mapcan" "cerror" "invoke-restart-interactively" "assoc-if-not" "with-package-iterator" + "get-internal-run-time" "read-delimited-list" "unless" "lower-case-p" "restart-name" "/" "boole" + "defmethod" "float" "software-version" "vector-pop" "vector-push-extend" "caar" "ldiff" "member" + "find-symbol" "reduce" "svref" "describe-object" "logior" "string-equal" "type-of" "position" + "cddadr" "pathname-device" "get-output-stream-string" "symbol-package" "tan" + "compute-applicable-methods" "cddddr" "nsubst-if-not" "sublis" "set-difference" + "two-way-stream-input-stream" "adjustable-array-p" "machine-instance" "signal" "conjugate" + "caaaar" "endp" "lisp-implementation-version" "cddaar" "package-name" "adjust-array" "bit-nand" + "gethash" "in-package" "symbol-function" "make-concatenated-stream" "defpackage" "class-of" + "no-next-method" "logeqv" "deposit-field" "disassemble" "unuse-package" "copy-tree" "find" + "asinh" "class-name" "rename-file" "values" "print-not-readable-object" "mismatch" "cadadr" + "shadowing-import" "delete-if-not" "maplist" "listen" "return" "stream-element-type" "unintern" + "merge" "make-synonym-stream" "prin1-to-string" "nsubst-if" "byte-position" "phase" + "muffle-warning" "remhash" "continue" "load-time-value" "hash-table-size" + "upgraded-complex-part-type" "char-lessp" "sbit" "upgraded-array-element-type" "file-length" + "typecase" "cadddr" "first" "rationalize" "logtest" "find-if-not" "dpb" "mapc" "sinh" + "char-greaterp" "shiftf" "denominator" "get-universal-time" "nconc" "setf" "lognand" + "rename-package" "pprint-logical-block" "break" "symbol-macrolet" "the" "fresh-line" + "clear-output" "assoc-if" "string/=" "princ" "directory-namestring" "stream-error-stream" + "array-element-type" "setq" "copy-seq" "time" "restart-case" "prog*" "shared-initialize" + "array-total-size" "simple-bit-vector-p" "define-method-combination" "write-byte" "constantly" + "caddar" "print-object" "vector" "throw" "reverse" ">=" "upper-case-p" "nbutlast") + ) + +(list_lit + . + (sym_lit) @operator + (#match? @operator "^([+*-+=<>]|<=|>=|/=)$")) + +((sym_lit) @string.special.symbol + (#lua-match? @string.special.symbol "^[&]")) + +[ + (array_dimension) + "#0A" + "#0a" +] @number + +(char_lit) @character diff --git a/runtime/queries/commonlisp/injections.scm b/runtime/queries/commonlisp/injections.scm new file mode 100644 index 000000000..dc8982053 --- /dev/null +++ b/runtime/queries/commonlisp/injections.scm @@ -0,0 +1,5 @@ +([ + (comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/commonlisp/locals.scm b/runtime/queries/commonlisp/locals.scm new file mode 100644 index 000000000..98036d322 --- /dev/null +++ b/runtime/queries/commonlisp/locals.scm @@ -0,0 +1,109 @@ +(defun_header + function_name: (sym_lit) @local.definition.function + (#set! definition.function.scope "parent")) + +(defun_header + lambda_list: (list_lit + (sym_lit) @local.definition.parameter)) + +(defun_header + keyword: (defun_keyword + "defmethod") + lambda_list: (list_lit + (list_lit + . + (sym_lit) + . + (sym_lit) @local.definition.type))) + +(defun_header + lambda_list: (list_lit + (list_lit + . + (sym_lit) @local.definition.parameter + . + (_)))) + +(sym_lit) @local.reference + +(defun) @local.scope + +((list_lit + . + (sym_lit) @_defvar + . + (sym_lit) @local.definition.var) + (#match? @_defvar "^(cl:)?(defvar|defparameter)$")) + +(list_lit + . + (sym_lit) @_deftest + . + (sym_lit) @local.definition.function + (#eq? @_deftest "deftest")) @local.scope + +(list_lit + . + (sym_lit) @_deftest + . + (sym_lit) @local.definition.function + (#eq? @_deftest "deftest")) @local.scope + +(for_clause + . + (sym_lit) @local.definition.var) + +(with_clause + . + (sym_lit) @local.definition.var) + +(loop_macro) @local.scope + +(list_lit + . + (sym_lit) @_let + (#match? @_let "(cl:|cffi:)?(with-accessors|with-foreign-objects|let[*]?)") + . + (list_lit + (list_lit + . + (sym_lit) @local.definition.var))) @local.scope + +(list_lit + . + (sym_lit) @_let + (#match? @_let "(cl:|alexandria:)?(with-gensyms|dotimes|with-foreign-object)") + . + (list_lit + . + (sym_lit) @local.definition.var)) @local.scope + +(list_lit + . + (kwd_lit) @_import_from + (#eq? @_import_from ":import-from") + . + (_) + (kwd_lit + (kwd_symbol) @local.definition.import)) + +(list_lit + . + (kwd_lit) @_import_from + (#eq? @_import_from ":import-from") + . + (_) + (sym_lit) @local.definition.import) + +(list_lit + . + (kwd_lit) @_use + (#eq? @_use ":use") + (kwd_lit + (kwd_symbol) @local.definition.import)) + +(list_lit + . + (kwd_lit) @_use + (#eq? @_use ":use") + (sym_lit) @local.definition.import) diff --git a/runtime/queries/cooklang/highlights.scm b/runtime/queries/cooklang/highlights.scm new file mode 100644 index 000000000..4ac391899 --- /dev/null +++ b/runtime/queries/cooklang/highlights.scm @@ -0,0 +1,31 @@ +(metadata) @comment + +(comment) @comment @spell + +[ + "{" + "}" +] @punctuation.bracket + +"%" @punctuation.special + +(ingredient + "@" @punctuation.delimiter + (name)? @string.special.symbol + (amount + (quantity)? @number + (units)? @constant)?) + +(timer + "~" @punctuation.delimiter + (name)? @string.special.symbol + (amount + (quantity)? @number + (units)? @constant)?) + +(cookware + "#" @punctuation.delimiter + (name)? @string.special.symbol + (amount + (quantity)? @number + (units)? @constant)?) diff --git a/runtime/queries/cooklang/injections.scm b/runtime/queries/cooklang/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/cooklang/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/corn/folds.scm b/runtime/queries/corn/folds.scm new file mode 100644 index 000000000..2ce5ddb31 --- /dev/null +++ b/runtime/queries/corn/folds.scm @@ -0,0 +1,5 @@ +[ + (object) + (array) + (assign_block) +] @fold diff --git a/runtime/queries/corn/highlights.scm b/runtime/queries/corn/highlights.scm new file mode 100644 index 000000000..8f394ed79 --- /dev/null +++ b/runtime/queries/corn/highlights.scm @@ -0,0 +1,37 @@ +[ + "let" + "in" +] @keyword + +[ + "{" + "}" + "[" + "]" +] @punctuation.bracket + +"." @punctuation.delimiter + +[ + ".." + "=" +] @operator + +(input) @constant + +(null) @constant.builtin + +(comment) @comment @spell + +(string) @string + +(integer) @number + +(float) @number.float + +(float + "." @number.float) + +(boolean) @boolean + +(path_seg) @property diff --git a/runtime/queries/corn/indents.scm b/runtime/queries/corn/indents.scm new file mode 100644 index 000000000..f1f5e04da --- /dev/null +++ b/runtime/queries/corn/indents.scm @@ -0,0 +1,24 @@ +[ + (assign_block + "{") + (object) + (array) +] @indent.begin + +(assign_block + "}" @indent.branch) + +(assign_block + "}" @indent.end) + +(object + "}" @indent.branch) + +(object + "}" @indent.end) + +(array + "]" @indent.branch) + +(array + "]" @indent.end) diff --git a/runtime/queries/corn/injections.scm b/runtime/queries/corn/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/corn/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/corn/locals.scm b/runtime/queries/corn/locals.scm new file mode 100644 index 000000000..7e78c4d23 --- /dev/null +++ b/runtime/queries/corn/locals.scm @@ -0,0 +1,13 @@ +; scopes +[ + (object) + (array) +] @local.scope + +; definitions +(assign_block + (assignment + (input) @local.definition.constant)) + +(value + (input) @local.reference) diff --git a/runtime/queries/cpon/folds.scm b/runtime/queries/cpon/folds.scm new file mode 100644 index 000000000..02feec4e1 --- /dev/null +++ b/runtime/queries/cpon/folds.scm @@ -0,0 +1,5 @@ +[ + (meta_map) + (map) + (array) +] @fold diff --git a/runtime/queries/cpon/highlights.scm b/runtime/queries/cpon/highlights.scm new file mode 100644 index 000000000..9cc438ea5 --- /dev/null +++ b/runtime/queries/cpon/highlights.scm @@ -0,0 +1,54 @@ +; Literals +(string) @string + +(escape_sequence) @string.escape + +(hex_blob + "x" @character.special + (_) @string) + +(esc_blob + "b" @character.special + (_) @string) + +(datetime + "d" @character.special + (_) @string.special) + +(_ + key: (_) @property) + +(number) @number + +(float) @number.float + +(boolean) @boolean + +(null) @constant.builtin + +; Punctuation +[ + "," + ":" +] @punctuation.delimiter + +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "<" + ">" +] @punctuation.bracket + +("\"" @string + (#set! conceal "")) + +; Comments +(comment) @comment @spell diff --git a/runtime/queries/cpon/indents.scm b/runtime/queries/cpon/indents.scm new file mode 100644 index 000000000..8ec2ff57c --- /dev/null +++ b/runtime/queries/cpon/indents.scm @@ -0,0 +1,17 @@ +[ + (meta_map) + (map) + (imap) + (array) +] @indent.begin + +[ + "]" + "}" + ">" +] @indent.end @indent.branch + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/runtime/queries/cpon/injections.scm b/runtime/queries/cpon/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/cpon/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/cpon/locals.scm b/runtime/queries/cpon/locals.scm new file mode 100644 index 000000000..2a4ba4712 --- /dev/null +++ b/runtime/queries/cpon/locals.scm @@ -0,0 +1,6 @@ +[ + (document) + (meta_map) + (map) + (array) +] @local.scope diff --git a/runtime/queries/cpp/folds.scm b/runtime/queries/cpp/folds.scm new file mode 100644 index 000000000..f5f566480 --- /dev/null +++ b/runtime/queries/cpp/folds.scm @@ -0,0 +1,14 @@ +; inherits: c + +[ + (for_range_loop) + (class_specifier) + (field_declaration + type: (enum_specifier) + default_value: (initializer_list)) + (template_declaration) + (namespace_definition) + (try_statement) + (catch_clause) + (lambda_expression) +] @fold diff --git a/runtime/queries/cpp/highlights.scm b/runtime/queries/cpp/highlights.scm new file mode 100644 index 000000000..85ff2dc40 --- /dev/null +++ b/runtime/queries/cpp/highlights.scm @@ -0,0 +1,268 @@ +; inherits: c + +((identifier) @variable.member + (#lua-match? @variable.member "^m_.*$")) + +(parameter_declaration + declarator: (reference_declarator) @variable.parameter) + +; function(Foo ...foo) +(variadic_parameter_declaration + declarator: (variadic_declarator + (_) @variable.parameter)) + +; int foo = 0 +(optional_parameter_declaration + declarator: (_) @variable.parameter) + +;(field_expression) @variable.parameter ;; How to highlight this? +((field_expression + (field_identifier) @function.method) @_parent + (#has-parent? @_parent template_method function_declarator)) + +(field_declaration + (field_identifier) @variable.member) + +(field_initializer + (field_identifier) @property) + +(function_declarator + declarator: (field_identifier) @function.method) + +(concept_definition + name: (identifier) @type.definition) + +(alias_declaration + name: (type_identifier) @type.definition) + +(auto) @type.builtin + +(namespace_identifier) @module + +((namespace_identifier) @type + (#lua-match? @type "^[%u]")) + +(case_statement + value: (qualified_identifier + (identifier) @constant)) + +(using_declaration + . + "using" + . + "namespace" + . + [ + (qualified_identifier) + (identifier) + ] @module) + +(destructor_name + (identifier) @function.method) + +; functions +(function_declarator + (qualified_identifier + (identifier) @function)) + +(function_declarator + (qualified_identifier + (qualified_identifier + (identifier) @function))) + +(function_declarator + (qualified_identifier + (qualified_identifier + (qualified_identifier + (identifier) @function)))) + +((qualified_identifier + (qualified_identifier + (qualified_identifier + (qualified_identifier + (identifier) @function)))) @_parent + (#has-ancestor? @_parent function_declarator)) + +(function_declarator + (template_function + (identifier) @function)) + +(operator_name) @function + +"operator" @function + +"static_assert" @function.builtin + +(call_expression + (qualified_identifier + (identifier) @function.call)) + +(call_expression + (qualified_identifier + (qualified_identifier + (identifier) @function.call))) + +(call_expression + (qualified_identifier + (qualified_identifier + (qualified_identifier + (identifier) @function.call)))) + +((qualified_identifier + (qualified_identifier + (qualified_identifier + (qualified_identifier + (identifier) @function.call)))) @_parent + (#has-ancestor? @_parent call_expression)) + +(call_expression + (template_function + (identifier) @function.call)) + +(call_expression + (qualified_identifier + (template_function + (identifier) @function.call))) + +(call_expression + (qualified_identifier + (qualified_identifier + (template_function + (identifier) @function.call)))) + +(call_expression + (qualified_identifier + (qualified_identifier + (qualified_identifier + (template_function + (identifier) @function.call))))) + +((qualified_identifier + (qualified_identifier + (qualified_identifier + (qualified_identifier + (template_function + (identifier) @function.call))))) @_parent + (#has-ancestor? @_parent call_expression)) + +; methods +(function_declarator + (template_method + (field_identifier) @function.method)) + +(call_expression + (field_expression + (field_identifier) @function.method.call)) + +; constructors +((function_declarator + (qualified_identifier + (identifier) @constructor)) + (#lua-match? @constructor "^%u")) + +((call_expression + function: (identifier) @constructor) + (#lua-match? @constructor "^%u")) + +((call_expression + function: (qualified_identifier + name: (identifier) @constructor)) + (#lua-match? @constructor "^%u")) + +((call_expression + function: (field_expression + field: (field_identifier) @constructor)) + (#lua-match? @constructor "^%u")) + +; constructing a type in an initializer list: Constructor (): **SuperType (1)** +((field_initializer + (field_identifier) @constructor + (argument_list)) + (#lua-match? @constructor "^%u")) + +; Constants +(this) @variable.builtin + +(null + "nullptr" @constant.builtin) + +(true) @boolean + +(false) @boolean + +; Literals +(raw_string_literal) @string + +; Keywords +[ + "try" + "catch" + "noexcept" + "throw" +] @keyword.exception + +[ + "decltype" + "explicit" + "friend" + "override" + "using" + "requires" + "constexpr" +] @keyword + +[ + "class" + "namespace" + "template" + "typename" + "concept" +] @keyword.type + +[ + "co_await" + "co_yield" + "co_return" +] @keyword.coroutine + +[ + "public" + "private" + "protected" + "final" + "virtual" +] @keyword.modifier + +[ + "new" + "delete" + "xor" + "bitand" + "bitor" + "compl" + "not" + "xor_eq" + "and_eq" + "or_eq" + "not_eq" + "and" + "or" +] @keyword.operator + +"<=>" @operator + +"::" @punctuation.delimiter + +(template_argument_list + [ + "<" + ">" + ] @punctuation.bracket) + +(template_parameter_list + [ + "<" + ">" + ] @punctuation.bracket) + +(literal_suffix) @operator diff --git a/runtime/queries/cpp/indents.scm b/runtime/queries/cpp/indents.scm new file mode 100644 index 000000000..0782d226e --- /dev/null +++ b/runtime/queries/cpp/indents.scm @@ -0,0 +1,8 @@ +; inherits: c + +(condition_clause) @indent.begin + +((field_initializer_list) @indent.begin + (#set! indent.start_at_same_line 1)) + +(access_specifier) @indent.branch diff --git a/runtime/queries/cpp/injections.scm b/runtime/queries/cpp/injections.scm new file mode 100644 index 000000000..1fbc8e131 --- /dev/null +++ b/runtime/queries/cpp/injections.scm @@ -0,0 +1,9 @@ +; inherits: c + +((comment) @injection.content + (#lua-match? @injection.content "/[*\/][!*\/]<?[^a-zA-Z]") + (#set! injection.language "doxygen")) + +(raw_string_literal + delimiter: (raw_string_delimiter) @injection.language + (raw_string_content) @injection.content) diff --git a/runtime/queries/cpp/locals.scm b/runtime/queries/cpp/locals.scm new file mode 100644 index 000000000..b24ada85f --- /dev/null +++ b/runtime/queries/cpp/locals.scm @@ -0,0 +1,78 @@ +; inherits: c + +; Parameters +(variadic_parameter_declaration + declarator: (variadic_declarator + (identifier) @local.definition.parameter)) + +(optional_parameter_declaration + declarator: (identifier) @local.definition.parameter) + +; Class / struct definitions +(class_specifier) @local.scope + +(reference_declarator + (identifier) @local.definition.var) + +(variadic_declarator + (identifier) @local.definition.var) + +(struct_specifier + name: (qualified_identifier + name: (type_identifier) @local.definition.type)) + +(class_specifier + name: (type_identifier) @local.definition.type) + +(concept_definition + name: (identifier) @local.definition.type) + +(class_specifier + name: (qualified_identifier + name: (type_identifier) @local.definition.type)) + +(alias_declaration + name: (type_identifier) @local.definition.type) + +;template <typename T> +(type_parameter_declaration + (type_identifier) @local.definition.type) + +(template_declaration) @local.scope + +; Namespaces +(namespace_definition + name: (namespace_identifier) @local.definition.namespace + body: (_) @local.scope) + +(namespace_definition + name: (nested_namespace_specifier) @local.definition.namespace + body: (_) @local.scope) + +((namespace_identifier) @local.reference + (#set! reference.kind "namespace")) + +; Function definitions +(template_function + name: (identifier) @local.definition.function) @local.scope + +(template_method + name: (field_identifier) @local.definition.method) @local.scope + +(function_declarator + declarator: (qualified_identifier + name: (identifier) @local.definition.function)) @local.scope + +(field_declaration + declarator: (function_declarator + (field_identifier) @local.definition.method)) + +(lambda_expression) @local.scope + +; Control structures +(try_statement + body: (_) @local.scope) + +(catch_clause) @local.scope + +(requires_expression) @local.scope diff --git a/runtime/queries/css/folds.scm b/runtime/queries/css/folds.scm new file mode 100644 index 000000000..60d69a917 --- /dev/null +++ b/runtime/queries/css/folds.scm @@ -0,0 +1,10 @@ +[ + ; top-level block statements from https://github.com/tree-sitter/tree-sitter-css/blob/master/grammar.js + ; note: (block) is not used due to unideal behavior when node before block node spans multiple lines + (rule_set) + (at_rule) + (supports_statement) + (media_statement) + (keyframe_block) + (import_statement)+ +] @fold diff --git a/runtime/queries/css/highlights.scm b/runtime/queries/css/highlights.scm new file mode 100644 index 000000000..49471fdb2 --- /dev/null +++ b/runtime/queries/css/highlights.scm @@ -0,0 +1,109 @@ +[ + "@media" + "@charset" + "@namespace" + "@supports" + "@keyframes" + (at_keyword) +] @keyword.directive + +"@import" @keyword.import + +[ + (to) + (from) +] @keyword + +(comment) @comment @spell + +(tag_name) @tag + +(class_name) @type + +(id_name) @constant + +[ + (property_name) + (feature_name) +] @property + +[ + (nesting_selector) + (universal_selector) +] @character.special + +(function_name) @function + +[ + "~" + ">" + "+" + "-" + "*" + "/" + "=" + "^=" + "|=" + "~=" + "$=" + "*=" +] @operator + +[ + "and" + "or" + "not" + "only" +] @keyword.operator + +(important) @keyword.modifier + +(attribute_selector + (plain_value) @string) + +(pseudo_element_selector + "::" + (tag_name) @attribute) + +(pseudo_class_selector + (class_name) @attribute) + +(attribute_name) @tag.attribute + +(namespace_name) @module + +(keyframes_name) @variable + +((property_name) @variable + (#lua-match? @variable "^[-][-]")) + +((plain_value) @variable + (#lua-match? @variable "^[-][-]")) + +[ + (string_value) + (color_value) + (unit) +] @string + +(integer_value) @number + +(float_value) @number.float + +[ + "#" + "," + "." + ":" + "::" + ";" +] @punctuation.delimiter + +[ + "{" + ")" + "(" + "}" + "[" + "]" +] @punctuation.bracket diff --git a/runtime/queries/css/indents.scm b/runtime/queries/css/indents.scm new file mode 100644 index 000000000..75e4a63a9 --- /dev/null +++ b/runtime/queries/css/indents.scm @@ -0,0 +1,11 @@ +[ + (block) + (declaration) +] @indent.begin + +(block + "}" @indent.branch) + +"}" @indent.dedent + +(comment) @indent.ignore diff --git a/runtime/queries/css/injections.scm b/runtime/queries/css/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/css/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/csv/highlights.scm b/runtime/queries/csv/highlights.scm new file mode 100644 index 000000000..de2213aa1 --- /dev/null +++ b/runtime/queries/csv/highlights.scm @@ -0,0 +1,3 @@ +; inherits: tsv + +"," @punctuation.delimiter diff --git a/runtime/queries/cuda/folds.scm b/runtime/queries/cuda/folds.scm new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/runtime/queries/cuda/folds.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/runtime/queries/cuda/highlights.scm b/runtime/queries/cuda/highlights.scm new file mode 100644 index 000000000..6605c5a72 --- /dev/null +++ b/runtime/queries/cuda/highlights.scm @@ -0,0 +1,17 @@ +; inherits: cpp + +[ + "<<<" + ">>>" +] @punctuation.bracket + +[ + "__host__" + "__device__" + "__global__" + "__managed__" + "__forceinline__" + "__noinline__" +] @keyword.modifier + +"__launch_bounds__" @keyword.modifier diff --git a/runtime/queries/cuda/indents.scm b/runtime/queries/cuda/indents.scm new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/runtime/queries/cuda/indents.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/runtime/queries/cuda/injections.scm b/runtime/queries/cuda/injections.scm new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/runtime/queries/cuda/injections.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/runtime/queries/cuda/locals.scm b/runtime/queries/cuda/locals.scm new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/runtime/queries/cuda/locals.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/runtime/queries/cue/folds.scm b/runtime/queries/cue/folds.scm new file mode 100644 index 000000000..934b59e6f --- /dev/null +++ b/runtime/queries/cue/folds.scm @@ -0,0 +1,5 @@ +[ + (import_spec_list) + (field) + (string) +] @fold diff --git a/runtime/queries/cue/highlights.scm b/runtime/queries/cue/highlights.scm new file mode 100644 index 000000000..27d4daddc --- /dev/null +++ b/runtime/queries/cue/highlights.scm @@ -0,0 +1,164 @@ +; Includes +[ + "package" + "import" +] @keyword.import + +; Namespaces +(package_identifier) @module + +(import_spec + [ + "." + "_" + ] @punctuation.special) + +[ + (attr_path) + (package_path) +] @string.special.url ; In attributes + +; Attributes +(attribute) @attribute + +; Conditionals +"if" @keyword.conditional + +; Repeats +"for" @keyword.repeat + +(for_clause + "_" @punctuation.special) + +; Keywords +"let" @keyword + +"in" @keyword.operator + +; Operators +[ + "+" + "-" + "*" + "/" + "|" + "&" + "||" + "&&" + "==" + "!=" + "<" + "<=" + ">" + ">=" + "=~" + "!~" + "!" + "=" +] @operator + +; Fields & Properties +(field + (label + (identifier) @variable.member)) + +(selector_expression + (_) + (identifier) @property) + +; Functions +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (selector_expression + (_) + (identifier) @function.call)) + +(call_expression + function: (builtin_function) @function.call) + +(builtin_function) @function.builtin + +; Variables +(identifier) @variable + +; Types +(primitive_type) @type.builtin + +((identifier) @type + (#lua-match? @type "^_?#")) + +[ + (slice_type) + (pointer_type) +] @type ; In attributes + +; Punctuation +[ + "," + ":" +] @punctuation.delimiter + +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "<" + ">" +] @punctuation.bracket + +[ + (ellipsis) + "?" +] @punctuation.special + +; Literals +(string) @string + +[ + (escape_char) + (escape_unicode) +] @string.escape + +(number) @number + +(float) @number.float + +(si_unit + (float) + (_) @string.special.symbol) + +(boolean) @boolean + +[ + (null) + (top) + (bottom) +] @constant.builtin + +; Interpolations +(interpolation + "\\(" @punctuation.special + (_) + ")" @punctuation.special) @none + +(interpolation + "\\(" + (identifier) @variable + ")") + +; Comments +(comment) @comment @spell diff --git a/runtime/queries/cue/indents.scm b/runtime/queries/cue/indents.scm new file mode 100644 index 000000000..cef2345cc --- /dev/null +++ b/runtime/queries/cue/indents.scm @@ -0,0 +1,30 @@ +[ + (import_spec_list) + (field) +] @indent.begin + +[ + "}" + "]" + ")" +] @indent.end + +[ + "{" + "}" +] @indent.branch + +[ + "[" + "]" +] @indent.branch + +[ + "(" + ")" +] @indent.branch + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/runtime/queries/cue/injections.scm b/runtime/queries/cue/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/cue/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/cue/locals.scm b/runtime/queries/cue/locals.scm new file mode 100644 index 000000000..b2a8972f7 --- /dev/null +++ b/runtime/queries/cue/locals.scm @@ -0,0 +1,31 @@ +; Scopes +[ + (source_file) + (field) + (for_clause) +] @local.scope + +; References +(identifier) @local.reference + +; Definitions +(import_spec + path: (string) @local.definition.import) + +(field + (label + (identifier) @local.definition.field)) + +(package_identifier) @local.definition.namespace + +(for_clause + (identifier) @local.definition.var + (expression)) + +(for_clause + (identifier) + (identifier) @local.definition.var + (expression)) + +(let_clause + (identifier) @local.definition.var) diff --git a/runtime/queries/cylc/folds.scm b/runtime/queries/cylc/folds.scm new file mode 100644 index 000000000..c8bd40703 --- /dev/null +++ b/runtime/queries/cylc/folds.scm @@ -0,0 +1,10 @@ +[ + (multiline_string) + (multiline_graph_string) + (top_section) + (sub_section_1) + (sub_section_2) + (runtime_section) + (task_section) + (graph_section) +] @fold diff --git a/runtime/queries/cylc/highlights.scm b/runtime/queries/cylc/highlights.scm new file mode 100644 index 000000000..a744caa52 --- /dev/null +++ b/runtime/queries/cylc/highlights.scm @@ -0,0 +1,72 @@ +(comment) @comment @spell + +(key) @property + +(boolean) @boolean + +(datetime) @string.special + +(task_name) @function + +(include_directive) @keyword.import + +[ + (section_name) + (namespace) +] @markup.heading + +[ + (integer) + (recurrence) +] @number + +[ + "[" + "]" + "[[" + "]]" + "[[[" + "]]]" + "<" + ">" + (graph_parenthesis) +] @punctuation.bracket + +[ + "\"" + "\"\"\"" + (unquoted_string) + (quoted_string) + (multiline_string) +] @string + +[ + (xtrigger_annotation) + (suicide_annotation) +] @attribute + +[ + "=" + (assignment_operator) + (graph_logical) + (graph_arrow) +] @operator + +(include_statement + path: (_)? @string.special.path) + +(task_parameter + name: (_)? @variable.parameter + selection: (_)? @variable.parameter) + +(task_output + ":" @tag + (nametag) @variable.builtin + "?"? @tag) + +[ + (jinja2_expression) + (jinja2_statement) + (jinja2_comment) + (jinja2_shebang) +] @keyword.directive diff --git a/runtime/queries/cylc/indents.scm b/runtime/queries/cylc/indents.scm new file mode 100644 index 000000000..0457e4580 --- /dev/null +++ b/runtime/queries/cylc/indents.scm @@ -0,0 +1,16 @@ +[ + (top_section) + (sub_section_1) + (sub_section_2) + (graph_section) + (runtime_section) + (task_section) +] @indent.begin + +(multiline_string + quotes_close: _ @indent.end) @indent.begin + +(multiline_graph_string + quotes_close: _ @indent.end) @indent.begin + +(line_continuation) @indent.zero diff --git a/runtime/queries/cylc/injections.scm b/runtime/queries/cylc/injections.scm new file mode 100644 index 000000000..41becd699 --- /dev/null +++ b/runtime/queries/cylc/injections.scm @@ -0,0 +1,11 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; https://cylc.github.io/cylc-doc/latest/html/user-guide/task-implementation/job-scripts.html#jobscripts +((setting + key: (key) @_key + (#any-of? @_key + "script" "init-script" "env-script" "pre-script" "post-script" "err-script" "exit-script") + value: (_ + (string_content) @injection.content)) + (#set! injection.language "bash")) diff --git a/runtime/queries/d/folds.scm b/runtime/queries/d/folds.scm new file mode 100644 index 000000000..49d6256f6 --- /dev/null +++ b/runtime/queries/d/folds.scm @@ -0,0 +1,4 @@ +[ + (block_statement) + (aggregate_body) +] @fold diff --git a/runtime/queries/d/highlights.scm b/runtime/queries/d/highlights.scm new file mode 100644 index 000000000..11d08a1b7 --- /dev/null +++ b/runtime/queries/d/highlights.scm @@ -0,0 +1,374 @@ +; Keywords +[ + (directive) + (shebang) +] @keyword.directive + +[ + (import) + (module) +] @keyword.import + +[ + (alias) + (asm) + (class) + (delegate) + (delete) + (enum) + (interface) + (invariant) + (mixin) + (pragma) + (struct) + (template) + (union) + (unittest) + (version) + (with) + (traits) + (vector) + (parameters_) + (default) + (goto) +] @keyword + +(function) @keyword.function + +(synchronized) @keyword.coroutine + +[ + (if) + (else) + (switch) + (case) + (break) +] @keyword.conditional + +[ + (do) + (for) + (foreach) + (foreach_reverse) + (while) + (continue) +] @keyword.repeat + +(return) @keyword.return + +[ + (abstract) + (deprecated) + (private) + (protected) + (public) + (package) + (immutable) + (final) + (const) + (override) + (static) +] @keyword.modifier + +[ + (assert) + (try) + (catch) + (finally) + (throw) + (nothrow) +] @keyword.exception + +[ + (cast) + (new) + (in) + (is) + (not_in) + (not_is) + (typeid) + (typeof) +] @keyword.operator + +[ + (lazy) + (align) + (extern) + (scope) + (ref) + (pure) + (export) + (shared) + (gshared) + (out) + (inout) +] @keyword.modifier + +(parameter_attribute + (return) @keyword.modifier) + +(parameter_attribute + (in) @keyword.modifier) + +(parameter_attribute + (out) @keyword.modifier) + +(debug) @keyword.debug + +; Operators +[ + "/=" + "/" + ".." + "&" + "&=" + "&&" + "|" + "|=" + "||" + "-" + "-=" + "--" + "+" + "+=" + "++" + "<" + "<=" + "<<" + "<<=" + ">" + ">=" + ">>=" + ">>>=" + ">>" + ">>>" + "!" + "!=" + "$" + "=" + "==" + "*" + "*=" + "%" + "%=" + "^" + "^=" + "^^" + "^^=" + "~" + "~=" + "@" +] @operator + +; Variables +(identifier) @variable + +[ + "exit" + "success" + "failure" + (this) + (super) +] @variable.builtin + +(linkage_attribute + "(" + _ @variable.builtin + ")") + +; Modules +(module_fqn + (identifier) @module) + +; Attributes +(at_attribute + (identifier) @attribute) + +; Constants +(enum_member + (identifier) @constant) + +(manifest_declarator + . + (identifier) @constant) + +; Members +(aggregate_body + (variable_declaration + (declarator + (identifier) @variable.member))) + +(property_expression + "." + (identifier) @variable.member) + +(type + "." + (identifier) @variable.member) + +; Types +(class_declaration + (class) + . + (identifier) @type) + +(struct_declaration + (struct) + . + (identifier) @type) + +(union_declaration + (union) + . + (identifier) @type) + +(enum_declaration + (enum) + . + (identifier) @type) + +(alias_declaration + (alias) + . + (identifier) @type) + +((identifier) @type + (#lua-match? @type "^[A-Z].*")) + +(type + . + (identifier) @type .) + +[ + (auto) + (void) + (bool) + (byte) + (ubyte) + (char) + (short) + (ushort) + (wchar) + (dchar) + (int) + (uint) + (long) + (ulong) + (real) + (double) + (float) + (cent) + (ucent) + (ireal) + (idouble) + (ifloat) + (creal) + (double) + (cfloat) +] @type.builtin + +; Functions +(function_declaration + (identifier) @function) + +(call_expression + (identifier) @function) + +(call_expression + (type + (identifier) @function .)) + +(call_expression + (property_expression + (call_expression) + (identifier) @function .)) + +; Parameters +(parameter + (_) + (identifier) @variable.parameter) + +(function_literal + "(" + (type + (identifier) @variable.parameter)) + +; Constructors +(constructor + (this) @constructor) + +(destructor + (this) @constructor) + +(postblit + . + (this) @constructor) + +; Punctuation +[ + ";" + "." + ":" + "," + "=>" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +"..." @punctuation.special + +; Ternaries +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +; Labels +(label + (identifier) @label) + +(goto_statement + (identifier) @label) + +; Literals +(string_literal) @string + +[ + (int_literal) + (float_literal) +] @number + +(char_literal) @character + +[ + (true) + (false) +] @boolean + +[ + (null) + (special_keyword) +] @constant.builtin + +; Comments +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[+][+][^+].*[+]/$")) diff --git a/runtime/queries/d/indents.scm b/runtime/queries/d/indents.scm new file mode 100644 index 000000000..c89b4e91d --- /dev/null +++ b/runtime/queries/d/indents.scm @@ -0,0 +1,24 @@ +[ + (parameters) + (template_parameters) + (expression_statement) + (aggregate_body) + (function_body) + (scope_statement) + (block_statement) + (case_statement) +] @indent.begin + +(comment) @indent.auto + +[ + (case) + (default) + "}" + "]" +] @indent.branch + +[ + (directive) + (shebang) +] @indent.zero diff --git a/runtime/queries/d/injections.scm b/runtime/queries/d/injections.scm new file mode 100644 index 000000000..cfc1bf986 --- /dev/null +++ b/runtime/queries/d/injections.scm @@ -0,0 +1,19 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((call_expression + (type) @_printf + (named_arguments + "(" + . + (named_argument + (expression + (string_literal) @injection.content)))) + (#eq? @_printf "printf") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "printf")) + +; TODO: uncomment when asm is added +; ((asm_inline) @injection.content +; (#set! injection.language "asm") +; (#set! injection.combined)) diff --git a/runtime/queries/d/locals.scm b/runtime/queries/d/locals.scm new file mode 100644 index 000000000..2cd7b9e89 --- /dev/null +++ b/runtime/queries/d/locals.scm @@ -0,0 +1,79 @@ +; Scopes +[ + (source_file) + (block_statement) + (aggregate_body) +] @local.scope + +; References +(identifier) @local.reference + +; Definitions +(module_def + (module_declaration + (module_fqn) @local.definition.namespace) + (#set! definition.namespace.scope "global")) + +(enum_declaration + (enum_member + . + (identifier) @local.definition.enum)) + +(class_declaration + (class) + . + (identifier) @local.definition.type) + +(struct_declaration + (struct) + . + (identifier) @local.definition.type) + +(union_declaration + (union) + . + (identifier) @local.definition.type) + +(enum_declaration + (enum) + . + (identifier) @local.definition.type) + +(alias_declaration + (alias_initializer + . + (identifier) @local.definition.type)) + +(constructor + (this) @local.definition.method) + +(destructor + (this) @local.definition.method) + +(postblit + (this) @local.definition.method) + +(aggregate_body + (function_declaration + (identifier) @local.definition.method)) + +(manifest_declarator + . + (identifier) @local.definition.constant) + +(anonymous_enum_declaration + (enum_member + . + (identifier) @local.definition.constant)) + +(variable_declaration + (declarator + (identifier) @local.definition.var)) + +(aggregate_body + (variable_declaration + (declarator + (identifier) @local.definition.field))) + +(function_declaration + (identifier) @local.definition.function) diff --git a/runtime/queries/dart/folds.scm b/runtime/queries/dart/folds.scm new file mode 100644 index 000000000..fc75ac219 --- /dev/null +++ b/runtime/queries/dart/folds.scm @@ -0,0 +1,13 @@ +[ + (class_definition) + (enum_declaration) + (extension_declaration) + (arguments) + (function_body) + (block) + (switch_block) + (list_literal) + (set_or_map_literal) + (string_literal) + (import_or_export)+ +] @fold diff --git a/runtime/queries/dart/highlights.scm b/runtime/queries/dart/highlights.scm new file mode 100644 index 000000000..072a10d26 --- /dev/null +++ b/runtime/queries/dart/highlights.scm @@ -0,0 +1,303 @@ +(identifier) @variable + +(dotted_identifier_list) @string + +; Methods +; -------------------- +; TODO: add method/call_expression to grammar and +; distinguish method call from variable access +(function_expression_body + (identifier) @function.call) + +; ((identifier)(selector (argument_part)) @function) +; NOTE: This query is a bit of a work around for the fact that the dart grammar doesn't +; specifically identify a node as a function call +(((identifier) @function.call + (#lua-match? @function.call "^_?[%l]")) + . + (selector + . + (argument_part))) @function.call + +; Annotations +; -------------------- +(annotation + "@" @attribute + name: (identifier) @attribute) + +; Operators and Tokens +; -------------------- +(template_substitution + "$" @punctuation.special + "{" @punctuation.special + "}" @punctuation.special) @none + +(template_substitution + "$" @punctuation.special + (identifier_dollar_escaped) @variable) @none + +(escape_sequence) @string.escape + +[ + "=>" + ".." + "??" + "==" + "!" + "?" + "&&" + "%" + "<" + ">" + "=" + ">=" + "<=" + "||" + ">>>=" + ">>=" + "<<=" + "&=" + "|=" + "??=" + "%=" + "+=" + "-=" + "*=" + "/=" + "^=" + "~/=" + (shift_operator) + (multiplicative_operator) + (increment_operator) + (is_operator) + (prefix_operator) + (equality_operator) + (additive_operator) +] @operator + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; Delimiters +; -------------------- +[ + ";" + "." + "," + ":" + "?." + "?" +] @punctuation.delimiter + +; Types +; -------------------- +(class_definition + name: (identifier) @type) + +(constructor_signature + name: (identifier) @type) + +(scoped_identifier + scope: (identifier) @type) + +(function_signature + name: (identifier) @function.method) + +(getter_signature + (identifier) @function.method) + +(setter_signature + name: (identifier) @function.method) + +(enum_declaration + name: (identifier) @type) + +(enum_constant + name: (identifier) @type) + +(void_type) @type + +((scoped_identifier + scope: (identifier) @type + name: (identifier) @type) + (#lua-match? @type "^[%u%l]")) + +(type_identifier) @type + +(type_alias + (type_identifier) @type.definition) + +(type_arguments + [ + "<" + ">" + ] @punctuation.bracket) + +; Variables +; -------------------- +; var keyword +(inferred_type) @keyword + +((identifier) @type + (#lua-match? @type "^_?[%u].*[%l]")) ; catch Classes or IClasses not CLASSES + +"Function" @type + +; properties +(unconditional_assignable_selector + (identifier) @property) + +(conditional_assignable_selector + (identifier) @property) + +(this) @variable.builtin + +; Parameters +; -------------------- +(formal_parameter + (identifier) @variable.parameter) + +(named_argument + (label + (identifier) @variable.parameter)) + +; Literals +; -------------------- +[ + (hex_integer_literal) + (decimal_integer_literal) + (decimal_floating_point_literal) + ; TODO: inaccessible nodes + ; (octal_integer_literal) + ; (hex_floating_point_literal) +] @number + +(symbol_literal) @string.special.symbol + +(string_literal) @string + +(true) @boolean + +(false) @boolean + +(null_literal) @constant.builtin + +(comment) @comment @spell + +(documentation_comment) @comment.documentation @spell + +; Keywords +; -------------------- +[ + "import" + "library" + "export" + "as" + "show" + "hide" +] @keyword.import + +; Reserved words (cannot be used as identifiers) +[ + ; TODO: + ; "rethrow" cannot be targeted at all and seems to be an invisible node + ; TODO: + ; the assert keyword cannot be specifically targeted + ; because the grammar selects the whole node or the content + ; of the assertion not just the keyword + ; assert + (case_builtin) + "late" + "required" + "on" + "extends" + "in" + "is" + "new" + "super" + "with" +] @keyword + +[ + "class" + "enum" + "extension" +] @keyword.type + +"return" @keyword.return + +; Built in identifiers: +; alone these are marked as keywords +[ + "deferred" + "factory" + "get" + "implements" + "interface" + "library" + "operator" + "mixin" + "part" + "set" + "typedef" +] @keyword + +[ + "async" + "async*" + "sync*" + "await" + "yield" +] @keyword.coroutine + +[ + (const_builtin) + (final_builtin) + "abstract" + "covariant" + "external" + "static" + "final" + "base" + "sealed" +] @keyword.modifier + +; when used as an identifier: +((identifier) @variable.builtin + (#any-of? @variable.builtin + "abstract" "as" "covariant" "deferred" "dynamic" "export" "external" "factory" "Function" "get" + "implements" "import" "interface" "library" "operator" "mixin" "part" "set" "static" "typedef")) + +[ + "if" + "else" + "switch" + "default" +] @keyword.conditional + +(conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +[ + "try" + "throw" + "catch" + "finally" + (break_statement) +] @keyword.exception + +[ + "do" + "while" + "continue" + "for" +] @keyword.repeat diff --git a/runtime/queries/dart/indents.scm b/runtime/queries/dart/indents.scm new file mode 100644 index 000000000..03d9464bc --- /dev/null +++ b/runtime/queries/dart/indents.scm @@ -0,0 +1,49 @@ +[ + (class_body) + (function_body) + (function_expression_body) + (declaration + (initializers)) + (switch_block) + (formal_parameter_list) + (formal_parameter) + (list_literal) + (return_statement) + (arguments) + (try_statement) +] @indent.begin + +(switch_block + (_) @indent.begin + (#set! indent.immediate 1) + (#set! indent.start_at_same_line 1)) + +[ + (switch_statement_case) + (switch_statement_default) +] @indent.branch + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @indent.branch + +"}" @indent.end + +(return_statement + ";" @indent.end) + +(break_statement + ";" @indent.end) + +(comment) @indent.ignore + +; dedenting the else block is painfully slow; replace with simpler strategy +; (if_statement) @indent.begin +; (if_statement +; (block) @indent.branch) +(if_statement) @indent.auto diff --git a/runtime/queries/dart/injections.scm b/runtime/queries/dart/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/dart/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/dart/locals.scm b/runtime/queries/dart/locals.scm new file mode 100644 index 000000000..3e3beb58e --- /dev/null +++ b/runtime/queries/dart/locals.scm @@ -0,0 +1,32 @@ +; Definitions +(function_signature + name: (identifier) @local.definition.function) + +(formal_parameter + name: (identifier) @local.definition.parameter) + +(initialized_variable_definition + name: (identifier) @local.definition.var) + +(initialized_identifier + (identifier) @local.definition.var) + +(static_final_declaration + (identifier) @local.definition.var) + +; References +(identifier) @local.reference + +; Scopes +(class_definition + body: (_) @local.scope) + +[ + (block) + (if_statement) + (for_statement) + (while_statement) + (try_statement) + (catch_clause) + (finally_clause) +] @local.scope diff --git a/runtime/queries/desktop/folds.scm b/runtime/queries/desktop/folds.scm new file mode 100644 index 000000000..624ca8a86 --- /dev/null +++ b/runtime/queries/desktop/folds.scm @@ -0,0 +1 @@ +(group) @fold diff --git a/runtime/queries/desktop/highlights.scm b/runtime/queries/desktop/highlights.scm new file mode 100644 index 000000000..7a5ebf241 --- /dev/null +++ b/runtime/queries/desktop/highlights.scm @@ -0,0 +1,94 @@ +(comment) @comment @spell + +(group_name) @markup.heading + +(entry + key: (identifier) @property) + +(localized_key + name: (identifier) @property) + +[ + (language) + (country) + (encoding) + (modifier) +] @string.special + +(string) @string + +(escape_sequence) @string.escape + +(field_code) @character.special + +[ + (true) + (false) +] @boolean + +"=" @operator + +[ + ";" + "_" + "." + "@" +] @punctuation.delimiter + +[ + "[" + "]" +] @punctuation.bracket + +; Especial entries +((entry + key: (identifier) @_key + value: (string) @type) + (#eq? @_key "Type") + (#any-of? @type "Application" "Link" "Directory")) + +((entry + key: (identifier) @_key + value: (string) @number) + (#eq? @_key "Version")) + +((entry + key: (identifier) @_key + value: (string) @string.special.path) + (#any-of? @_key "TryExec" "Path")) + +((entry + key: (identifier) @_key + value: (string) @string.special.url) + (#eq? @_key "URL")) + +; https://specifications.freedesktop.org/menu-spec/latest/category-registry.html +((entry + key: (identifier) @_key + value: (list + (string) @constant.builtin)) + (#eq? @_key "Categories") + (#any-of? @constant.builtin + ; Main categories + "AudioVideo" "Audio" "Video" "Development" "Education" "Game" "Graphics" "Network" "Office" + "Science" "Settings" "System" "Utility" + ; Additional Categories + "Building" "Debugger" "IDE" "GUIDesigner" "Profiling" "RevisionControl" "Translation" "Calendar" + "ContactManagement" "Database" "Dictionary" "Chart" "Email" "Finance" "FlowChart" "PDA" + "ProjectManagement" "Presentation" "Spreadsheet" "WordProcessor" "2DGraphics" "VectorGraphics" + "RasterGraphics" "3DGraphics" "Scanning" "OCR" "Photography" "Publishing" "Viewer" "TextTools" + "DesktopSettings" "HardwareSettings" "Printing" "PackageManager" "Dialup" "InstantMessaging" + "Chat" "IRCClient" "Feed" "FileTransfer" "HamRadio" "News" "P2P" "RemoteAccess" "Telephony" + "TelephonyTools" "VideoConference" "WebBrowser" "WebDevelopment" "Midi" "Mixer" "Sequencer" + "Tuner" "TV" "AudioVideoEditing" "Player" "Recorder" "DiscBurning" "ActionGame" "AdventureGame" + "ArcadeGame" "BoardGame" "BlocksGame" "CardGame" "KidsGame" "LogicGame" "RolePlaying" "Shooter" + "Simulation" "SportsGame" "StrategyGame" "Art" "Construction" "Music" "Languages" + "ArtificialIntelligence" "Astronomy" "Biology" "Chemistry" "ComputerScience" "DataVisualization" + "Economy" "Electricity" "Geography" "Geology" "Geoscience" "History" "Humanities" + "ImageProcessing" "Literature" "Maps" "Math" "NumericalAnalysis" "MedicalSoftware" "Physics" + "Robotics" "Spirituality" "Sports" "ParallelComputing" "Amusement" "Archiving" "Compression" + "Electronics" "Emulator" "Engineering" "FileTools" "FileManager" "TerminalEmulator" "Filesystem" + "Monitor" "Security" "Accessibility" "Calculator" "Clock" "TextEditor" "Documentation" "Adult" + "Core" "KDE" "COSMIC" "GNOME" "XFCE" "DDE" "GTK" "Qt" "Motif" "Java" "ConsoleOnly" + ; Reserved + "Screensaver" "TrayIcon" "Applet" "Shell")) diff --git a/runtime/queries/desktop/injections.scm b/runtime/queries/desktop/injections.scm new file mode 100644 index 000000000..1666a0430 --- /dev/null +++ b/runtime/queries/desktop/injections.scm @@ -0,0 +1,8 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((entry + key: (identifier) @_exec + value: (string) @injection.content) + (#eq? @_exec "Exec") + (#set! injection.language "bash")) diff --git a/runtime/queries/devicetree/folds.scm b/runtime/queries/devicetree/folds.scm new file mode 100644 index 000000000..206c4bed8 --- /dev/null +++ b/runtime/queries/devicetree/folds.scm @@ -0,0 +1 @@ +(node) @fold diff --git a/runtime/queries/devicetree/highlights.scm b/runtime/queries/devicetree/highlights.scm new file mode 100644 index 000000000..74ec89af1 --- /dev/null +++ b/runtime/queries/devicetree/highlights.scm @@ -0,0 +1,61 @@ +(comment) @comment @spell + +[ + (preproc_include) + (dtsi_include) +] @keyword.import + +(preproc_def) @constant.macro + +(preproc_function_def) @function.macro + +[ + (memory_reservation) + (file_version) +] @attribute + +[ + (string_literal) + (byte_string_literal) + (system_lib_string) +] @string + +(integer_literal) @number + +(identifier) @variable + +(node + (identifier) @module) + +(property + (identifier) @property) + +(node + label: (_) @label) + +(call_expression + (identifier) @function.macro) + +(reference) @label ; referencing labeled_item.identifier + +(unit_address) @constant + +"=" @operator + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" +] @punctuation.bracket + +[ + ";" + ":" + "," + "@" +] @punctuation.delimiter diff --git a/runtime/queries/devicetree/indents.scm b/runtime/queries/devicetree/indents.scm new file mode 100644 index 000000000..9740060ca --- /dev/null +++ b/runtime/queries/devicetree/indents.scm @@ -0,0 +1,12 @@ +[ + (node) + (property) + (integer_cells) +] @indent.begin + +[ + "}" + ">" +] @indent.branch + +(comment) @indent.ignore diff --git a/runtime/queries/devicetree/injections.scm b/runtime/queries/devicetree/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/devicetree/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/devicetree/locals.scm b/runtime/queries/devicetree/locals.scm new file mode 100644 index 000000000..e33a81dfd --- /dev/null +++ b/runtime/queries/devicetree/locals.scm @@ -0,0 +1,4 @@ +[ + (node) + (integer_cells) +] @local.scope diff --git a/runtime/queries/dhall/folds.scm b/runtime/queries/dhall/folds.scm new file mode 100644 index 000000000..bc92797b4 --- /dev/null +++ b/runtime/queries/dhall/folds.scm @@ -0,0 +1,10 @@ +[ + (let_binding) + (application_expression) + (lambda_expression) + (record_type) + (union_type) + (list_literal) + (record_literal) + (block_comment) +] @fold diff --git a/runtime/queries/dhall/highlights.scm b/runtime/queries/dhall/highlights.scm new file mode 100644 index 000000000..d7a5d0006 --- /dev/null +++ b/runtime/queries/dhall/highlights.scm @@ -0,0 +1,200 @@ +; Imports +(missing_import) @keyword.import + +(local_import) @string.special.path + +(http_import) @string.special.url + +[ + (env_variable) + (import_hash) +] @string.special + +[ + (import_as_bytes) + (import_as_location) + (import_as_text) +] @type + +; Types +([ + (let_binding + (label) @type) + (union_type_entry + (label) @type) +] + (#lua-match? @type "^%u")) + +((primitive_expression + (identifier + (label) @type) + (selector + (label) @type)) @variable + (#lua-match? @variable "^[A-Z][^.]*$")) + +; Parameters +(lambda_expression + label: (label) @variable.parameter) + +; Variables +(label) @variable + +(identifier + [ + (label) @variable + (de_bruijn_index) @operator + ]) + +(let_binding + label: (label) @variable) + +; Fields +(record_literal_entry + (label) @variable.member) + +(record_type_entry + (label) @variable.member) + +(selector + (selector_dot) + (_) @variable.member) + +; Keywords +(env_import) @keyword + +[ + "let" + "in" + "assert" +] @keyword + +[ + "using" + "as" + "with" +] @keyword.operator + +; Operators +[ + (type_operator) + (assign_operator) + (lambda_operator) + (arrow_operator) + (infix_operator) + (completion_operator) + (assert_operator) + (forall_operator) + (empty_record_literal) +] @operator + +; Builtins +(builtin_function) @function.builtin + +(builtin + [ + "Bool" + "Natural" + "Natural/build" + "Natural/fold" + "Natural/isZero" + "Natural/even" + "Natural/odd" + "Natural/subtract" + "Natural/toInteger" + "Natural/show" + "Integer" + "Integer/toDouble" + "Integer/show" + "Integer/negate" + "Integer/clamp" + "Double" + "Double/show" + "List" + "List/build" + "List/fold" + "List/length" + "List/head" + "List/last" + "List/indexed" + "List/reverse" + "Text" + "Text/show" + "Text/replace" + "Optional" + "Date" + "Date/show" + "Time" + "Time/show" + "TimeZone" + "TimeZone/show" + "Type" + "Kind" + "Sort" + ] @type.builtin) + +; Punctuation +[ + "," + "|" +] @punctuation.delimiter + +(selector_dot) @punctuation.delimiter + +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "<" + ">" +] @punctuation.bracket + +; Conditionals +[ + "if" + "then" + "else" +] @keyword.conditional + +; Literals +[ + (text_literal) + (bytes_literal) +] @string + +(interpolation + "}" @string) + +[ + (double_quote_escaped) + (single_quote_escaped) +] @string.escape + +[ + (integer_literal) + (natural_literal) +] @number + +(double_literal) @number.float + +(boolean_literal) @boolean + +(builtin + "None") @constant.builtin + +; Comments +[ + (line_comment) + (block_comment) +] @comment @spell diff --git a/runtime/queries/dhall/injections.scm b/runtime/queries/dhall/injections.scm new file mode 100644 index 000000000..3cd6aac8e --- /dev/null +++ b/runtime/queries/dhall/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/diff/folds.scm b/runtime/queries/diff/folds.scm new file mode 100644 index 000000000..3560abb3e --- /dev/null +++ b/runtime/queries/diff/folds.scm @@ -0,0 +1,5 @@ +[ + (block) + (hunks) + (hunk) +] @fold diff --git a/runtime/queries/diff/highlights.scm b/runtime/queries/diff/highlights.scm new file mode 100644 index 000000000..54c57a807 --- /dev/null +++ b/runtime/queries/diff/highlights.scm @@ -0,0 +1,49 @@ +(comment) @comment @spell + +[ + (addition) + (new_file) +] @diff.plus + +[ + (deletion) + (old_file) +] @diff.minus + +(commit) @constant + +(location) @attribute + +(command + "diff" @function + (argument) @variable.parameter) + +(filename) @string.special.path + +(mode) @number + +([ + ".." + "+" + "++" + "+++" + "++++" + "-" + "--" + "---" + "----" +] @punctuation.special + (#set! priority 95)) + +[ + (binary_change) + (similarity) + (file_change) +] @label + +(index + "index" @keyword) + +(similarity + (score) @number + "%" @number) diff --git a/runtime/queries/diff/injections.scm b/runtime/queries/diff/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/diff/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/disassembly/highlights.scm b/runtime/queries/disassembly/highlights.scm new file mode 100644 index 000000000..b1ece9ab6 --- /dev/null +++ b/runtime/queries/disassembly/highlights.scm @@ -0,0 +1,30 @@ +(byte) @constant + +[ + (address) + (hexadecimal) + (integer) +] @number + +(identifier) @variable + +(bad_instruction) @comment.warning + +(code_location + (identifier) @function.call) + +(comment) @comment + +(instruction) @function + +(memory_dump) @string + +[ + "<" + ">" +] @punctuation.special + +[ + "+" + ":" +] @punctuation.delimiter diff --git a/runtime/queries/disassembly/injections.scm b/runtime/queries/disassembly/injections.scm new file mode 100644 index 000000000..9fb52dafe --- /dev/null +++ b/runtime/queries/disassembly/injections.scm @@ -0,0 +1,6 @@ +; TODO: https://github.com/nvim-treesitter/nvim-treesitter/pull/5548#issuecomment-1773707396 +; +; To be added once a compatible Assembly parser is merged into nvim-treesitter +; +; ((instruction) @injection.content +; (#set! injection.language "asm")) diff --git a/runtime/queries/djot/folds.scm b/runtime/queries/djot/folds.scm new file mode 100644 index 000000000..94f3724eb --- /dev/null +++ b/runtime/queries/djot/folds.scm @@ -0,0 +1,7 @@ +[ + (section) + (code_block) + (raw_block) + (list) + (div) +] @fold diff --git a/runtime/queries/djot/highlights.scm b/runtime/queries/djot/highlights.scm new file mode 100644 index 000000000..73dd66057 --- /dev/null +++ b/runtime/queries/djot/highlights.scm @@ -0,0 +1,372 @@ +(heading) @markup.heading + +((heading + (marker) @_heading.marker) @markup.heading.1 + (#eq? @_heading.marker "# ")) + +((heading + (marker) @_heading.marker) @markup.heading.2 + (#eq? @_heading.marker "## ")) + +((heading + (marker) @_heading.marker) @markup.heading.3 + (#eq? @_heading.marker "### ")) + +((heading + (marker) @_heading.marker) @markup.heading.4 + (#eq? @_heading.marker "##### ")) + +((heading + (marker) @_heading.marker) @markup.heading.5 + (#eq? @_heading.marker "###### ")) + +((heading + (marker) @_heading.marker) @markup.heading.6 + (#eq? @_heading.marker "####### ")) + +(thematic_break) @string.special + +[ + (div_marker_begin) + (div_marker_end) +] @punctuation.delimiter + +([ + (code_block) + (raw_block) + (frontmatter) +] @markup.raw.block + (#set! priority 90)) + +; Remove @markup.raw for code with a language spec +(code_block + . + (code_block_marker_begin) + (language) + (code) @none + (#set! priority 90)) + +[ + (code_block_marker_begin) + (code_block_marker_end) + (raw_block_marker_begin) + (raw_block_marker_end) +] @punctuation.delimiter + +(language) @attribute + +(inline_attribute + _ @conceal + (#set! conceal "")) + +((language_marker) @punctuation.delimiter + (#set! conceal "")) + +(block_quote) @markup.quote + +(block_quote_marker) @punctuation.special + +(table_header) @markup.heading + +(table_header + "|" @punctuation.special) + +(table_row + "|" @punctuation.special) + +(table_separator) @punctuation.special + +(table_caption + (marker) @punctuation.special) + +(table_caption) @markup.italic + +[ + (list_marker_dash) + (list_marker_plus) + (list_marker_star) + (list_marker_definition) + (list_marker_decimal_period) + (list_marker_decimal_paren) + (list_marker_decimal_parens) + (list_marker_lower_alpha_period) + (list_marker_lower_alpha_paren) + (list_marker_lower_alpha_parens) + (list_marker_upper_alpha_period) + (list_marker_upper_alpha_paren) + (list_marker_upper_alpha_parens) + (list_marker_lower_roman_period) + (list_marker_lower_roman_paren) + (list_marker_lower_roman_parens) + (list_marker_upper_roman_period) + (list_marker_upper_roman_paren) + (list_marker_upper_roman_parens) +] @markup.list + +(list_marker_task + (unchecked)) @markup.list.unchecked + +(list_marker_task + (checked)) @markup.list.checked + +; Colorize `x` in `[x]` +((checked) @constant.builtin + (#offset! @constant.builtin 0 1 0 -1)) + +[ + (ellipsis) + (en_dash) + (em_dash) + (quotation_marks) +] @string.special + +(list_item + (term) @type.definition) + +; Conceal { and } but leave " and ' +((quotation_marks) @string.special + (#any-of? @string.special "\"}" "'}") + (#offset! @string.special 0 1 0 0) + (#set! conceal "")) + +((quotation_marks) @string.special + (#any-of? @string.special "\\\"" "\\'" "{'" "{\"") + (#offset! @string.special 0 0 0 -1) + (#set! conceal "")) + +[ + (hard_line_break) + (backslash_escape) +] @string.escape + +; Only conceal \ but leave escaped character. +((backslash_escape) @string.escape + (#offset! @string.escape 0 0 0 -1) + (#set! conceal "")) + +(frontmatter_marker) @punctuation.delimiter + +(emphasis) @markup.italic + +(strong) @markup.strong + +(symbol) @string.special.symbol + +(insert) @markup.underline + +(delete) @markup.strikethrough + +[ + (highlighted) + (superscript) + (subscript) +] @string.special + +([ + (emphasis_begin) + (emphasis_end) + (strong_begin) + (strong_end) + (superscript_begin) + (superscript_end) + (subscript_begin) + (subscript_end) + (highlighted_begin) + (highlighted_end) + (insert_begin) + (insert_end) + (delete_begin) + (delete_end) + (verbatim_marker_begin) + (verbatim_marker_end) + (math_marker) + (math_marker_begin) + (math_marker_end) + (raw_inline_attribute) + (raw_inline_marker_begin) + (raw_inline_marker_end) +] @punctuation.delimiter + (#set! conceal "")) + +((math) @markup.math + (#set! priority 90)) + +(verbatim) @markup.raw + +((raw_inline) @markup.raw + (#set! priority 90)) + +[ + (comment) + (inline_comment) +] @comment + +(span + [ + "[" + "]" + ] @punctuation.bracket) + +(inline_attribute + [ + "{" + "}" + ] @punctuation.bracket) + +(block_attribute + [ + "{" + "}" + ] @punctuation.bracket) + +[ + (class) + (class_name) +] @type + +(identifier) @tag + +(key_value + "=" @operator) + +(key_value + (key) @property) + +(key_value + (value) @string) + +(link_text + [ + "[" + "]" + ] @punctuation.bracket + (#set! conceal "")) + +(autolink + [ + "<" + ">" + ] @punctuation.bracket + (#set! conceal "")) + +(inline_link + (inline_link_destination) @markup.link.url + (#set! conceal "")) + +(link_reference_definition + ":" @punctuation.special) + +(full_reference_link + (link_text) @markup.link) + +(full_reference_link + (link_label) @markup.link.label + (#set! conceal "")) + +(collapsed_reference_link + "[]" @punctuation.bracket + (#set! conceal "")) + +(full_reference_link + [ + "[" + "]" + ] @punctuation.bracket + (#set! conceal "")) + +(collapsed_reference_link + (link_text) @markup.link) + +(collapsed_reference_link + (link_text) @markup.link.label) + +(inline_link + (link_text) @markup.link) + +(full_reference_image + (link_label) @markup.link.label) + +(full_reference_image + [ + "[" + "]" + ] @punctuation.bracket) + +(collapsed_reference_image + "[]" @punctuation.bracket) + +(image_description + [ + "![" + "]" + ] @punctuation.bracket) + +(image_description) @markup.italic + +(link_reference_definition + [ + "[" + "]" + ] @punctuation.bracket) + +(link_reference_definition + (link_label) @markup.link.label) + +(inline_link_destination + [ + "(" + ")" + ] @punctuation.bracket) + +[ + (autolink) + (inline_link_destination) + (link_destination) + (link_reference_definition) +] @markup.link.url + +(footnote + (reference_label) @markup.link.label) + +(footnote_reference + (reference_label) @markup.link.label) + +[ + (footnote_marker_begin) + (footnote_marker_end) +] @punctuation.bracket + +(todo) @comment.todo + +(note) @comment.note + +(fixme) @comment.error + +[ + (paragraph) + (comment) + (table_cell) +] @spell + +[ + (autolink) + (inline_link_destination) + (link_destination) + (code_block) + (raw_block) + (math) + (raw_inline) + (verbatim) + (reference_label) + (class) + (class_name) + (identifier) + (key_value) + (frontmatter) +] @nospell + +(full_reference_link + (link_label) @nospell) + +(full_reference_image + (link_label) @nospell) diff --git a/runtime/queries/djot/indents.scm b/runtime/queries/djot/indents.scm new file mode 100644 index 000000000..3b1a56ebd --- /dev/null +++ b/runtime/queries/djot/indents.scm @@ -0,0 +1,10 @@ +; The intention here is to rely on Neovims `autoindent` setting. +; This allows us to not indent after just a single list item +; so we can create narrow lists quickly, but indent blocks inside list items +; to the previous paragraph. +(list_item_content) @indent.auto + +(footnote_content) @indent.align + +((table_caption) @indent.begin + (#set! indent.immediate 1)) diff --git a/runtime/queries/djot/injections.scm b/runtime/queries/djot/injections.scm new file mode 100644 index 000000000..0e4141046 --- /dev/null +++ b/runtime/queries/djot/injections.scm @@ -0,0 +1,24 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +(math + (content) @injection.content + (#set! injection.language "latex")) + +(code_block + (language) @injection.language + (code) @injection.content) + +(raw_block + (raw_block_info + (language) @injection.language) + (content) @injection.content) + +(raw_inline + (content) @injection.content + (raw_inline_attribute + (language) @injection.language)) + +(frontmatter + (language) @injection.language + (frontmatter_content) @injection.content) diff --git a/runtime/queries/djot/locals.scm b/runtime/queries/djot/locals.scm new file mode 100644 index 000000000..1ac27529f --- /dev/null +++ b/runtime/queries/djot/locals.scm @@ -0,0 +1,17 @@ +(link_reference_definition + (link_label) @local.definition) + +(footnote + (reference_label) @local.definition) + +(collapsed_reference_link + (link_text) @local.reference) + +(full_reference_link + (link_label) @local.reference) + +(full_reference_image + (link_label) @local.reference) + +(footnote_reference + (reference_label) @local.reference) diff --git a/runtime/queries/dockerfile/highlights.scm b/runtime/queries/dockerfile/highlights.scm new file mode 100644 index 000000000..72893f8b0 --- /dev/null +++ b/runtime/queries/dockerfile/highlights.scm @@ -0,0 +1,68 @@ +[ + "FROM" + "AS" + "RUN" + "CMD" + "LABEL" + "EXPOSE" + "ENV" + "ADD" + "COPY" + "ENTRYPOINT" + "VOLUME" + "USER" + "WORKDIR" + "ARG" + "ONBUILD" + "STOPSIGNAL" + "HEALTHCHECK" + "SHELL" + "MAINTAINER" + "CROSS_BUILD" +] @keyword + +[ + ":" + "@" +] @operator + +(comment) @comment @spell + +(image_spec + (image_tag + ":" @punctuation.special) + (image_digest + "@" @punctuation.special)) + +(double_quoted_string) @string + +[ + (heredoc_marker) + (heredoc_end) +] @label + +((heredoc_block + (heredoc_line) @string) + (#set! priority 90)) + +(expansion + [ + "$" + "{" + "}" + ] @punctuation.special) + +((variable) @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + +(arg_instruction + . + (unquoted_string) @property) + +(env_instruction + (env_pair + . + (unquoted_string) @property)) + +(expose_instruction + (expose_port) @number) diff --git a/runtime/queries/dockerfile/injections.scm b/runtime/queries/dockerfile/injections.scm new file mode 100644 index 000000000..5d3bbffb7 --- /dev/null +++ b/runtime/queries/dockerfile/injections.scm @@ -0,0 +1,12 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((shell_command + (shell_fragment) @injection.content) + (#set! injection.language "bash") + (#set! injection.combined)) + +((run_instruction + (heredoc_block) @injection.content) + (#set! injection.language "bash") + (#set! injection.include-children)) diff --git a/runtime/queries/dot/highlights.scm b/runtime/queries/dot/highlights.scm new file mode 100644 index 000000000..75ad92271 --- /dev/null +++ b/runtime/queries/dot/highlights.scm @@ -0,0 +1,49 @@ +(identifier) @type + +[ + "strict" + "graph" + "digraph" + "subgraph" + "node" + "edge" +] @keyword + +(string_literal) @string + +(number_literal) @number + +[ + (edgeop) + (operator) +] @operator + +[ + "," + ";" +] @punctuation.delimiter + +[ + "{" + "}" + "[" + "]" + "<" + ">" +] @punctuation.bracket + +(subgraph + id: (id + (identifier) @module)) + +(attribute + name: (id + (identifier) @variable.member)) + +(attribute + value: (id + (identifier) @constant)) + +(comment) @comment @spell + +(preproc) @keyword.directive diff --git a/runtime/queries/dot/indents.scm b/runtime/queries/dot/indents.scm new file mode 100644 index 000000000..a951e5511 --- /dev/null +++ b/runtime/queries/dot/indents.scm @@ -0,0 +1,9 @@ +[ + (block) + (attr_list) +] @indent.begin + +[ + "}" + "]" +] @indent.branch @indent.end diff --git a/runtime/queries/dot/injections.scm b/runtime/queries/dot/injections.scm new file mode 100644 index 000000000..4fe39a8ba --- /dev/null +++ b/runtime/queries/dot/injections.scm @@ -0,0 +1,5 @@ +((html_internal) @injection.content + (#set! injection.language "html")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/doxygen/highlights.scm b/runtime/queries/doxygen/highlights.scm new file mode 100644 index 000000000..454500d64 --- /dev/null +++ b/runtime/queries/doxygen/highlights.scm @@ -0,0 +1,61 @@ +((tag_name) @keyword + (#set! priority 105)) + +[ + "@code" + "@endcode" +] @keyword + +(identifier) @variable + +((tag + (tag_name) @_param + (identifier) @variable.parameter) + (#any-of? @_param "@param" "\\param")) + +(function + (identifier) @function) + +(function_link) @function + +(emphasis) @markup.italic + +[ + "\\a" + "\\c" +] @tag + +(code_block_language) @label + +[ + "in" + "out" + "inout" +] @keyword.modifier + +"~" @operator + +[ + "<a" + ">" + "</a>" +] @tag + +[ + "." + "," + "::" + (code_block_start) + (code_block_end) +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +(code_block_content) @none diff --git a/runtime/queries/doxygen/indents.scm b/runtime/queries/doxygen/indents.scm new file mode 100644 index 000000000..ef30f1e76 --- /dev/null +++ b/runtime/queries/doxygen/indents.scm @@ -0,0 +1 @@ +(document) @indent.auto diff --git a/runtime/queries/doxygen/injections.scm b/runtime/queries/doxygen/injections.scm new file mode 100644 index 000000000..994f535ad --- /dev/null +++ b/runtime/queries/doxygen/injections.scm @@ -0,0 +1,15 @@ +((type) @injection.content + (#set! injection.parent)) + +([ + (function_link) + (code) +] @injection.content + (#set! injection.parent)) + +((link) @injection.content + (#set! injection.language "html")) + +(code_block + (code_block_language) @injection.language + (code_block_content) @injection.content) diff --git a/runtime/queries/dtd/folds.scm b/runtime/queries/dtd/folds.scm new file mode 100644 index 000000000..b1bce4ffb --- /dev/null +++ b/runtime/queries/dtd/folds.scm @@ -0,0 +1,4 @@ +[ + (conditionalSect) + (Comment) +] @fold diff --git a/runtime/queries/dtd/highlights.scm b/runtime/queries/dtd/highlights.scm new file mode 100644 index 000000000..9afd6e38b --- /dev/null +++ b/runtime/queries/dtd/highlights.scm @@ -0,0 +1,148 @@ +; Text declaration +(TextDecl + "xml" @keyword.directive) + +(TextDecl + [ + "version" + "encoding" + ] @tag.attribute) + +(TextDecl + (EncName) @string.special) + +(TextDecl + (VersionNum) @number) + +; Processing instructions +(PI) @keyword.directive + +; Element declaration +(elementdecl + "ELEMENT" @keyword.directive.define + (Name) @tag) + +(contentspec + (_ + (Name) @tag.attribute)) + +"#PCDATA" @type.builtin + +[ + "EMPTY" + "ANY" +] @keyword.modifier + +[ + "*" + "?" + "+" +] @character.special + +; Entity declaration +(GEDecl + "ENTITY" @keyword.directive.define + (Name) @constant) + +(GEDecl + (EntityValue) @string) + +(NDataDecl + "NDATA" @keyword + (Name) @label) + +; Parsed entity declaration +(PEDecl + "ENTITY" @keyword.directive.define + "%" @operator + (Name) @function.macro) + +(PEDecl + (EntityValue) @string) + +; Notation declaration +(NotationDecl + "NOTATION" @keyword.directive + (Name) @label) + +; Attlist declaration +(AttlistDecl + "ATTLIST" @keyword.directive.define + (Name) @tag) + +(AttDef + (Name) @tag.attribute) + +(AttDef + (Enumeration + (Nmtoken) @string)) + +[ + (StringType) + (TokenizedType) +] @type.builtin + +(NotationType + "NOTATION" @type.builtin) + +[ + "#REQUIRED" + "#IMPLIED" + "#FIXED" +] @attribute + +; Entities +(EntityRef) @constant + +((EntityRef) @constant.builtin + (#any-of? @constant.builtin "&" "<" ">" """ "'")) + +(CharRef) @character + +(PEReference) @function.macro + +; External references +[ + "PUBLIC" + "SYSTEM" +] @keyword + +(PubidLiteral) @string.special + +(SystemLiteral + (URI) @string.special.url) + +; Delimiters & punctuation +[ + "<?" + "?>" + "<!" + ">" + "<![" + "]]>" +] @tag.delimiter + +[ + "(" + ")" + "[" +] @punctuation.bracket + +[ + "\"" + "'" +] @punctuation.delimiter + +[ + "," + "|" + "=" +] @operator + +; Misc +[ + "INCLUDE" + "IGNORE" +] @keyword.import + +(Comment) @comment @spell diff --git a/runtime/queries/dtd/injections.scm b/runtime/queries/dtd/injections.scm new file mode 100644 index 000000000..57fae5832 --- /dev/null +++ b/runtime/queries/dtd/injections.scm @@ -0,0 +1,2 @@ +((Comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/dtd/locals.scm b/runtime/queries/dtd/locals.scm new file mode 100644 index 000000000..88246c04a --- /dev/null +++ b/runtime/queries/dtd/locals.scm @@ -0,0 +1,11 @@ +(elementdecl + (Name) @local.definition.type) + +(elementdecl + (contentspec + (children + (Name) @local.reference))) + +(AttlistDecl + . + (Name) @local.reference) diff --git a/runtime/queries/earthfile/highlights.scm b/runtime/queries/earthfile/highlights.scm new file mode 100644 index 000000000..cc7dce298 --- /dev/null +++ b/runtime/queries/earthfile/highlights.scm @@ -0,0 +1,129 @@ +(string_array + "," @punctuation.delimiter) + +(string_array + [ + "[" + "]" + ] @punctuation.bracket) + +[ + "ARG" + "AS LOCAL" + "BUILD" + "CACHE" + "CMD" + "COPY" + "DO" + "ENTRYPOINT" + "ENV" + "EXPOSE" + "FROM DOCKERFILE" + "FROM" + "FUNCTION" + "GIT CLONE" + "HOST" + "IMPORT" + "LABEL" + "LET" + "PROJECT" + "RUN" + "SAVE ARTIFACT" + "SAVE IMAGE" + "SET" + "USER" + "VERSION" + "VOLUME" + "WORKDIR" +] @keyword + +(for_command + [ + "FOR" + "IN" + "END" + ] @keyword.repeat) + +(if_command + [ + "IF" + "END" + ] @keyword.conditional) + +(elif_block + "ELSE IF" @keyword.conditional) + +(else_block + "ELSE" @keyword.conditional) + +(import_command + [ + "IMPORT" + "AS" + ] @keyword.import) + +(try_command + [ + "TRY" + "FINALLY" + "END" + ] @keyword.exception) + +(wait_command + [ + "WAIT" + "END" + ] @keyword) + +(with_docker_command + [ + "WITH DOCKER" + "END" + ] @keyword) + +[ + (comment) + (line_continuation_comment) +] @comment @spell + +[ + (target_ref) + (target_artifact) + (function_ref) +] @function + +(target + (identifier) @function) + +[ + (double_quoted_string) + (single_quoted_string) +] @string + +(unquoted_string) @string.special + +(escape_sequence) @string.escape + +(variable) @variable + +(expansion + [ + "$" + "{" + "}" + "(" + ")" + ] @punctuation.special) + +(build_arg + [ + "--" + (variable) + ] @variable.parameter) + +(options + (_) @property) + +"=" @operator + +(line_continuation) @operator diff --git a/runtime/queries/earthfile/injections.scm b/runtime/queries/earthfile/injections.scm new file mode 100644 index 000000000..7435a400e --- /dev/null +++ b/runtime/queries/earthfile/injections.scm @@ -0,0 +1,9 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((line_continuation_comment) @injection.content + (#set! injection.language "comment")) + +((shell_fragment) @injection.content + (#set! injection.language "bash") + (#set! injection.include-children)) diff --git a/runtime/queries/ebnf/highlights.scm b/runtime/queries/ebnf/highlights.scm new file mode 100644 index 000000000..4254d04dd --- /dev/null +++ b/runtime/queries/ebnf/highlights.scm @@ -0,0 +1,42 @@ +; Simple tokens ;;;; +(terminal) @string + +(special_sequence) @string.special + +(integer) @number + +(comment) @comment @spell + +; Identifiers ;;;; +; Allow different highlighting for specific casings +((identifier) @type + (#lua-match? @type "^%u")) + +((identifier) @string.special.symbol + (#lua-match? @string.special.symbol "^%l")) + +((identifier) @constant + (#lua-match? @constant "^%u[%u%d_]+$")) + +; Punctuation ;;;; +[ + ";" + "," +] @punctuation.delimiter + +[ + "|" + "*" + "-" +] @operator + +"=" @keyword.operator + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket diff --git a/runtime/queries/ebnf/injections.scm b/runtime/queries/ebnf/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/ebnf/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/ecma/folds.scm b/runtime/queries/ecma/folds.scm new file mode 100644 index 000000000..a348f3444 --- /dev/null +++ b/runtime/queries/ecma/folds.scm @@ -0,0 +1,24 @@ +[ + (arguments) + (for_in_statement) + (for_statement) + (while_statement) + (arrow_function) + (function_expression) + (function_declaration) + (class_declaration) + (method_definition) + (do_statement) + (with_statement) + (switch_statement) + (switch_case) + (switch_default) + (import_statement)+ + (if_statement) + (try_statement) + (catch_clause) + (array) + (object) + (generator_function) + (generator_function_declaration) +] @fold diff --git a/runtime/queries/ecma/highlights.scm b/runtime/queries/ecma/highlights.scm new file mode 100644 index 000000000..cec2f4e3e --- /dev/null +++ b/runtime/queries/ecma/highlights.scm @@ -0,0 +1,392 @@ +; Types +; Javascript +; Variables +;----------- +(identifier) @variable + +; Properties +;----------- +(property_identifier) @variable.member + +(shorthand_property_identifier) @variable.member + +(private_property_identifier) @variable.member + +(object_pattern + (shorthand_property_identifier_pattern) @variable) + +(object_pattern + (object_assignment_pattern + (shorthand_property_identifier_pattern) @variable)) + +; Special identifiers +;-------------------- +((identifier) @type + (#lua-match? @type "^[A-Z]")) + +((identifier) @constant + (#lua-match? @constant "^_*[A-Z][A-Z%d_]*$")) + +((shorthand_property_identifier) @constant + (#lua-match? @constant "^_*[A-Z][A-Z%d_]*$")) + +((identifier) @variable.builtin + (#any-of? @variable.builtin "arguments" "module" "console" "window" "document")) + +((identifier) @type.builtin + (#any-of? @type.builtin + "Object" "Function" "Boolean" "Symbol" "Number" "Math" "Date" "String" "RegExp" "Map" "Set" + "WeakMap" "WeakSet" "Promise" "Array" "Int8Array" "Uint8Array" "Uint8ClampedArray" "Int16Array" + "Uint16Array" "Int32Array" "Uint32Array" "Float32Array" "Float64Array" "ArrayBuffer" "DataView" + "Error" "EvalError" "InternalError" "RangeError" "ReferenceError" "SyntaxError" "TypeError" + "URIError")) + +(statement_identifier) @label + +; Function and method definitions +;-------------------------------- +(function_expression + name: (identifier) @function) + +(function_declaration + name: (identifier) @function) + +(generator_function + name: (identifier) @function) + +(generator_function_declaration + name: (identifier) @function) + +(method_definition + name: [ + (property_identifier) + (private_property_identifier) + ] @function.method) + +(method_definition + name: (property_identifier) @constructor + (#eq? @constructor "constructor")) + +(pair + key: (property_identifier) @function.method + value: (function_expression)) + +(pair + key: (property_identifier) @function.method + value: (arrow_function)) + +(assignment_expression + left: (member_expression + property: (property_identifier) @function.method) + right: (arrow_function)) + +(assignment_expression + left: (member_expression + property: (property_identifier) @function.method) + right: (function_expression)) + +(variable_declarator + name: (identifier) @function + value: (arrow_function)) + +(variable_declarator + name: (identifier) @function + value: (function_expression)) + +(assignment_expression + left: (identifier) @function + right: (arrow_function)) + +(assignment_expression + left: (identifier) @function + right: (function_expression)) + +; Function and method calls +;-------------------------- +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (member_expression + property: [ + (property_identifier) + (private_property_identifier) + ] @function.method.call)) + +(call_expression + function: (await_expression + (identifier) @function.call)) + +(call_expression + function: (await_expression + (member_expression + property: [ + (property_identifier) + (private_property_identifier) + ] @function.method.call))) + +; Builtins +;--------- +((identifier) @module.builtin + (#eq? @module.builtin "Intl")) + +((identifier) @function.builtin + (#any-of? @function.builtin + "eval" "isFinite" "isNaN" "parseFloat" "parseInt" "decodeURI" "decodeURIComponent" "encodeURI" + "encodeURIComponent" "require")) + +; Constructor +;------------ +(new_expression + constructor: (identifier) @constructor) + +; Decorators +;---------- +(decorator + "@" @attribute + (identifier) @attribute) + +(decorator + "@" @attribute + (call_expression + (identifier) @attribute)) + +(decorator + "@" @attribute + (member_expression + (property_identifier) @attribute)) + +(decorator + "@" @attribute + (call_expression + (member_expression + (property_identifier) @attribute))) + +; Literals +;--------- +[ + (this) + (super) +] @variable.builtin + +((identifier) @variable.builtin + (#eq? @variable.builtin "self")) + +[ + (true) + (false) +] @boolean + +[ + (null) + (undefined) +] @constant.builtin + +[ + (comment) + (html_comment) +] @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +(hash_bang_line) @keyword.directive + +((string_fragment) @keyword.directive + (#eq? @keyword.directive "use strict")) + +(string) @string + +(template_string) @string + +(escape_sequence) @string.escape + +(regex_pattern) @string.regexp + +(regex_flags) @character.special + +(regex + "/" @punctuation.bracket) ; Regex delimiters + +(number) @number + +((identifier) @number + (#any-of? @number "NaN" "Infinity")) + +; Punctuation +;------------ +[ + ";" + "." + "," + ":" +] @punctuation.delimiter + +[ + "--" + "-" + "-=" + "&&" + "+" + "++" + "+=" + "&=" + "/=" + "**=" + "<<=" + "<" + "<=" + "<<" + "=" + "==" + "===" + "!=" + "!==" + "=>" + ">" + ">=" + ">>" + "||" + "%" + "%=" + "*" + "**" + ">>>" + "&" + "|" + "^" + "??" + "*=" + ">>=" + ">>>=" + "^=" + "|=" + "&&=" + "||=" + "??=" + "..." +] @operator + +(binary_expression + "/" @operator) + +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +(unary_expression + [ + "!" + "~" + "-" + "+" + ] @operator) + +(unary_expression + [ + "delete" + "void" + ] @keyword.operator) + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(template_substitution + [ + "${" + "}" + ] @punctuation.special) @none + +; Imports +;---------- +(namespace_import + "*" @character.special + (identifier) @module) + +(namespace_export + "*" @character.special + (identifier) @module) + +(export_statement + "*" @character.special) + +; Keywords +;---------- +[ + "if" + "else" + "switch" + "case" +] @keyword.conditional + +[ + "import" + "from" + "as" + "export" +] @keyword.import + +[ + "for" + "of" + "do" + "while" + "continue" +] @keyword.repeat + +[ + "break" + "const" + "debugger" + "extends" + "get" + "let" + "set" + "static" + "target" + "var" + "with" +] @keyword + +"class" @keyword.type + +[ + "async" + "await" +] @keyword.coroutine + +[ + "return" + "yield" +] @keyword.return + +"function" @keyword.function + +[ + "new" + "delete" + "in" + "instanceof" + "typeof" +] @keyword.operator + +[ + "throw" + "try" + "catch" + "finally" +] @keyword.exception + +(export_statement + "default" @keyword) + +(switch_default + "default" @keyword.conditional) diff --git a/runtime/queries/ecma/indents.scm b/runtime/queries/ecma/indents.scm new file mode 100644 index 000000000..d56741670 --- /dev/null +++ b/runtime/queries/ecma/indents.scm @@ -0,0 +1,82 @@ +[ + (arguments) + (array) + (binary_expression) + (class_body) + (export_clause) + (formal_parameters) + (named_imports) + (object) + (object_pattern) + (parenthesized_expression) + (return_statement) + (statement_block) + (switch_case) + (switch_default) + (switch_statement) + (template_substitution) + (ternary_expression) +] @indent.begin + +(arguments + (call_expression) @indent.begin) + +(binary_expression + (call_expression) @indent.begin) + +(expression_statement + (call_expression) @indent.begin) + +(arrow_function + body: (_) @_body + (#not-kind-eq? @_body "statement_block")) @indent.begin + +(assignment_expression + right: (_) @_right + (#not-kind-eq? @_right "arrow_function" "function")) @indent.begin + +(variable_declarator + value: (_) @_value + (#not-kind-eq? @_value "arrow_function" "call_expression" "function")) @indent.begin + +(arguments + ")" @indent.end) + +(object + "}" @indent.end) + +(statement_block + "}" @indent.end) + +[ + (arguments + (object)) + ")" + "}" + "]" +] @indent.branch + +(statement_block + "{" @indent.branch) + +((parenthesized_expression + "(" + (_) + ")" @indent.end) @_outer + (#not-has-parent? @_outer if_statement)) + +[ + "}" + "]" +] @indent.end + +(template_string) @indent.ignore + +[ + (comment) + (ERROR) +] @indent.auto + +(if_statement + consequence: (_) @indent.dedent + (#not-kind-eq? @indent.dedent statement_block)) @indent.begin diff --git a/runtime/queries/ecma/injections.scm b/runtime/queries/ecma/injections.scm new file mode 100644 index 000000000..04abafcde --- /dev/null +++ b/runtime/queries/ecma/injections.scm @@ -0,0 +1,203 @@ +(((comment) @_jsdoc_comment + (#lua-match? @_jsdoc_comment "^/[*][*][^*].*[*]/$")) @injection.content + (#set! injection.language "jsdoc")) + +((comment) @injection.content + (#set! injection.language "comment")) + +; html(`...`), html`...`, sql(`...`), etc. +(call_expression + function: (identifier) @injection.language + arguments: [ + (arguments + (template_string) @injection.content) + (template_string) @injection.content + ] + (#lua-match? @injection.language "^[a-zA-Z][a-zA-Z0-9]*$") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + ; Languages excluded from auto-injection due to special rules + ; - svg uses the html parser + ; - css uses the styled parser + (#not-any-of? @injection.language "svg" "css")) + +; svg`...` or svg(`...`) +(call_expression + function: (identifier) @_name + (#eq? @_name "svg") + arguments: [ + (arguments + (template_string) @injection.content) + (template_string) @injection.content + ] + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "html")) + +; Vercel PostgreSQL +; foo.sql`...` or foo.sql(`...`) +(call_expression + function: (member_expression + property: (property_identifier) @injection.language) + arguments: [ + (arguments + (template_string) @injection.content) + (template_string) @injection.content + ] + (#eq? @injection.language "sql") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children)) + +(call_expression + function: (identifier) @_name + (#eq? @_name "gql") + arguments: (template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "graphql")) + +(call_expression + function: (identifier) @_name + (#eq? @_name "hbs") + arguments: (template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "glimmer")) + +; css`<css>`, keyframes`<css>` +(call_expression + function: (identifier) @_name + (#any-of? @_name "css" "keyframes") + arguments: (template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "styled")) + +; styled.div`<css>` +(call_expression + function: (member_expression + object: (identifier) @_name + (#eq? @_name "styled")) + arguments: ((template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "styled"))) + +; styled(Component)`<css>` +(call_expression + function: (call_expression + function: (identifier) @_name + (#eq? @_name "styled")) + arguments: ((template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "styled"))) + +; styled.div.attrs({ prop: "foo" })`<css>` +(call_expression + function: (call_expression + function: (member_expression + object: (member_expression + object: (identifier) @_name + (#eq? @_name "styled")))) + arguments: ((template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "styled"))) + +; styled(Component).attrs({ prop: "foo" })`<css>` +(call_expression + function: (call_expression + function: (member_expression + object: (call_expression + function: (identifier) @_name + (#eq? @_name "styled")))) + arguments: ((template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "styled"))) + +((regex_pattern) @injection.content + (#set! injection.language "regex")) + +; ((comment) @_gql_comment +; (#eq? @_gql_comment "/* GraphQL */") +; (template_string) @injection.content +; (#set! injection.language "graphql")) +((template_string) @injection.content + (#lua-match? @injection.content "^`#graphql") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "graphql")) + +; el.innerHTML = `<html>` +(assignment_expression + left: (member_expression + property: (property_identifier) @_prop + (#any-of? @_prop "outerHTML" "innerHTML")) + right: (template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "html")) + +; el.innerHTML = '<html>' +(assignment_expression + left: (member_expression + property: (property_identifier) @_prop + (#any-of? @_prop "outerHTML" "innerHTML")) + right: (string + (string_fragment) @injection.content) + (#set! injection.language "html")) + +;---- Angular injections ----- +; @Component({ +; template: `<html>` +; }) +(decorator + (call_expression + function: ((identifier) @_name + (#eq? @_name "Component")) + arguments: (arguments + (object + (pair + key: ((property_identifier) @_prop + (#eq? @_prop "template")) + value: ((template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "angular"))))))) + +; @Component({ +; styles: [`<css>`] +; }) +(decorator + (call_expression + function: ((identifier) @_name + (#eq? @_name "Component")) + arguments: (arguments + (object + (pair + key: ((property_identifier) @_prop + (#eq? @_prop "styles")) + value: (array + ((template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "css")))))))) + +; @Component({ +; styles: `<css>` +; }) +(decorator + (call_expression + function: ((identifier) @_name + (#eq? @_name "Component")) + arguments: (arguments + (object + (pair + key: ((property_identifier) @_prop + (#eq? @_prop "styles")) + value: ((template_string) @injection.content + (#set! injection.include-children) + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "css"))))))) diff --git a/runtime/queries/ecma/locals.scm b/runtime/queries/ecma/locals.scm new file mode 100644 index 000000000..24ea7c0a8 --- /dev/null +++ b/runtime/queries/ecma/locals.scm @@ -0,0 +1,42 @@ +; Scopes +;------- +(statement_block) @local.scope + +(function_expression) @local.scope + +(arrow_function) @local.scope + +(function_declaration) @local.scope + +(method_definition) @local.scope + +(for_statement) @local.scope + +(for_in_statement) @local.scope + +(catch_clause) @local.scope + +; Definitions +;------------ +(variable_declarator + name: (identifier) @local.definition.var) + +(import_specifier + (identifier) @local.definition.import) + +(namespace_import + (identifier) @local.definition.import) + +(function_declaration + (identifier) @local.definition.function + (#set! definition.var.scope parent)) + +(method_definition + (property_identifier) @local.definition.function + (#set! definition.var.scope parent)) + +; References +;------------ +(identifier) @local.reference + +(shorthand_property_identifier) @local.reference diff --git a/runtime/queries/editorconfig/folds.scm b/runtime/queries/editorconfig/folds.scm new file mode 100644 index 000000000..911798f5a --- /dev/null +++ b/runtime/queries/editorconfig/folds.scm @@ -0,0 +1 @@ +(section) @fold diff --git a/runtime/queries/editorconfig/highlights.scm b/runtime/queries/editorconfig/highlights.scm new file mode 100644 index 000000000..feb0a524c --- /dev/null +++ b/runtime/queries/editorconfig/highlights.scm @@ -0,0 +1,55 @@ +(comment) @comment @spell + +(section + (section_name) @string.special.path) + +(character_choice + (character) @constant) + +(character_range + start: (character) @constant + end: (character) @constant) + +[ + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "," + ".." + (path_separator) +] @punctuation.delimiter + +[ + "-" + "=" + (negation) +] @operator + +[ + (wildcard_characters) + (wildcard_any_characters) + (wildcard_single_character) +] @character.special + +(escaped_character) @string.escape + +(pair + key: (identifier) @property + value: (_) @string) + +(boolean) @boolean + +(integer) @number + +(unset) @constant.builtin + +[ + (spelling_language) + (indent_style) + (end_of_line) + (charset) +] @string.special diff --git a/runtime/queries/editorconfig/injections.scm b/runtime/queries/editorconfig/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/editorconfig/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/eds/folds.scm b/runtime/queries/eds/folds.scm new file mode 100644 index 000000000..911798f5a --- /dev/null +++ b/runtime/queries/eds/folds.scm @@ -0,0 +1 @@ +(section) @fold diff --git a/runtime/queries/eds/highlights.scm b/runtime/queries/eds/highlights.scm new file mode 100644 index 000000000..0e008c979 --- /dev/null +++ b/runtime/queries/eds/highlights.scm @@ -0,0 +1,45 @@ +"=" @punctuation.delimiter + +[ + "[" + "]" +] @punctuation.bracket + +((section_name) @variable.builtin + (#match? @variable.builtin + "\\c^(FileInfo|DeviceInfo|DummyUsage|MandatoryObjects|OptionalObjects)$")) + +((section_name) @variable.builtin + (#lua-match? @variable.builtin "^1")) + +(section + (section_name) @_name + (#match? @_name "\\c^Comments$")) @comment + +(section + (section_name) @_name + (statement + (key) @_key) @string + (#match? @_key "\\c^ParameterName$") + (#not-match? @_name "\\c^Comments$")) + +(section + (section_name) @_name + (statement + (key) @_key) @type + (#match? @_key "\\c^(ObjectType|DataType|AccessType)$") + (#not-match? @_name "\\c^Comments$")) + +(section + (section_name) @_name + (statement + (key) @_key) @attribute + (#match? @_key "\\c^PDOMapping$") + (#not-match? @_name "\\c^Comments$")) + +(section + (section_name) @_name + (statement + (key) @_key) @number + (#match? @_key "\\c^(DefaultValue|LowLimit|HighLimit|SubNumber)$") + (#not-match? @_name "\\c^Comments$")) diff --git a/runtime/queries/eex/highlights.scm b/runtime/queries/eex/highlights.scm new file mode 100644 index 000000000..d032a7486 --- /dev/null +++ b/runtime/queries/eex/highlights.scm @@ -0,0 +1,12 @@ +[ + "%>" + "--%>" + "<%!--" + "<%" + "<%#" + "<%%=" + "<%=" +] @tag.delimiter + +; EEx comments are highlighted as such +(comment) @comment @spell diff --git a/runtime/queries/eex/injections.scm b/runtime/queries/eex/injections.scm new file mode 100644 index 000000000..f13d3c14e --- /dev/null +++ b/runtime/queries/eex/injections.scm @@ -0,0 +1,8 @@ +; EEx expressions are Elixir +((expression) @injection.content + (#set! injection.language "elixir")) + +; EEx expressions can span multiple interpolated lines +((partial_expression) @injection.content + (#set! injection.language "elixir") + (#set! injection.combined)) diff --git a/runtime/queries/elixir/folds.scm b/runtime/queries/elixir/folds.scm new file mode 100644 index 000000000..7abfe6797 --- /dev/null +++ b/runtime/queries/elixir/folds.scm @@ -0,0 +1,10 @@ +[ + (anonymous_function) + (stab_clause) + (arguments) + (block) + (do_block) + (list) + (map) + (tuple) +] @fold diff --git a/runtime/queries/elixir/highlights.scm b/runtime/queries/elixir/highlights.scm new file mode 100644 index 000000000..cbdb40de5 --- /dev/null +++ b/runtime/queries/elixir/highlights.scm @@ -0,0 +1,217 @@ +; Punctuation +[ + "," + ";" +] @punctuation.delimiter + +[ + "(" + ")" + "<<" + ">>" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +"%" @punctuation.special + +; Identifiers +(identifier) @variable + +; Unused Identifiers +((identifier) @comment + (#lua-match? @comment "^_")) + +; Comments +(comment) @comment @spell + +; Strings +(string) @string + +; Modules +(alias) @module + +; Atoms & Keywords +[ + (atom) + (quoted_atom) + (keyword) + (quoted_keyword) +] @string.special.symbol + +; Interpolation +(interpolation + [ + "#{" + "}" + ] @string.special) + +; Escape sequences +(escape_sequence) @string.escape + +; Integers +(integer) @number + +; Floats +(float) @number.float + +; Characters +[ + (char) + (charlist) +] @character + +; Booleans +(boolean) @boolean + +; Nil +(nil) @constant.builtin + +; Operators +(operator_identifier) @operator + +(unary_operator + operator: _ @operator) + +(binary_operator + operator: _ @operator) + +; Pipe Operator +(binary_operator + operator: "|>" + right: (identifier) @function) + +(dot + operator: _ @operator) + +(stab_clause + operator: _ @operator) + +; Local Function Calls +(call + target: (identifier) @function.call) + +; Remote Function Calls +(call + target: (dot + left: [ + (atom) @type + (_) + ] + right: (identifier) @function.call) + (arguments)) + +; Definition Function Calls +(call + target: ((identifier) @keyword.function + (#any-of? @keyword.function + "def" "defdelegate" "defexception" "defguard" "defguardp" "defimpl" "defmacro" "defmacrop" + "defmodule" "defn" "defnp" "defoverridable" "defp" "defprotocol" "defstruct")) + (arguments + [ + (call + (identifier) @function) + (identifier) @function + (binary_operator + left: (call + target: (identifier) @function) + operator: "when") + ])?) + +; Kernel Keywords & Special Forms +(call + target: ((identifier) @keyword + (#any-of? @keyword + "alias" "case" "catch" "cond" "else" "for" "if" "import" "quote" "raise" "receive" "require" + "reraise" "super" "throw" "try" "unless" "unquote" "unquote_splicing" "use" "with"))) + +; Special Constants +((identifier) @constant.builtin + (#any-of? @constant.builtin "__CALLER__" "__DIR__" "__ENV__" "__MODULE__" "__STACKTRACE__")) + +; Reserved Keywords +[ + "after" + "catch" + "do" + "end" + "fn" + "rescue" + "when" + "else" +] @keyword + +; Operator Keywords +[ + "and" + "in" + "not in" + "not" + "or" +] @keyword.operator + +; Capture Operator +(unary_operator + operator: "&" + operand: [ + (integer) @operator + (binary_operator + left: [ + (call + target: (dot + left: (_) + right: (identifier) @function)) + (identifier) @function + ] + operator: "/" + right: (integer) @operator) + ]) + +; Non-String Sigils +(sigil + "~" @string.special + (sigil_name) @string.special @_sigil_name + quoted_start: _ @string.special + quoted_end: _ @string.special + ((sigil_modifiers) @string.special)? + (#not-any-of? @_sigil_name "s" "S")) + +; String Sigils +(sigil + "~" @string + (sigil_name) @string @_sigil_name + quoted_start: _ @string + (quoted_content) @string + quoted_end: _ @string + ((sigil_modifiers) @string)? + (#any-of? @_sigil_name "s" "S")) + +; Module attributes +(unary_operator + operator: "@" + operand: [ + (identifier) + (call + target: (identifier)) + ] @constant) @constant + +; Documentation +(unary_operator + operator: "@" + operand: (call + target: ((identifier) @_identifier + (#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc")) @comment.documentation + (arguments + [ + (string) + (boolean) + (charlist) + (sigil + "~" @comment.documentation + (sigil_name) @comment.documentation + quoted_start: _ @comment.documentation + (quoted_content) @comment.documentation + quoted_end: _ @comment.documentation) + ] @comment.documentation))) @comment.documentation diff --git a/runtime/queries/elixir/indents.scm b/runtime/queries/elixir/indents.scm new file mode 100644 index 000000000..5470b6422 --- /dev/null +++ b/runtime/queries/elixir/indents.scm @@ -0,0 +1,25 @@ +[ + (block) + (do_block) + (list) + (map) + (stab_clause) + (tuple) + (arguments) +] @indent.begin + +[ + ")" + "]" + "after" + "catch" + "else" + "rescue" + "}" + "end" +] @indent.end @indent.branch + +; Elixir pipelines are not indented, but other binary operator chains are +((binary_operator + operator: _ @_operator) @indent.begin + (#not-eq? @_operator "|>")) diff --git a/runtime/queries/elixir/injections.scm b/runtime/queries/elixir/injections.scm new file mode 100644 index 000000000..f70fd984c --- /dev/null +++ b/runtime/queries/elixir/injections.scm @@ -0,0 +1,59 @@ +; Comments +((comment) @injection.content + (#set! injection.language "comment")) + +; Documentation +(unary_operator + operator: "@" + operand: (call + target: ((identifier) @_identifier + (#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc")) + (arguments + [ + (string + (quoted_content) @injection.content) + (sigil + (quoted_content) @injection.content) + ]) + (#set! injection.language "markdown"))) + +; HEEx +(sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content + (#any-of? @_sigil_name "H" "LVN") + (#set! injection.language "heex")) + +; Surface +(sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content + (#eq? @_sigil_name "F") + (#set! injection.language "surface")) + +; Zigler +(sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content + (#any-of? @_sigil_name "E" "L") + (#set! injection.language "eex")) + +(sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content + (#any-of? @_sigil_name "z" "Z") + (#set! injection.language "zig")) + +; Regex +(sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content + (#any-of? @_sigil_name "r" "R") + (#set! injection.language "regex")) + +; Json +(sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content + (#any-of? @_sigil_name "j" "J") + (#set! injection.language "json")) diff --git a/runtime/queries/elixir/locals.scm b/runtime/queries/elixir/locals.scm new file mode 100644 index 000000000..ac9d86e36 --- /dev/null +++ b/runtime/queries/elixir/locals.scm @@ -0,0 +1,200 @@ +; References +(identifier) @local.reference + +(alias) @local.reference + +; Module Definitions +(call + target: ((identifier) @_identifier + (#eq? @_identifier "defmodule")) + (arguments + (alias) @local.definition.type)) + +; Pattern Match Definitions +(binary_operator + ; format-ignore + left: + [ + (identifier) @local.definition.var + (_ (identifier) @local.definition.var) + (_ (_ (identifier) @local.definition.var)) + (_ (_ (_ (identifier) @local.definition.var))) + (_ (_ (_ (_ (identifier) @local.definition.var)))) + (_ (_ (_ (_ (_ (identifier) @local.definition.var))))) + (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))) + (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))))))) + ] + operator: "=") + +; Stab Clause Definitions +; format-ignore +(stab_clause + left: + [ + (arguments + [ + (identifier) @local.definition.var + (_ (identifier) @local.definition.var) + (_ (_ (identifier) @local.definition.var)) + (_ (_ (_ (identifier) @local.definition.var))) + (_ (_ (_ (_ (identifier) @local.definition.var)))) + (_ (_ (_ (_ (_ (identifier) @local.definition.var))))) + (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))) + (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))))))) + ]) + + (binary_operator + left: + (arguments + ; format-ignore + [ + (identifier) @local.definition.var + (_ (identifier) @local.definition.var) + (_ (_ (identifier) @local.definition.var)) + (_ (_ (_ (identifier) @local.definition.var))) + (_ (_ (_ (_ (identifier) @local.definition.var)))) + (_ (_ (_ (_ (_ (identifier) @local.definition.var))))) + (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))) + (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))))))) + ]) + operator: "when") + ]) + +; Aliases +; format-ignore +(call + target: + ((identifier) @_identifier + (#any-of? @_identifier "require" "alias" "use" "import")) + (arguments + [ + (alias) @local.definition.import + (_ (alias) @local.definition.import) + (_ (_ (alias) @local.definition.import)) + (_ (_ (_ (alias) @local.definition.import))) + (_ (_ (_ (_ (alias) @local.definition.import)))) + ])) + +; Local Function Definitions & Scopes +; format-ignore +(call + target: + ((identifier) @_identifier + (#any-of? @_identifier "def" "defp" "defmacro" "defmacrop" "defguard" "defguardp" "defn" "defnp" "for")) + (arguments + [ + (identifier) @local.definition.function + (binary_operator + left: (identifier) @local.definition.function + operator: "when") + (binary_operator + (identifier) @local.definition.parameter) + (call + target: (identifier) @local.definition.function + (arguments + [ + (identifier) @local.definition.parameter + (_ (identifier) @local.definition.parameter) + (_ (_ (identifier) @local.definition.parameter)) + (_ (_ (_ (identifier) @local.definition.parameter))) + (_ (_ (_ (_ (identifier) @local.definition.parameter)))) + (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))) + (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))) + (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))))))))) + ])) + ]?) + (#set! definition.function.scope parent)(do_block)?) @local.scope + +; ExUnit Test Definitions & Scopes +; format-ignore +(call + target: + ((identifier) @_identifier + (#eq? @_identifier "test")) + (arguments + [ + (string) + ((string) + . + "," + . + [ + (identifier) @local.definition.parameter + (_ (identifier) @local.definition.parameter) + (_ (_ (identifier) @local.definition.parameter)) + (_ (_ (_ (identifier) @local.definition.parameter))) + (_ (_ (_ (_ (identifier) @local.definition.parameter)))) + (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))) + (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))) + (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))))))))) + ]) + ]) + (do_block)?) @local.scope + +; Stab Clause Scopes +(stab_clause) @local.scope diff --git a/runtime/queries/elm/folds.scm b/runtime/queries/elm/folds.scm new file mode 100644 index 000000000..56987d9f9 --- /dev/null +++ b/runtime/queries/elm/folds.scm @@ -0,0 +1,14 @@ +((function_call_expr) @_fn + (#not-has-parent? @_fn parenthesized_expr)) @fold + +[ + (case_of_branch) + (case_of_expr) + (value_declaration) + (type_declaration) + (type_alias_declaration) + (list_expr) + (record_expr) + (parenthesized_expr) + (import_clause)+ +] @fold diff --git a/runtime/queries/elm/highlights.scm b/runtime/queries/elm/highlights.scm new file mode 100644 index 000000000..cfa09caf1 --- /dev/null +++ b/runtime/queries/elm/highlights.scm @@ -0,0 +1,229 @@ +[ + (line_comment) + (block_comment) +] @comment @spell + +((block_comment) @comment.documentation + (#lua-match? @comment.documentation "^{[-]|[^|]")) + +; Keywords +;--------- +[ + "if" + "then" + "else" + (case) + (of) +] @keyword.conditional + +[ + "let" + "in" + (as) + (port) + (alias) + (infix) + (module) + (type) +] @keyword + +[ + (import) + (exposing) +] @keyword.import + +; Punctuation +;------------ +(double_dot) @punctuation.special + +[ + "," + "|" + (dot) +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +; Variables +;---------- +(value_qid + (lower_case_identifier) @variable) + +(value_declaration + (function_declaration_left + (lower_case_identifier) @variable)) + +(type_annotation + (lower_case_identifier) @variable) + +(port_annotation + (lower_case_identifier) @variable) + +(anything_pattern + (underscore) @character.special) + +(record_base_identifier + (lower_case_identifier) @variable) + +(lower_pattern + (lower_case_identifier) @variable) + +(exposed_value + (lower_case_identifier) @variable) + +(value_qid + ((dot) + (lower_case_identifier) @variable.member)) + +(field_access_expr + ((dot) + (lower_case_identifier) @variable.member)) + +(function_declaration_left + (anything_pattern + (underscore) @character.special)) + +(function_declaration_left + (lower_pattern + (lower_case_identifier) @variable.parameter)) + +; Functions +;---------- +(value_declaration + functionDeclarationLeft: (function_declaration_left + (lower_case_identifier) @function + (pattern))) + +(value_declaration + functionDeclarationLeft: (function_declaration_left + (lower_case_identifier) @function + pattern: (_))) + +(value_declaration + functionDeclarationLeft: (function_declaration_left + (lower_case_identifier) @function) + body: (anonymous_function_expr)) + +(type_annotation + name: (lower_case_identifier) @function + typeExpression: (type_expression + (arrow))) + +(port_annotation + name: (lower_case_identifier) @function + typeExpression: (type_expression + (arrow))) + +(function_call_expr + target: (value_expr + (value_qid + (lower_case_identifier) @function.call))) + +; Operators +;---------- +[ + (operator_identifier) + (eq) + (colon) + (arrow) + (backslash) + "::" +] @operator + +; Modules +;-------- +(module_declaration + (upper_case_qid + (upper_case_identifier) @module)) + +(import_clause + (upper_case_qid + (upper_case_identifier) @module)) + +(as_clause + (upper_case_identifier) @module) + +(value_expr + (value_qid + (upper_case_identifier) @module)) + +; Types +;------ +(type_declaration + (upper_case_identifier) @type) + +(type_ref + (upper_case_qid + (upper_case_identifier) @type)) + +(type_variable + (lower_case_identifier) @type) + +(lower_type_name + (lower_case_identifier) @type) + +(exposed_type + (upper_case_identifier) @type) + +(type_alias_declaration + (upper_case_identifier) @type.definition) + +(field_type + name: (lower_case_identifier) @property) + +(field + name: (lower_case_identifier) @property) + +(type_declaration + (union_variant + (upper_case_identifier) @constructor)) + +(nullary_constructor_argument_pattern + (upper_case_qid + (upper_case_identifier) @constructor)) + +(union_pattern + (upper_case_qid + (upper_case_identifier) @constructor)) + +(value_expr + (upper_case_qid + (upper_case_identifier)) @constructor) + +; Literals +;--------- +(number_constant_expr + (number_literal) @number) + +(upper_case_qid + ((upper_case_identifier) @boolean + (#any-of? @boolean "True" "False"))) + +[ + (open_quote) + (close_quote) +] @string + +(string_constant_expr + (string_escape) @string) + +(string_constant_expr + (regular_string_part) @string) + +[ + (open_char) + (close_char) +] @character + +(char_constant_expr + (string_escape) @character) + +(char_constant_expr + (regular_string_part) @character) diff --git a/runtime/queries/elm/injections.scm b/runtime/queries/elm/injections.scm new file mode 100644 index 000000000..7ee6c7f03 --- /dev/null +++ b/runtime/queries/elm/injections.scm @@ -0,0 +1,8 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) + +((glsl_content) @injection.content + (#set! injection.language "glsl")) diff --git a/runtime/queries/elsa/folds.scm b/runtime/queries/elsa/folds.scm new file mode 100644 index 000000000..afdfec308 --- /dev/null +++ b/runtime/queries/elsa/folds.scm @@ -0,0 +1 @@ +(reduction) @fold diff --git a/runtime/queries/elsa/highlights.scm b/runtime/queries/elsa/highlights.scm new file mode 100644 index 000000000..1a974bda6 --- /dev/null +++ b/runtime/queries/elsa/highlights.scm @@ -0,0 +1,36 @@ +; Keywords +[ + "eval" + "let" +] @keyword + +; Function +(function) @function + +; Method +(method) @function.method + +; Parameter +(parameter) @variable.parameter + +; Variables +(identifier) @variable + +; Operators +[ + "\\" + "->" + "=" + (step) +] @operator + +; Punctuation +[ + "(" + ")" +] @punctuation.bracket + +":" @punctuation.delimiter + +; Comments +(comment) @comment @spell diff --git a/runtime/queries/elsa/indents.scm b/runtime/queries/elsa/indents.scm new file mode 100644 index 000000000..6ddd1aa64 --- /dev/null +++ b/runtime/queries/elsa/indents.scm @@ -0,0 +1,6 @@ +(reduction) @indent.begin + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/runtime/queries/elsa/injections.scm b/runtime/queries/elsa/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/elsa/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/elsa/locals.scm b/runtime/queries/elsa/locals.scm new file mode 100644 index 000000000..3e8197ae7 --- /dev/null +++ b/runtime/queries/elsa/locals.scm @@ -0,0 +1,12 @@ +[ + (source_file) + (reduction) +] @local.scope + +(identifier) @local.reference + +(function) @local.definition.function + +(method) @local.definition.method + +(parameter) @local.definition.parameter diff --git a/runtime/queries/elvish/highlights.scm b/runtime/queries/elvish/highlights.scm new file mode 100644 index 000000000..9836a6c78 --- /dev/null +++ b/runtime/queries/elvish/highlights.scm @@ -0,0 +1,157 @@ +(comment) @comment @spell + +[ + "if" + "elif" +] @keyword.conditional + +(if + (else + "else" @keyword.conditional)) + +[ + "while" + "for" +] @keyword.repeat + +(while + (else + "else" @keyword.repeat)) + +(for + (else + "else" @keyword.repeat)) + +[ + "try" + "catch" + "finally" +] @keyword.exception + +(try + (else + "else" @keyword.exception)) + +"use" @keyword.import + +(import + (bareword) @string.special.path) + +(wildcard + [ + "*" + "**" + "?" + ] @character.special) + +(command + argument: (bareword) @variable.parameter) + +(command + head: (identifier) @function.call) + +((command + head: (identifier) @keyword.return) + (#eq? @keyword.return "return")) + +((command + (identifier) @keyword.operator) + (#any-of? @keyword.operator "and" "or" "coalesce")) + +[ + "+" + "-" + "*" + "/" + "%" + "<" + "<=" + "==" + "!=" + ">" + ">=" + "<s" + "<=s" + "==s" + "!=s" + ">s" + ">=s" +] @function.builtin + +[ + ">" + "<" + ">>" + "<>" + "|" +] @operator + +(io_port) @number + +(function_definition + "fn" @keyword.function + (identifier) @function) + +(parameter_list) @variable.parameter + +(parameter_list + "|" @punctuation.bracket) + +[ + "var" + "set" + "tmp" + "del" +] @keyword + +(variable_declaration + (lhs + (identifier) @variable)) + +(variable_assignment + (lhs + (identifier) @variable)) + +(temporary_assignment + (lhs + (identifier) @variable)) + +(variable_deletion + (identifier) @variable) + +(number) @number + +(string) @string + +(variable + (identifier) @variable) + +((variable + (identifier) @function) + (#lua-match? @function ".+[~]$")) + +((variable + (identifier) @boolean) + (#any-of? @boolean "true" "false")) + +((variable + (identifier) @constant.builtin) + (#any-of? @constant.builtin + "_" "after-chdir" "args" "before-chdir" "buildinfo" "nil" "notify-bg-job-success" "num-bg-jobs" + "ok" "paths" "pid" "pwd" "value-out-indicator" "version")) + +[ + "$" + "@" +] @punctuation.special + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +";" @punctuation.delimiter diff --git a/runtime/queries/elvish/injections.scm b/runtime/queries/elvish/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/elvish/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/embedded_template/highlights.scm b/runtime/queries/embedded_template/highlights.scm new file mode 100644 index 000000000..410983d65 --- /dev/null +++ b/runtime/queries/embedded_template/highlights.scm @@ -0,0 +1,12 @@ +(comment_directive) @comment @spell + +[ + "<%#" + "<%" + "<%=" + "<%_" + "<%-" + "%>" + "-%>" + "_%>" +] @keyword diff --git a/runtime/queries/embedded_template/injections.scm b/runtime/queries/embedded_template/injections.scm new file mode 100644 index 000000000..cdeb2cd4f --- /dev/null +++ b/runtime/queries/embedded_template/injections.scm @@ -0,0 +1,7 @@ +((content) @injection.content + (#set! injection.language "html") + (#set! injection.combined)) + +((code) @injection.content + (#set! injection.language "ruby") + (#set! injection.combined)) diff --git a/runtime/queries/enforce/folds.scm b/runtime/queries/enforce/folds.scm new file mode 100644 index 000000000..dd2b8622a --- /dev/null +++ b/runtime/queries/enforce/folds.scm @@ -0,0 +1,10 @@ +[ + (block) + (switch) + (formal_parameters) + (actual_parameters) + (decl_class) + (decl_enum) + (comment_block) + (doc_block) +] @fold diff --git a/runtime/queries/enforce/highlights.scm b/runtime/queries/enforce/highlights.scm new file mode 100644 index 000000000..aa8fb9b3e --- /dev/null +++ b/runtime/queries/enforce/highlights.scm @@ -0,0 +1,190 @@ +[ + (comment_line) + (comment_block) +] @comment @spell + +[ + (doc_line) + (doc_block) +] @comment.documentation @spell + +(literal_bool) @boolean + +(literal_int) @number + +(literal_float) @number.float + +(literal_string) @string + +(escape_sequence) @string.escape + +(identifier) @variable + +(formal_parameter + name: (identifier) @variable.parameter) + +((identifier) @constant + (#lua-match? @constant "^[A-Z_][A-Z%d_]+$")) + +; Preprocessor directives +[ + (include) + (define) + (ifdef) + (ifndef) + (else) + (endif) +] @keyword.directive + +(preproc_const) @constant.macro + +; Constant fields +(decl_field + ((field_modifier) @_modifier + (#eq? @_modifier "const")) + type: (_) + name: (identifier) @constant) + +(enum_member + name: (identifier) @constant) + +[ + "+" + "-" + "*" + "/" + "%" + "^" + "++" + "--" + "=" + "+=" + "-=" + "*=" + "/=" + "&=" + "^=" + "|=" + "<<=" + ">>=" + "<" + "<=" + ">=" + ">" + "==" + "!=" + "!" + "&&" + "||" + ">>" + "<<" + "&" + "|" + "^" + "~" +] @operator + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; TODO: <> in decl_class +(types + [ + "<" + ">" + ] @punctuation.bracket) + +[ + "," + "." + ":" + ";" +] @punctuation.delimiter + +[ + "default" + "extends" +] @keyword + +[ + "new" + "delete" +] @keyword.operator + +"return" @keyword.return + +[ + "if" + "else" + "switch" + "case" +] @keyword.conditional + +[ + "while" + "for" + "foreach" + "continue" + "break" +] @keyword.repeat + +[ + "enum" + "class" + "typedef" +] @keyword.type + +[ + (variable_modifier) + (method_modifier) + (class_modifier) + (field_modifier) + (formal_parameter_modifier) +] @keyword.modifier + +"ref" @type + +(decl_class + typename: (identifier) @type) + +(decl_class + superclass: (superclass + typename: (identifier) @type)) + +(decl_enum + typename: (identifier) @type) + +(type_identifier + (identifier) @type) + +[ + "auto" + (type_primitive) +] @type.builtin + +[ + (super) + (this) +] @variable.builtin + +(literal_null) @constant.builtin + +(decl_method + name: (identifier) @function.method) + +(invokation + invoked: (identifier) @function.method.call) + +; Constructor and deconstructor (function with same name of the class) +(decl_class + typename: (identifier) @_classname + body: (class_body + (decl_method + name: (identifier) @constructor + (#eq? @constructor @_classname)))) diff --git a/runtime/queries/enforce/indents.scm b/runtime/queries/enforce/indents.scm new file mode 100644 index 000000000..b1dc79b2e --- /dev/null +++ b/runtime/queries/enforce/indents.scm @@ -0,0 +1,30 @@ +[ + (block) + (class_body) + (enum_body) + (switch_body) + (array_creation) + (formal_parameters) + (actual_parameters) +] @indent.begin + +[ + "(" + ")" + "[" + "]" + "}" +] @indent.branch + +[ + ")" + "]" + "}" +] @indent.end + +(comment_line) @indent.ignore + +[ + (ERROR) + (comment_block) +] @indent.auto diff --git a/runtime/queries/enforce/injections.scm b/runtime/queries/enforce/injections.scm new file mode 100644 index 000000000..9231a4429 --- /dev/null +++ b/runtime/queries/enforce/injections.scm @@ -0,0 +1,13 @@ +([ + (comment_block) + (comment_line) +] @injection.content + (#set! injection.language "comment")) + +([ + (doc_block) + (doc_line) +] @injection.content + (#set! injection.language "doxygen")) + +; TODO: string and print (numbered) format injection diff --git a/runtime/queries/enforce/locals.scm b/runtime/queries/enforce/locals.scm new file mode 100644 index 000000000..9f62f9d96 --- /dev/null +++ b/runtime/queries/enforce/locals.scm @@ -0,0 +1,40 @@ +; Scopes +(compilation_unit) @local.scope + +(decl_class + body: (_) @local.scope) + +(decl_enum + body: (_) @local.scope) + +(decl_method) @local.scope + +(block) @local.scope + +(if) @local.scope + +(for) @local.scope + +(foreach) @local.scope + +(while) @local.scope + +; Definitions +(decl_class + typename: (identifier) @local.definition.type) + +(decl_enum + typename: (identifier) @local.definition.enum) + +(decl_method + name: (identifier) @local.definition.method) + +(decl_variable + (_)* + (identifier) @local.definition.var) + +; References +(identifier) @local.reference + +(type_identifier + (identifier) @local.reference) diff --git a/runtime/queries/erlang/folds.scm b/runtime/queries/erlang/folds.scm new file mode 100644 index 000000000..65c2d8ed1 --- /dev/null +++ b/runtime/queries/erlang/folds.scm @@ -0,0 +1,9 @@ +[ + (fun_decl) + (anonymous_fun) + (case_expr) + (maybe_expr) + (map_expr) + (export_attribute) + (export_type_attribute) +] @fold diff --git a/runtime/queries/erlang/highlights.scm b/runtime/queries/erlang/highlights.scm new file mode 100644 index 000000000..8bba348d9 --- /dev/null +++ b/runtime/queries/erlang/highlights.scm @@ -0,0 +1,184 @@ +((atom) @constant + (#set! priority "90")) + +(var) @variable + +(char) @character + +(integer) @number + +(float) @number.float + +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[%%][%%]")) + +; keyword +[ + "fun" + "div" +] @keyword + +; bracket +[ + "(" + ")" + "{" + "}" + "[" + "]" + "#" +] @punctuation.bracket + +; Comparisons +[ + "==" + "=:=" + "=/=" + "=<" + ">=" + "<" + ">" +] @operator ; .comparison + +; operator +[ + ":" + ":=" + "!" + ; "-" + "+" + "=" + "->" + "=>" + "|" + "?=" +] @operator + +[ + "," + "." + ";" +] @punctuation.delimiter + +; conditional +[ + "receive" + "if" + "case" + "of" + "when" + "after" + "begin" + "end" + "maybe" + "else" +] @keyword.conditional + +[ + "catch" + "try" +] @keyword.exception + +((atom) @boolean + (#any-of? @boolean "true" "false")) + +; Macros +((macro_call_expr) @constant.macro + (#set! priority 101)) + +; Preprocessor +(pp_define + lhs: _ @constant.macro + (#set! priority 101)) + +(_preprocessor_directive) @keyword.directive +(#set! priority 99) + +; Attributes +(pp_include) @keyword.import + +(pp_include_lib) @keyword.import + +(export_attribute) @keyword.import + +(export_type_attribute) @type.definition + +(export_type_attribute + types: (fa + fun: _ @type + (#set! priority 101))) + +(behaviour_attribute) @keyword.import + +(module_attribute + (atom) @module) @keyword.import + +(wild_attribute + name: (attr_name + name: _ @attribute)) @attribute + +; Records +(record_expr) @type + +(record_field_expr + _ @variable.member) @type + +(record_field_name + _ @variable.member) @type + +(record_name + "#" @type + name: _ @type) @type + +(record_decl + name: _ @type) @type.definition + +(record_field + name: _ @variable.member) + +(record_field + name: _ @variable.member + ty: _ @type) + +; Type alias +(type_alias + name: _ @type) @type.definition + +(spec) @type.definition + +[ + (string) + (binary) +] @string + +; expr_function_call +(call + expr: [ + (atom) + (remote) + (var) + ] @function) + +(call + (atom) @keyword.exception + (#any-of? @keyword.exception "error" "throw" "exit")) + +; Parenthesized expression: (SomeFunc)(), only highlight the parens +(call + expr: (paren_expr + "(" @function.call + ")" @function.call)) + +; function +(external_fun) @function.call + +(internal_fun + fun: (atom) @function.call) + +(function_clause + name: (atom) @function) + +(fa + fun: (atom) @function) diff --git a/runtime/queries/erlang/injections.scm b/runtime/queries/erlang/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/erlang/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/facility/folds.scm b/runtime/queries/facility/folds.scm new file mode 100644 index 000000000..7d8bafc80 --- /dev/null +++ b/runtime/queries/facility/folds.scm @@ -0,0 +1,6 @@ +[ + (service) + (method) + (dto) + (enum) +] @fold diff --git a/runtime/queries/facility/highlights.scm b/runtime/queries/facility/highlights.scm new file mode 100644 index 000000000..592bf5311 --- /dev/null +++ b/runtime/queries/facility/highlights.scm @@ -0,0 +1,90 @@ +[ + ";" + "." + "," +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(comment) @comment @spell + +(doc_comment) @comment.documentation @spell + +[ + "service" + "errors" +] @keyword + +[ + "method" + "event" +] @keyword.function + +[ + "enum" + "data" +] @keyword.type + +"extern" @keyword.modifier + +(type) @type.builtin + +(service + service_name: (identifier) @type) + +(error_set + (identifier) @variable.member) + +(error_set + name: (identifier) @type) + +(dto + name: (identifier) @type) + +(external_dto + name: (identifier) @type) + +(enum + (values_block + (identifier) @constant)) + +(enum + name: (identifier) @type) + +(external_enum + name: (identifier) @type) + +(type + name: (identifier) @type) + +[ + "map" + "nullable" + "result" + "required" + "http" + "csharp" + "js" + "info" + "obsolete" +] @attribute.builtin + +(parameter + name: (identifier) @variable.parameter) + +(field + name: (identifier) @variable.member) + +(method + name: (identifier) @function.method) + +(number_literal) @number + +(string_literal) @string diff --git a/runtime/queries/facility/indents.scm b/runtime/queries/facility/indents.scm new file mode 100644 index 000000000..247949ba1 --- /dev/null +++ b/runtime/queries/facility/indents.scm @@ -0,0 +1,7 @@ +[ + (service_block) + (values_block) + (field_list) +] @indent.begin + +"}" @indent.branch diff --git a/runtime/queries/facility/injections.scm b/runtime/queries/facility/injections.scm new file mode 100644 index 000000000..5d9b7836f --- /dev/null +++ b/runtime/queries/facility/injections.scm @@ -0,0 +1,8 @@ +((remarks) @injection.content + (#set! injection.language "markdown")) + +([ + (comment) + (doc_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/faust/highlights.scm b/runtime/queries/faust/highlights.scm new file mode 100644 index 000000000..6e7ef1d92 --- /dev/null +++ b/runtime/queries/faust/highlights.scm @@ -0,0 +1,219 @@ +; Identifiers +(identifier) @variable + +[ + "process" + "effect" +] @variable.builtin + +(parameters + (identifier)) @variable.parameter + +(access + definition: (identifier) @variable.member) + +(global_metadata + key: (identifier) @variable.member) + +(function_metadata + function_name: (identifier) @variable.member) + +; Literals +(_ + filename: (string)) @string.special.path + +(documentation) @string.documentation @spell + +[ + (string) + (fstring) +] @string + +(int) @number + +(real) @number.float + +; Types +(_ + type: [ + (int_type) + (float_type) + (any_type) + ]) @type.builtin + +[ + (single_precision) + (double_precision) + (quad_precision) + (fixed_point_precision) +] @attribute + +; Functions +(function_definition + name: (identifier) @function) + +(function_names) @function + +(function_call + (identifier) @function.call) + +(function_call + (access + definition: (identifier) @function.call)) + +[ + "exp" + "log" + "log10" + "sqrt" + "abs" + "floor" + "ceil" + "rint" + "round" + "acos" + "asin" + "atan" + "cos" + "sin" + "tan" + "atan2" + "int" + "float" + "pow" + "min" + "max" + "fmod" + "remainder" + "prefix" + "attach" + "enable" + "control" + "rdtable" + "rwtable" + "select2" + "select3" + "lowest" + "highest" + "assertbounds" + (par) + (seq) + (sum) + (prod) + (component) + (library) + (vslider_type) + (hslider_type) + (nentry_type) + (vbargraph_type) + (hbargraph_type) + (vgroup_type) + (hgroup_type) + (tgroup_type) + "button" + "checkbox" + "soundfile" + "inputs" + "outputs" + "route" +] @function.builtin + +; xor is a @keyword.operator +[ + (add) + (sub) + (mult) + (div) + (mod) + (pow) + (or) + (and) + (lshift) + (rshift) + (lt) + (le) + (gt) + (ge) + (eq) + (neq) + (delay) + (one_sample_delay) + "=" + "=>" + "->" +] @operator + +(recursive + "~" @operator) + +(sequential + ":" @operator) + +(split + "<:" @operator) + +(merge + ":>" @operator) + +(parallel + "," @operator) + +; Keywords +[ + (par) + (seq) + (sum) + (prod) +] @keyword.repeat + +(file_import + "import" @keyword.import) + +[ + (wire) + (cut) + (mem) + "declare" + "with" + "environment" + "case" + "ffunction" + "fconstant" + "fvariable" +] @keyword + +(xor) @keyword.operator + +; Punctuation +[ + "," + ";" + "." +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; Comments +(comment) @comment @spell + +; Tags +[ + "<mdoc>" + "</mdoc>" + "<metadata>" + "</metadata>" + "<equation>" + "</equation>" + "<diagram>" + "</diagram>" + "<listing" + "<notice" + "/>" +] @tag diff --git a/runtime/queries/faust/injections.scm b/runtime/queries/faust/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/faust/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/fennel/folds.scm b/runtime/queries/fennel/folds.scm new file mode 100644 index 000000000..0862e5926 --- /dev/null +++ b/runtime/queries/fennel/folds.scm @@ -0,0 +1,51 @@ +; compounds +[ + (list) + (table) + (sequence) +] @fold + +; sub-forms / special compounds +[ + (list_binding) + (table_binding) + (sequence_binding) + (table_metadata) + (sequence_arguments) + (let_vars) + (case_guard_or_special) + (case_guard) + (case_catch) +] @fold + +; forms +[ + (quote_form) + (unquote_form) + (local_form) + (var_form) + (set_form) + (global_form) + (let_form) + (fn_form) + (lambda_form) + (hashfn_form) + (each_form) + (collect_form) + (icollect_form) + (accumulate_form) + (for_form) + (fcollect_form) + (faccumulate_form) + (case_form) + (match_form) + (case_try_form) + (match_try_form) +] @fold + +; reader macros +(quote_reader_macro + expression: (_) @fold) + +(quasi_quote_reader_macro + expression: (_) @fold) diff --git a/runtime/queries/fennel/highlights.scm b/runtime/queries/fennel/highlights.scm new file mode 100644 index 000000000..2f0b5f738 --- /dev/null +++ b/runtime/queries/fennel/highlights.scm @@ -0,0 +1,193 @@ +; Most primitive nodes +(shebang) @keyword.directive + +(comment) @comment @spell + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + (nil) + (nil_binding) +] @constant.builtin + +[ + (boolean) + (boolean_binding) +] @boolean + +[ + (number) + (number_binding) +] @number + +[ + (string) + (string_binding) +] @string + +[ + (symbol) + (symbol_binding) +] @variable + +(symbol_option) @keyword.directive + +(escape_sequence) @string.escape + +(multi_symbol + "." @punctuation.delimiter + member: (symbol_fragment) @variable.member) + +(list + call: (symbol) @function.call) + +(list + call: (multi_symbol + member: (symbol_fragment) @function.call .)) + +(multi_symbol_method + ":" @punctuation.delimiter + method: (symbol_fragment) @function.method.call) + +(quasi_quote_reader_macro + macro: _ @punctuation.special) + +(quote_reader_macro + macro: _ @punctuation.special) + +(unquote_reader_macro + macro: _ @punctuation.special) + +(hashfn_reader_macro + macro: _ @keyword.function) + +(sequence_arguments + (symbol_binding) @variable.parameter) + +(sequence_arguments + (rest_binding + rhs: (symbol_binding) @variable.parameter)) + +(docstring) @string.documentation + +(fn_form + name: [ + (symbol) @function + (multi_symbol + member: (symbol_fragment) @function .) + ]) + +(lambda_form + name: [ + (symbol) @function + (multi_symbol + member: (symbol_fragment) @function .) + ]) + +; NOTE: The macro name is highlighted as @variable because it +; gives a nicer contrast instead of everything being the same +; color. Rust queries use this workaround too for `macro_rules!`. +(macro_form + name: [ + (symbol) @variable + (multi_symbol + member: (symbol_fragment) @variable .) + ]) + +((symbol) @variable.parameter + (#any-of? @variable.parameter "$" "$...")) + +((symbol) @variable.parameter + (#lua-match? @variable.parameter "^%$[1-9]$")) + +((symbol) @operator + (#any-of? @operator + ; arithmetic + "+" "-" "*" "/" "//" "%" "^" + ; comparison + ">" "<" ">=" "<=" "=" "~=" + ; other + "#" "." "?." "..")) + +((symbol) @keyword.operator + (#any-of? @keyword.operator + ; comparison + "not=" + ; boolean + "and" "or" "not" + ; bitwise + "lshift" "rshift" "band" "bor" "bxor" "bnot" + ; other + "length")) + +(case_guard + call: (_) @keyword.conditional) + +(case_guard_or_special + call: (_) @keyword.conditional) + +((symbol) @keyword.function + (#any-of? @keyword.function "fn" "lambda" "λ" "hashfn")) + +((symbol) @keyword.repeat + (#any-of? @keyword.repeat "for" "each" "while")) + +((symbol) @keyword.conditional + (#any-of? @keyword.conditional "if" "when" "match" "case" "match-try" "case-try")) + +((symbol) @keyword + (#any-of? @keyword + "global" "local" "let" "set" "var" "comment" "do" "doc" "eval-compiler" "lua" "macros" "unquote" + "quote" "tset" "values" "tail!")) + +((symbol) @keyword.import + (#any-of? @keyword.import "require-macros" "import-macros" "include")) + +((symbol) @function.macro + (#any-of? @function.macro + "collect" "icollect" "fcollect" "accumulate" "faccumulate" "->" "->>" "-?>" "-?>>" "?." "doto" + "macro" "macrodebug" "partial" "pick-args" "pick-values" "with-open")) + +(case_catch + call: (symbol) @keyword) + +(import_macros_form + imports: (table_binding + (table_binding_pair + value: (symbol_binding) @function.macro))) + +; TODO: Highlight builtin methods (`table.unpack`, etc) as @function.builtin +([ + (symbol) @module.builtin + (multi_symbol + base: (symbol_fragment) @module.builtin) +] + (#any-of? @module.builtin + "vim" "_G" "debug" "io" "jit" "math" "os" "package" "string" "table" "utf8")) + +([ + (symbol) @variable.builtin + (multi_symbol + . + (symbol_fragment) @variable.builtin) +] + (#eq? @variable.builtin "arg")) + +((symbol) @variable.builtin + (#eq? @variable.builtin "...")) + +((symbol) @constant.builtin + (#eq? @constant.builtin "_VERSION")) + +((symbol) @function.builtin + (#any-of? @function.builtin + "assert" "collectgarbage" "dofile" "error" "getmetatable" "ipairs" "load" "loadfile" "next" + "pairs" "pcall" "print" "rawequal" "rawget" "rawlen" "rawset" "require" "select" "setmetatable" + "tonumber" "tostring" "type" "warn" "xpcall" "module" "setfenv" "loadstring" "unpack")) diff --git a/runtime/queries/fennel/injections.scm b/runtime/queries/fennel/injections.scm new file mode 100644 index 000000000..f6724d328 --- /dev/null +++ b/runtime/queries/fennel/injections.scm @@ -0,0 +1,134 @@ +((comment_body) @injection.content + (#set! injection.language "comment")) + +(list + call: (multi_symbol) @_vimcmd_identifier + (#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec2") + . + item: (string + (string_content) @injection.content + (#set! injection.language "vim"))) + +; NOTE: Matches *exactly* `ffi.cdef` +(list + call: (multi_symbol) @_cdef_identifier + (#eq? @_cdef_identifier "ffi.cdef") + . + item: (string + (string_content) @injection.content + (#set! injection.language "c"))) + +(list + call: (multi_symbol) @_ts_query_identifier + (#any-of? @_ts_query_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse") + . + item: (_) + . + item: (_) + . + item: (string + (string_content) @injection.content + (#set! injection.language "query"))) + +(list + call: (multi_symbol) @_vimcmd_identifier + (#eq? @_vimcmd_identifier "vim.api.nvim_create_autocmd") + . + item: (_) + . + item: (table + (table_pair + key: (string + (string_content) @_command + (#eq? @_command "command")) + value: (string + (string_content) @injection.content + (#set! injection.language "vim"))))) + +(list + call: (multi_symbol) @_user_cmd + (#eq? @_user_cmd "vim.api.nvim_create_user_command") + . + item: (_) + . + item: (string + (string_content) @injection.content + (#set! injection.language "vim"))) + +(list + call: (multi_symbol) @_user_cmd + (#eq? @_user_cmd "vim.api.nvim_buf_create_user_command") + . + item: (_) + . + item: (_) + . + item: (string + (string_content) @injection.content + (#set! injection.language "vim"))) + +(list + call: (multi_symbol) @_map + (#any-of? @_map "vim.api.nvim_set_keymap" "vim.keymap.set") + . + item: (_) + . + item: (_) + . + item: (string + (string_content) @injection.content + (#set! injection.language "vim"))) + +(list + call: (multi_symbol) @_map + (#eq? @_map "vim.api.nvim_buf_set_keymap") + . + item: (_) + . + item: (_) + . + item: (_) + . + item: (string + (string_content) @injection.content + (#set! injection.language "vim"))) + +; highlight string as query if starts with `; query` +(string + (string_content) @injection.content + (#lua-match? @injection.content "^%s*;+%s?query") + (#set! injection.language "query")) + +; (string.match "123" "%d+") +(list + call: (multi_symbol + member: (symbol_fragment) @_func + . + (#any-of? @_func "find" "match" "gmatch" "gsub")) + . + item: (_) + . + item: (string + (string_content) @injection.content + (#set! injection.language "luap") + (#set! injection.include-children))) + +; (my-string:match "%d+") +(list + call: (multi_symbol_method + method: (symbol_fragment) @_method + (#any-of? @_method "find" "match" "gmatch" "gsub")) + . + item: (string + (string_content) @injection.content + (#set! injection.language "luap") + (#set! injection.include-children))) + +; (string.format "pi = %.2f" 3.14159) +(list + call: (multi_symbol) @_func + (#eq? @_func "string.format") + . + item: (string + (string_content) @injection.content + (#set! injection.language "printf"))) diff --git a/runtime/queries/fennel/locals.scm b/runtime/queries/fennel/locals.scm new file mode 100644 index 000000000..be63e728f --- /dev/null +++ b/runtime/queries/fennel/locals.scm @@ -0,0 +1,56 @@ +(program) @local.scope + +(symbol) @local.reference + +[ + (let_form) + (fn_form) + (lambda_form) + (each_form) + (for_form) + (collect_form) + (icollect_form) + (accumulate_form) + (for_form) + (fcollect_form) + (faccumulate_form) + (case_form) + (match_form) + (case_try_form) + (match_try_form) + (if_form) +] @local.scope + +(list + call: (symbol) @_call + (#any-of? @_call "while" "when" "do")) @local.scope + +(fn_form + name: [ + (symbol) @local.definition.function + (multi_symbol + member: (symbol_fragment) @local.definition.function .) + ] + args: (sequence_arguments + (symbol_binding) @local.definition.parameter) + (#set! definition.function.scope "parent")) + +(lambda_form + name: [ + (symbol) @local.definition.function + (multi_symbol + member: (symbol_fragment) @local.definition.function .) + ] + args: (sequence_arguments + (symbol_binding) @local.definition.parameter) + (#set! definition.function.scope "parent")) + +(macro_form + name: [ + (symbol) @local.definition.function + (multi_symbol + member: (symbol_fragment) @local.definition.function .) + ] + args: (sequence_arguments + (symbol_binding) @local.definition.parameter) + (#set! definition.function.scope "parent")) diff --git a/runtime/queries/fidl/folds.scm b/runtime/queries/fidl/folds.scm new file mode 100644 index 000000000..f524c455b --- /dev/null +++ b/runtime/queries/fidl/folds.scm @@ -0,0 +1,6 @@ +[ + (layout_declaration) + (protocol_declaration) + (resource_declaration) + (service_declaration) +] @fold diff --git a/runtime/queries/fidl/highlights.scm b/runtime/queries/fidl/highlights.scm new file mode 100644 index 000000000..f1960c612 --- /dev/null +++ b/runtime/queries/fidl/highlights.scm @@ -0,0 +1,67 @@ +[ + "ajar" + "alias" + "as" + "bits" + "closed" + "compose" + "const" + "error" + "flexible" + "library" + "open" + ; "optional" we did not specify a node for optional yet + "overlay" + "protocol" + "reserved" + "strict" + "using" +] @keyword + +[ + "enum" + "struct" + "table" + "union" + "resource" + "service" + "type" +] @keyword.type + +(primitives_type) @type.builtin + +(builtin_complex_type) @type.builtin + +(const_declaration + (identifier) @constant) + +[ + "=" + "|" + "&" + "->" +] @operator + +(attribute + "@" @attribute + (identifier) @attribute) + +(string_literal) @string + +(numeric_literal) @number + +[ + (true) + (false) +] @boolean + +(comment) @comment + +[ + "(" + ")" + "<" + ">" + "{" + "}" +] @punctuation.bracket diff --git a/runtime/queries/fidl/injections.scm b/runtime/queries/fidl/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/fidl/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/firrtl/folds.scm b/runtime/queries/firrtl/folds.scm new file mode 100644 index 000000000..4c64e644f --- /dev/null +++ b/runtime/queries/firrtl/folds.scm @@ -0,0 +1,6 @@ +[ + (circuit) + (module) + (when) + (else) +] @fold diff --git a/runtime/queries/firrtl/highlights.scm b/runtime/queries/firrtl/highlights.scm new file mode 100644 index 000000000..0a90fa55b --- /dev/null +++ b/runtime/queries/firrtl/highlights.scm @@ -0,0 +1,198 @@ +; Namespaces +(circuit + (identifier) @module) + +(module + (identifier) @module) + +; Types +((identifier) @type + (#lua-match? @type "^[A-Z][A-Za-z0-9_$]*$")) + +; Keywords +[ + "circuit" + "module" + "extmodule" + "flip" + "parameter" + "reset" + "wire" + "cmem" + "smem" + "mem" + "reg" + "with" + "mport" + "inst" + "of" + "node" + "is" + "invalid" + "skip" + "infer" + "read" + "write" + "rdwr" + "defname" +] @keyword + +; Qualifiers +(qualifier) @keyword.modifier + +; Storageclasses +[ + "input" + "output" +] @keyword.modifier + +; Conditionals +[ + "when" + "else" +] @keyword.conditional + +; Annotations +(info) @attribute + +; Builtins +[ + "stop" + "printf" + "assert" + "assume" + "cover" + "attach" + "mux" + "validif" +] @function.builtin + +[ + "UInt" + "SInt" + "Analog" + "Fixed" + "Clock" + "AsyncReset" + "Reset" +] @type.builtin + +; Fields +[ + "data-type" + "depth" + "read-latency" + "write-latency" + "read-under-write" + "reader" + "writer" + "readwriter" +] @variable.member + +((field_id) @variable.member + (#set! priority 105)) + +(port + (identifier) @variable.member) + +(wire + (identifier) @variable.member) + +(cmem + (identifier) @variable.member) + +(smem + (identifier) @variable.member) + +(memory + (identifier) @variable.member) + +(register + (identifier) @variable.member) + +; Parameters +(primitive_operation + (identifier) @variable.parameter) + +(mux + (identifier) @variable.parameter) + +(printf + (identifier) @variable.parameter) + +(reset + (identifier) @variable.parameter) + +(stop + (identifier) @variable.parameter) + +; Variables +(identifier) @variable + +; Operators +(primop) @keyword.operator + +[ + "+" + "-" + "=" + "=>" + "<=" + "<-" +] @operator + +; Literals +[ + (uint) + (number) +] @number + +(number_str) @string.special + +(double) @number.float + +(string) @string + +(escape_sequence) @string.escape + +[ + "old" + "new" + "undefined" +] @constant.builtin + +; Punctuation +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "<" + ">" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "," + "." + ":" +] @punctuation.delimiter + +; Comments +(comment) @comment @spell + +[ + "=>" + "<=" + "=" +] @operator diff --git a/runtime/queries/firrtl/indents.scm b/runtime/queries/firrtl/indents.scm new file mode 100644 index 000000000..e172e1e81 --- /dev/null +++ b/runtime/queries/firrtl/indents.scm @@ -0,0 +1,12 @@ +[ + (circuit) + (module) + (memory) + (when) + (else) +] @indent.begin + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/runtime/queries/firrtl/injections.scm b/runtime/queries/firrtl/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/firrtl/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/firrtl/locals.scm b/runtime/queries/firrtl/locals.scm new file mode 100644 index 000000000..97b7931bf --- /dev/null +++ b/runtime/queries/firrtl/locals.scm @@ -0,0 +1,45 @@ +; Scopes +[ + (source_file) + (circuit) + (module) + (else) + (when) +] @local.scope + +; References +(identifier) @local.reference + +; Definitions +(port + (identifier) @local.definition.field) + +(wire + (identifier) @local.definition.field) + +(cmem + (identifier) @local.definition.field) + +(smem + (identifier) @local.definition.field) + +(memory + (identifier) @local.definition.field) + +(register + (identifier) @local.definition.field) + +(circuit + (identifier) @local.definition.namespace) + +(module + (identifier) @local.definition.namespace) + +(parameter + (identifier) @local.definition.parameter) + +(rdwr + (identifier) @local.definition.var) + +(node + (identifier) @local.definition.var) diff --git a/runtime/queries/fish/folds.scm b/runtime/queries/fish/folds.scm new file mode 100644 index 000000000..06363e15e --- /dev/null +++ b/runtime/queries/fish/folds.scm @@ -0,0 +1,8 @@ +[ + (function_definition) + (if_statement) + (switch_statement) + (for_statement) + (while_statement) + (begin_statement) +] @fold diff --git a/runtime/queries/fish/highlights.scm b/runtime/queries/fish/highlights.scm new file mode 100644 index 000000000..a7c451175 --- /dev/null +++ b/runtime/queries/fish/highlights.scm @@ -0,0 +1,204 @@ +; Fish highlighting +; Operators +[ + "&&" + "||" + "|" + "&|" + "2>|" + "&" + ".." + "!" + (direction) + (stream_redirect) +] @operator + +; match operators of test command +(command + name: (word) @function.builtin + (#eq? @function.builtin "test") + argument: (word) @operator + (#match? @operator "^(!?\\=|-[a-zA-Z]+)$")) + +; match operators of [ command +(command + name: (word) @punctuation.bracket + (#eq? @punctuation.bracket "[") + argument: (word) @operator + (#match? @operator "^(!?\\=|-[a-zA-Z]+)$")) + +[ + "not" + "and" + "or" +] @keyword.operator + +; Conditionals +(if_statement + [ + "if" + "end" + ] @keyword.conditional) + +(switch_statement + [ + "switch" + "end" + ] @keyword.conditional) + +(case_clause + "case" @keyword.conditional) + +(else_clause + "else" @keyword.conditional) + +(else_if_clause + [ + "else" + "if" + ] @keyword.conditional) + +; Loops/Blocks +(while_statement + [ + "while" + "end" + ] @keyword.repeat) + +(for_statement + [ + "for" + "end" + ] @keyword.repeat) + +(begin_statement + [ + "begin" + "end" + ] @keyword.repeat) + +; Keywords +[ + "in" + (break) + (continue) +] @keyword + +"return" @keyword.return + +; Punctuation +[ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket + +"," @punctuation.delimiter + +; Commands +(command + argument: [ + (word) @variable.parameter + (#lua-match? @variable.parameter "^[-]") + ]) + +(command_substitution + "$" @punctuation.special) + +; non-builtin command names +(command + name: (word) @function.call) + +; derived from builtin -n (fish 3.2.2) +(command + name: [ + (word) @function.builtin + (#any-of? @function.builtin + "." ":" "_" "alias" "argparse" "bg" "bind" "block" "breakpoint" "builtin" "cd" "command" + "commandline" "complete" "contains" "count" "disown" "echo" "emit" "eval" "exec" "exit" "fg" + "functions" "history" "isatty" "jobs" "math" "printf" "pwd" "random" "read" "realpath" "set" + "set_color" "source" "status" "string" "test" "time" "type" "ulimit" "wait") + ]) + +; Functions +(function_definition + [ + "function" + "end" + ] @keyword.function) + +(function_definition + name: [ + (word) + (concatenation) + ] @function) + +(function_definition + option: [ + (word) + (concatenation + (word)) + ] @variable.parameter + (#lua-match? @variable.parameter "^[-]")) + +; Strings +[ + (double_quote_string) + (single_quote_string) +] @string + +(escape_sequence) @string.escape + +; Variables +(variable_name) @variable + +(variable_expansion) @constant + +(variable_expansion + "$" @punctuation.special) @none + +; Reference: https://fishshell.com/docs/current/language.html#special-variables +((variable_name) @variable.builtin + (#any-of? @variable.builtin + "PATH" "CDPATH" "LANG" "LC_ALL" "LC_COLLATE" "LC_CTYPE" "LC_MESSAGES" "LC_MONETARY" "LC_NUMERIC" + "LC_TIME" "fish_color_normal" "fish_color_command" "fish_color_keyword" "fish_color_keyword" + "fish_color_redirection" "fish_color_end" "fish_color_error" "fish_color_param" + "fish_color_valid_path" "fish_color_option" "fish_color_comment" "fish_color_selection" + "fish_color_operator" "fish_color_escape" "fish_color_autosuggestion" "fish_color_cwd" + "fish_color_cwd_root" "fish_color_user" "fish_color_host" "fish_color_host_remote" + "fish_color_status" "fish_color_cancel" "fish_color_search_match" "fish_color_history_current" + "fish_pager_color_progress" "fish_pager_color_background" "fish_pager_color_prefix" + "fish_pager_color_completion" "fish_pager_color_description" + "fish_pager_color_selected_background" "fish_pager_color_selected_prefix" + "fish_pager_color_selected_completion" "fish_pager_color_selected_description" + "fish_pager_color_secondary_background" "fish_pager_color_secondary_prefix" + "fish_pager_color_secondary_completion" "fish_pager_color_secondary_description" + "fish_term24bit" "fish_term256" "fish_ambiguous_width" "fish_emoji_width" + "fish_autosuggestion_enabled" "fish_handle_reflow" "fish_key_bindings" "fish_escape_delay_ms" + "fish_sequence_key_delay_ms" "fish_complete_path" "fish_cursor_selection_mode" + "fish_function_path" "fish_greeting" "fish_history" "fish_trace" "FISH_DEBUG" + "FISH_DEBUG_OUTPUT" "fish_user_paths" "umask" "BROWSER" "_" "argv" "CMD_DURATION" "COLUMNS" + "LINES" "fish_kill_signal" "fish_killring" "fish_read_limit" "fish_pid" "history" "HOME" + "hostname" "IFS" "last_pid" "PWD" "pipestatus" "SHLVL" "status" "status_generation" "TERM" + "USER" "EUID" "version" "FISH_VERSION")) + +; Nodes +[ + (integer) + (float) +] @number + +(comment) @comment + +(comment) @spell + +((word) @boolean + (#any-of? @boolean "true" "false")) + +((program + . + (comment) @keyword.directive @nospell) + (#lua-match? @keyword.directive "^#!/")) diff --git a/runtime/queries/fish/indents.scm b/runtime/queries/fish/indents.scm new file mode 100644 index 000000000..4984c4cb2 --- /dev/null +++ b/runtime/queries/fish/indents.scm @@ -0,0 +1,18 @@ +[ + (function_definition) + (while_statement) + (for_statement) + (if_statement) + (begin_statement) + (switch_statement) +] @indent.begin + +[ + "else" ; else and else if must both start the line with "else", so tag the string directly + "case" + "end" +] @indent.branch + +"end" @indent.end + +(comment) @indent.ignore diff --git a/runtime/queries/fish/injections.scm b/runtime/queries/fish/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/fish/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/fish/locals.scm b/runtime/queries/fish/locals.scm new file mode 100644 index 000000000..904d568f9 --- /dev/null +++ b/runtime/queries/fish/locals.scm @@ -0,0 +1,19 @@ +; Scopes +[ + (command) + (function_definition) + (if_statement) + (for_statement) + (begin_statement) + (while_statement) + (switch_statement) +] @local.scope + +; Definitions +(function_definition + name: (word) @local.definition.function) + +; References +(variable_name) @local.reference + +(word) @local.reference diff --git a/runtime/queries/foam/folds.scm b/runtime/queries/foam/folds.scm new file mode 100644 index 000000000..e05d0dbaa --- /dev/null +++ b/runtime/queries/foam/folds.scm @@ -0,0 +1,8 @@ +[ + (comment) + (list) + (dict_core) +] @fold + +(code + (code_body)* @fold) diff --git a/runtime/queries/foam/highlights.scm b/runtime/queries/foam/highlights.scm new file mode 100644 index 000000000..9c96f196e --- /dev/null +++ b/runtime/queries/foam/highlights.scm @@ -0,0 +1,64 @@ +; Comments +(comment) @comment @spell + +; Generic Key-value pairs and dictionary keywords +(key_value + keyword: (identifier) @function) + +(dict + key: (identifier) @type) + +; Macros +(macro + "$" @keyword.conditional + (prev_scope)* @keyword.conditional + (identifier)* @module) + +; Directives +"#" @keyword.conditional + +(preproc_call + directive: (identifier)* @keyword.conditional + argument: (identifier)* @module) + +((preproc_call + argument: (identifier)* @module) @keyword.conditional + (#eq? @keyword.conditional "ifeq")) + +((preproc_call) @keyword.conditional + (#any-of? @keyword.conditional "else" "endif")) + +; Literals +(number_literal) @number.float + +(string_literal) @string + +(escape_sequence) @string.escape + +(boolean) @boolean + +; Treat [m^2 s^-2] the same as if it was put in numbers format +(dimensions + dimension: (identifier) @number.float) + +; Punctuation +[ + "(" + ")" + "[" + "]" + "{" + "}" + "#{" + "#}" + "|-" + "-|" + "<!--(" + ")-->" + "$$" +] @punctuation.bracket + +";" @punctuation.delimiter + +((identifier) @constant.builtin + (#any-of? @constant.builtin "uniform" "non-uniform" "and" "or")) diff --git a/runtime/queries/foam/indents.scm b/runtime/queries/foam/indents.scm new file mode 100644 index 000000000..be02b80ed --- /dev/null +++ b/runtime/queries/foam/indents.scm @@ -0,0 +1,11 @@ +[ + "{" + "}" +] @indent.branch + +[ + (dict) + (key_value) +] @indent.begin + +(comment) @indent.ignore diff --git a/runtime/queries/foam/injections.scm b/runtime/queries/foam/injections.scm new file mode 100644 index 000000000..b9f8f838f --- /dev/null +++ b/runtime/queries/foam/injections.scm @@ -0,0 +1,23 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; Pass code blocks to Cpp highlighter +(code + (code_body) @injection.content + (#set! injection.language "cpp")) + +; Pass identifiers to Go highlighter (Cheating I know) +; ((identifier) @injection.content +; (#set! injection.language "lua") +; Highlight regex syntax inside literal strings +((string_literal) @injection.content + (#set! injection.language "regex")) + +; Highlight PyFoam syntax as Python statements +(pyfoam_variable + code_body: (_) @injection.content + (#set! injection.language "python")) + +(pyfoam_expression + code_body: (_) @injection.content + (#set! injection.language "python")) diff --git a/runtime/queries/foam/locals.scm b/runtime/queries/foam/locals.scm new file mode 100644 index 000000000..f3f689081 --- /dev/null +++ b/runtime/queries/foam/locals.scm @@ -0,0 +1,11 @@ +(dict) @local.scope + +(dict + key: (_) @local.definition.type) + +(key_value + keyword: (_) @local.definition.parameter) + +(key_value + value: (macro + (identifier)*)* @local.reference) diff --git a/runtime/queries/forth/folds.scm b/runtime/queries/forth/folds.scm new file mode 100644 index 000000000..443abb30d --- /dev/null +++ b/runtime/queries/forth/folds.scm @@ -0,0 +1 @@ +(word_definition) @fold diff --git a/runtime/queries/forth/highlights.scm b/runtime/queries/forth/highlights.scm new file mode 100644 index 000000000..1e7207597 --- /dev/null +++ b/runtime/queries/forth/highlights.scm @@ -0,0 +1,19 @@ +(core) @function + +(operator) @operator + +(word) @variable + +((word) @constant + (#lua-match? @constant "^[A-Z_]+$")) + +(number) @number + +(string) @string + +[ + (start_definition) + (end_definition) +] @punctuation.delimiter + +(comment) @comment @spell diff --git a/runtime/queries/forth/indents.scm b/runtime/queries/forth/indents.scm new file mode 100644 index 000000000..067755433 --- /dev/null +++ b/runtime/queries/forth/indents.scm @@ -0,0 +1,3 @@ +(word_definition) @indent.begin + +(end_definition) @indent.end @indent.branch diff --git a/runtime/queries/forth/injections.scm b/runtime/queries/forth/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/forth/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/forth/locals.scm b/runtime/queries/forth/locals.scm new file mode 100644 index 000000000..d91d3aa98 --- /dev/null +++ b/runtime/queries/forth/locals.scm @@ -0,0 +1,3 @@ +(word) @local.reference + +(word_definition) @local.scope diff --git a/runtime/queries/fortran/folds.scm b/runtime/queries/fortran/folds.scm new file mode 100644 index 000000000..cedbdb635 --- /dev/null +++ b/runtime/queries/fortran/folds.scm @@ -0,0 +1,11 @@ +; by @oponkork +[ + (if_statement) + (where_statement) + (enum_statement) + (do_loop_statement) + (derived_type_definition) + (function) + (subroutine) + (interface) +] @fold diff --git a/runtime/queries/fortran/highlights.scm b/runtime/queries/fortran/highlights.scm new file mode 100644 index 000000000..6a6dbba35 --- /dev/null +++ b/runtime/queries/fortran/highlights.scm @@ -0,0 +1,319 @@ +; Preprocs +(preproc_directive) @keyword.directive + +; Namespaces +(program_statement + (name) @module) + +(end_program_statement + (name) @module) + +(module_statement + (name) @module) + +(end_module_statement + (name) @module) + +(submodule_statement + (name) @module) + +(end_submodule_statement + (name) @module) + +; Includes +[ + "import" + "include" + "use" +] @keyword.import + +(import_statement + "," + [ + "all" + "none" + ] @keyword) + +; Attributes +[ + (none) + "implicit" + "intent" +] @attribute + +(implicit_statement + "type" @attribute) + +; Keywords +[ + "attributes" + "associate" + "block" + "classis" + "contains" + "default" + "dimension" + "endassociate" + "endselect" + "enumerator" + "equivalence" + "extends" + "goto" + "intrinsic" + "non_intrinsic" + "namelist" + "parameter" + "quiet" + "rank" + "save" + "selectcase" + "selectrank" + "selecttype" + "sequence" + "stop" + "target" + "typeis" +] @keyword + +[ + "class" + "enum" + "endenum" + "type" + "endtype" + "module" + "endmodule" + "submodule" + "endsubmodule" + "interface" + "endinterface" +] @keyword.type + +(default) @keyword + +; Types +(type_name) @type + +(intrinsic_type) @type.builtin + +; Qualifiers +[ + "abstract" + "allocatable" + "automatic" + "constant" + "contiguous" + "data" + "deferred" + "device" + "external" + "family" + "final" + "generic" + "global" + "grid_global" + "host" + "initial" + "local" + "local_init" + "managed" + "nopass" + "non_overridable" + "optional" + "pass" + "pinned" + "pointer" + "private" + "property" + "protected" + "public" + "shared" + "static" + "texture" + "value" + "volatile" + (procedure_qualifier) +] @keyword.modifier + +[ + "common" + "in" + "inout" + "out" +] @keyword.modifier + +; Labels +[ + (statement_label) + (statement_label_reference) +] @label + +[ + "call" + "endfunction" + "endprogram" + "endprocedure" + "endsubroutine" + "function" + "procedure" + "program" + "subroutine" +] @keyword.function + +[ + "result" + "return" +] @keyword.return + +; Functions +(function_statement + (name) @function) + +(end_function_statement + (name) @function) + +(subroutine_statement + (name) @function) + +(end_subroutine_statement + (name) @function) + +(module_procedure_statement + (name) @function) + +(end_module_procedure_statement + (name) @function) + +(subroutine_call + (identifier) @function.call) + +[ + "character" + "close" + "bind" + "format" + "open" + "print" + "read" + "write" +] @function.builtin + +; Exceptions +"error" @keyword.exception + +; Conditionals +[ + "else" + "elseif" + "elsewhere" + "endif" + "endwhere" + "if" + "then" + "where" +] @keyword.conditional + +; Repeats +[ + "do" + "concurrent" + "enddo" + "endforall" + "forall" + "while" + "continue" + "cycle" + "exit" +] @keyword.repeat + +; Variables +(identifier) @variable + +; Parameters +(keyword_argument + name: (identifier) @variable.parameter) + +(parameters + (identifier) @variable.parameter) + +; Properties +(derived_type_member_expression + (type_member) @variable.member) + +; Operators +[ + "+" + "-" + "*" + "**" + "/" + "=" + "<" + ">" + "<=" + ">=" + "==" + "/=" + "//" + (assumed_rank) +] @operator + +[ + "\\.and\\." + "\\.or\\." + "\\.eqv\\." + "\\.neqv\\." + "\\.lt\\." + "\\.gt\\." + "\\.le\\." + "\\.ge\\." + "\\.eq\\." + "\\.ne\\." + "\\.not\\." +] @keyword.operator + +; Punctuation +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "<<<" + ">>>" +] @punctuation.bracket + +(array_literal + [ + "(/" + "/)" + ] @punctuation.bracket) + +[ + ":" + "," + "/" + "%" + "::" + "=>" +] @punctuation.delimiter + +; Literals +(string_literal) @string + +(number_literal) @number + +(boolean_literal) @boolean + +(null_literal) @constant.builtin + +; Comments +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^!>")) diff --git a/runtime/queries/fortran/indents.scm b/runtime/queries/fortran/indents.scm new file mode 100644 index 000000000..86704c4f4 --- /dev/null +++ b/runtime/queries/fortran/indents.scm @@ -0,0 +1,27 @@ +[ + (module) + (program) + (subroutine) + (function) + ; (interface) + (if_statement) + (do_loop_statement) + (where_statement) + (derived_type_definition) + (enum) +] @indent.begin + +[ + (end_module_statement) + (end_program_statement) + (end_subroutine_statement) + (end_function_statement) + ; (end_interface_statement) + (end_if_statement) + (end_do_loop_statement) + (else_clause) + (elseif_clause) + (end_type_statement) + (end_enum_statement) + (end_where_statement) +] @indent.branch diff --git a/runtime/queries/fortran/injections.scm b/runtime/queries/fortran/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/fortran/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/fsh/highlights.scm b/runtime/queries/fsh/highlights.scm new file mode 100644 index 000000000..2354a2037 --- /dev/null +++ b/runtime/queries/fsh/highlights.scm @@ -0,0 +1,97 @@ +[ + "(" + ")" +] @punctuation.bracket + +[ + "^" + "=" + ":" +] @operator + +[ + "#" + ".." + "*" + "->" +] @punctuation.special + +; Entities +[ + "Profile" + "Alias" + "Extension" + "Invariant" + "Instance" + "ValueSet" + "CodeSystem" + "Mapping" + "Logical" + "Resource" + "RuleSet" +] @keyword + +; Metadata Keywords +[ + "Parent" + "Title" + "Description" + "Id" + "Severity" + "InstanceOf" + "Usage" + "Source" + "XPath" + "Target" +] @keyword + +; Rule Keywords +[ + "contentReference" + "insert" + "and" + "or" + "contains" + "named" + "only" + "obeys" + "valueset" + "codes" + "from" + "include" + "exclude" + "where" + "system" + "exactly" +] @keyword.operator + +; Types +[ + "Reference" + "Canonical" +] @type.builtin + +(sd_metadata + (parent + (name))) @type + +(target_type + (name)) @type + +; Strings +(string) @string + +(multiline_string) @string + +; Constants +(strength_value) @constant + +(bool) @boolean + +(flag) @constant + +; Special Params +(code_value) @variable.parameter + +; Extras +(fsh_comment) @comment @spell diff --git a/runtime/queries/fsh/injections.scm b/runtime/queries/fsh/injections.scm new file mode 100644 index 000000000..7bf6d006a --- /dev/null +++ b/runtime/queries/fsh/injections.scm @@ -0,0 +1,2 @@ +((fsh_comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/fsharp/highlights.scm b/runtime/queries/fsharp/highlights.scm new file mode 100644 index 000000000..e400e3522 --- /dev/null +++ b/runtime/queries/fsharp/highlights.scm @@ -0,0 +1,411 @@ +[ + (line_comment) + (block_comment) +] @comment @spell + +((line_comment) @comment.documentation @spell + (#lua-match? @comment.documentation "^///")) + +(const + [ + (_) @constant + (unit) @constant.builtin + ]) + +(primary_constr_args + (_) @variable.parameter) + +(class_as_reference + (_) @variable.parameter.builtin) + +(type_name + type_name: (_) @type.definition) + +[ + (_type) + (atomic_type) +] @type + +(member_signature + . + (identifier) @function.method) + +(member_signature + (curried_spec + (arguments_spec + (argument_spec + (argument_name_spec + "?"? @character.special + name: (_) @variable.parameter))))) + +(union_type_case + (identifier) @constant) + +(rules + (rule + pattern: (_) @constant + block: (_))) + +(wildcard_pattern) @character.special + +(identifier_pattern + . + (_) @constant + . + (_) @variable) + +(optional_pattern + "?" @character.special) + +(fsi_directive_decl + . + (string) @module) + +(import_decl + . + (_) @module) + +(named_module + name: (_) @module) + +(namespace + name: (_) @module) + +(module_defn + (identifier) @module) + +(ce_expression + . + (_) @constant.macro) + +(field_initializer + field: (_) @property) + +(record_fields + (record_field + . + (identifier) @property)) + +(value_declaration_left + . + (_) @variable) + +(function_declaration_left + . + (_) @function) + +(argument_patterns + [ + (const) + (long_identifier) + (_pattern) + ] @variable.parameter) + +(argument_patterns + (typed_pattern + (_pattern) @variable.parameter + (_type) @type)) + +(argument_patterns + (record_pattern + (field_pattern + . + (long_identifier) @variable.parameter))) + +(argument_patterns + (array_pattern + (_pattern)? @variable.parameter)) + +(argument_patterns + (list_pattern + (_pattern)? @variable.parameter)) + +((argument_patterns + (long_identifier + (identifier) @character.special)) + (#lua-match? @character.special "^\_.*")) + +(member_defn + (method_or_prop_defn + [ + (property_or_ident) @function + (property_or_ident + instance: (identifier) @variable.parameter.builtin + method: (identifier) @function.method) + ] + args: (_)* @variable.parameter)) + +(dot_expression + . + (_) @variable.member + . + (_)) + +(application_expression + . + (_) @function.call + . + (_) @variable) + +((infix_expression + . + (_) + . + (infix_op) @operator + . + (_) @function.call) + (#eq? @operator "|>")) + +((infix_expression + . + (_) @function.call + . + (infix_op) @operator + . + (_)) + (#eq? @operator "<|")) + +[ + (xint) + (int) + (int16) + (uint16) + (int32) + (uint32) + (int64) + (uint64) + (nativeint) + (unativeint) +] @number + +[ + (ieee32) + (ieee64) + (float) + (decimal) +] @number.float + +(bool) @boolean + +[ + (string) + (triple_quoted_string) + (verbatim_string) + (char) +] @spell @string + +(compiler_directive_decl) @keyword.directive + +(preproc_line + "#line" @keyword.directive) + +(attribute + target: (identifier)? @keyword + (_type) @attribute) + +[ + "(" + ")" + "{" + "}" + ".[" + "[" + "]" + "[|" + "|]" + "{|" + "|}" +] @punctuation.bracket + +[ + "[<" + ">]" +] @punctuation.special + +(format_string_eval + [ + "{" + "}" + ] @punctuation.special) + +[ + "," + ";" + ":" + "." +] @punctuation.delimiter + +[ + "|" + "=" + ">" + "<" + "-" + "~" + "->" + "<-" + "&" + "&&" + "|" + "||" + ":>" + ":?>" + ".." + "*" + (infix_op) + (prefix_op) + (op_identifier) +] @operator + +(generic_type + [ + "<" + ">" + ] @punctuation.bracket) + +[ + "if" + "then" + "else" + "elif" + "when" + "match" + "match!" +] @keyword.conditional + +[ + "and" + "or" + "not" + "upcast" + "downcast" +] @keyword.operator + +[ + "return" + "return!" + "yield" + "yield!" +] @keyword.return + +[ + "for" + "while" + "downto" + "to" +] @keyword.repeat + +[ + "open" + "#r" + "#load" +] @keyword.import + +[ + "abstract" + "delegate" + "static" + "inline" + "mutable" + "override" + "rec" + "global" + (access_modifier) +] @keyword.modifier + +[ + "let" + "let!" + "use" + "use!" + "member" +] @keyword.function + +[ + "enum" + "type" + "inherit" + "interface" + "and" + "class" + "struct" +] @keyword.type + +((identifier) @keyword.exception + (#any-of? @keyword.exception "failwith" "failwithf" "raise" "reraise")) + +[ + "as" + "assert" + "begin" + "end" + "done" + "default" + "in" + "do" + "do!" + "fun" + "function" + "get" + "set" + "lazy" + "new" + "of" + "struct" + "val" + "module" + "namespace" + "with" +] @keyword + +[ + "null" + (unit) +] @constant.builtin + +(match_expression + "with" @keyword.conditional) + +(try_expression + [ + "try" + "with" + "finally" + ] @keyword.exception) + +(application_expression + (unit) @function.call) + +((_type + (long_identifier + (identifier) @type.builtin)) + (#any-of? @type.builtin + "bool" "byte" "sbyte" "int16" "uint16" "int" "uint" "int64" "uint64" "nativeint" "unativeint" + "decimal" "float" "double" "float32" "single" "char" "string" "unit")) + +(preproc_if + [ + "#if" @keyword.directive + "#endif" @keyword.directive + ] + condition: (_)? @keyword.directive) + +(preproc_else + "#else" @keyword.directive) + +((identifier) @module.builtin + (#any-of? @module.builtin + "Array" "Async" "Directory" "File" "List" "Option" "Path" "Map" "Set" "Lazy" "Seq" "Task" + "String" "Result")) + +((value_declaration + (attributes + (attribute + (_type + (long_identifier + (identifier) @attribute)))) + (function_or_value_defn + (value_declaration_left + . + (_) @constant))) + (#eq? @attribute "Literal")) diff --git a/runtime/queries/fsharp/injections.scm b/runtime/queries/fsharp/injections.scm new file mode 100644 index 000000000..211b263f3 --- /dev/null +++ b/runtime/queries/fsharp/injections.scm @@ -0,0 +1,11 @@ +([ + (line_comment) + (block_comment_content) +] @injection.content + (#set! injection.language "comment")) + +((line_comment) @injection.content + (#lua-match? @injection.content "^///") + (#offset! @injection.content 0 3 0 0) + (#set! injection.language "xml") + (#set! injection.combined)) diff --git a/runtime/queries/func/highlights.scm b/runtime/queries/func/highlights.scm new file mode 100644 index 000000000..9fd6dd82d --- /dev/null +++ b/runtime/queries/func/highlights.scm @@ -0,0 +1,167 @@ +; Include +"#include" @keyword.import + +(include_path) @string + +; Preproc +"#pragma" @keyword.directive + +(pragma_directive + [ + "version" + "not-version" + "test-version-set" + ] @keyword.directive) + +; Keywords +[ + "asm" + "impure" + "inline" + "inline_ref" + "method_id" + "type" +] @keyword + +"return" @keyword.return + +; Conditionals +[ + "if" + "ifnot" + "else" + "elseif" + "elseifnot" + "until" +] @keyword.conditional + +; Exceptions +[ + "try" + "catch" +] @keyword.exception + +; Repeats +[ + "do" + "forall" + "repeat" + "while" +] @keyword.repeat + +; Qualifiers +[ + "const" + "global" + (var) +] @keyword.modifier + +; Variables +(identifier) @variable + +; Constants +(const_var_declarations + name: (identifier) @constant) + +; Functions/Methods +(function_definition + name: (function_name) @function) + +(function_application + function: (identifier) @function) + +(method_call + method_name: (identifier) @function.method.call) + +; Parameters +(parameter) @variable.parameter + +; Types +(type_identifier) @type + +(primitive_type) @type.builtin + +; Operators +[ + "=" + "+=" + "-=" + "*=" + "/=" + "~/=" + "^/=" + "%=" + "~%=" + "^%=" + "<<=" + ">>=" + "~>>=" + "^>>=" + "&=" + "|=" + "^=" + "==" + "<" + ">" + "<=" + ">=" + "!=" + "<=>" + "<<" + ">>" + "~>>" + "^>>" + "-" + "+" + "|" + "^" + "*" + "/" + "%" + "~/" + "^/" + "~%" + "^%" + "/%" + "&" + "~" +] @operator + +; Literals +[ + (string) + (asm_instruction) +] @string + +[ + (string_type) + (underscore) +] @character.special + +(number) @number + +; Punctuation +[ + "{" + "}" +] @punctuation.bracket + +[ + "(" + ")" + "()" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + ";" + "," + "->" +] @punctuation.delimiter + +; Comments +(comment) @comment @spell diff --git a/runtime/queries/func/injections.scm b/runtime/queries/func/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/func/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/fusion/folds.scm b/runtime/queries/fusion/folds.scm new file mode 100644 index 000000000..179fc160b --- /dev/null +++ b/runtime/queries/fusion/folds.scm @@ -0,0 +1,6 @@ +[ + (comment) + (block) + (afx_comment) + (afx_element) +] @fold diff --git a/runtime/queries/fusion/highlights.scm b/runtime/queries/fusion/highlights.scm new file mode 100644 index 000000000..7108e5705 --- /dev/null +++ b/runtime/queries/fusion/highlights.scm @@ -0,0 +1,132 @@ +(comment) @comment @spell + +(afx_comment) @comment @spell + +; identifiers afx +(afx_opening_element + (afx_identifier) @tag) + +(afx_closing_element + (afx_identifier) @tag) + +(afx_element_self_closing + (afx_identifier) @tag) + +(afx_attribute + (afx_property_identifier) @tag.attribute) + +(afx_text) @spell + +; identifiers eel +(eel_object_path + (eel_path_identifier) @variable.builtin + (#any-of? @variable.builtin "this" "props")) + +(eel_object_path + (eel_path_identifier) @variable) + +(eel_object_pair + key: (eel_property_name) @property) + +(eel_method_name) @function + +(eel_parameter) @variable + +; identifiers fusion +; ----------- +(path_part) @property + +(meta_property) @attribute + +(prototype_signature + "prototype" @keyword) + +(include_statement + "include" @keyword.import + (source_file) @string.special.url) + +(namespace_declaration + "namespace" @keyword.type + (alias_namespace) @module) + +(type + name: (type_name) @type) + +; tokens +; ------ +(afx_opening_element + [ + "<" + ">" + ] @punctuation.bracket) + +(afx_closing_element + [ + "<" + ">" + "/" + ] @punctuation.bracket) + +(afx_element_self_closing + [ + "<" + "/>" + ] @punctuation.bracket) + +[ + (package_name) + (alias_namespace) +] @module + +(namespace_declaration + "=" @operator) + +(assignment + "=" @operator) + +(copy + "<" @operator) + +(deletion) @operator + +(eel_binary_expression + operator: _ @operator) + +(eel_not_expression + [ + "!" + "not" + ] @operator) + +(string) @string + +(number) @number + +(boolean) @boolean + +(null) @constant.builtin + +(value_expression + start: _ @punctuation.special + end: _ @punctuation.special) + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + ":" + "." + "?" +] @punctuation.delimiter + +(eel_ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) diff --git a/runtime/queries/fusion/indents.scm b/runtime/queries/fusion/indents.scm new file mode 100644 index 000000000..0ba6cf758 --- /dev/null +++ b/runtime/queries/fusion/indents.scm @@ -0,0 +1,24 @@ +[ + (block) + (value_dsl) + (afx_element) + (afx_element_self_closing) + (eel_array) + (eel_object) +] @indent.begin + +(block + end: _ @indent.branch) + +(value_dsl + end: _ @indent.branch) + +(eel_array + end: _ @indent.branch) + +(eel_object + end: _ @indent.branch) + +(afx_closing_element) @indent.branch + +(comment) @indent.ignore diff --git a/runtime/queries/fusion/injections.scm b/runtime/queries/fusion/injections.scm new file mode 100644 index 000000000..085cdb458 --- /dev/null +++ b/runtime/queries/fusion/injections.scm @@ -0,0 +1,5 @@ +([ + (comment) + (afx_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/fusion/locals.scm b/runtime/queries/fusion/locals.scm new file mode 100644 index 000000000..d23e0ab46 --- /dev/null +++ b/runtime/queries/fusion/locals.scm @@ -0,0 +1,23 @@ +; Fusion base +(block) @local.scope + +(namespace_declaration + (alias_namespace) @local.definition.namespace) + +(property + (path + (path_part) @local.definition.field)) + +(type + namespace: (package_name)? @local.definition.namespace + name: (type_name) @local.definition.type) + +; Eel Expressions +(eel_arrow_function) @local.scope + +(eel_object) @local.scope + +(eel_parameter) @local.definition.parameter + +(eel_object_pair + key: (eel_property_name) @local.definition.field) diff --git a/runtime/queries/gap/folds.scm b/runtime/queries/gap/folds.scm new file mode 100644 index 000000000..7cf0888b6 --- /dev/null +++ b/runtime/queries/gap/folds.scm @@ -0,0 +1,12 @@ +[ + (if_statement) + (elif_clause) + (else_clause) + (while_statement) + (repeat_statement) + (for_statement) + (atomic_statement) + (lambda) + (function) + (atomic_function) +] @fold diff --git a/runtime/queries/gap/highlights.scm b/runtime/queries/gap/highlights.scm new file mode 100644 index 000000000..6c0c856c5 --- /dev/null +++ b/runtime/queries/gap/highlights.scm @@ -0,0 +1,208 @@ +(identifier) @variable + +; Functions +(assignment_statement + left: (identifier) @function + right: (function)) + +(assignment_statement + left: (identifier) @function + right: (atomic_function)) + +(assignment_statement + left: (identifier) @function + right: (lambda)) + +(call + function: (identifier) @function.call) + +((call + function: (identifier) @function.builtin) + (#any-of? @function.builtin "Assert" "Info" "IsBound" "Unbind" "TryNextMethod")) + +(parameters + (identifier) @variable.parameter) + +(qualified_parameters + (identifier) @variable.parameter) + +(qualified_parameters + (qualified_identifier + (identifier) @variable.parameter)) + +(lambda_parameters + (identifier) @variable.parameter) + +; arg is treated specially when it is the only parameter of a function +((parameters + . + (identifier) @variable.parameter.builtin .) + (#eq? @variable.parameter.builtin "arg")) + +((qualified_parameters + . + (identifier) @variable.parameter.builtin .) + (#eq? @variable.parameter.builtin "arg")) + +((qualified_parameters + . + (qualified_identifier + (identifier) @variable.parameter.builtin) .) + (#eq? @variable.parameter.builtin "arg")) + +((lambda_parameters + . + (identifier) @variable.parameter.builtin .) + (#eq? @variable.parameter.builtin "arg")) + +; Literals +(bool) @constant.builtin + +(integer) @number + +(float) @number.float + +(string) @string + +(char) @character + +(escape_sequence) @string.escape + +[ + (help_topic) + (help_book) +] @string.special + +(tilde) @variable.builtin + +; Record selectors +(record_entry + left: [ + (identifier) + (integer) + ] @variable.member) + +(record_selector + selector: [ + (identifier) + (integer) + ] @variable.member) + +(component_selector + selector: [ + (identifier) + (integer) + ] @variable.member) + +(function_call_option + [ + (identifier) + (record_entry ;Record entries specify global properties in function calls + left: [ + (identifier) + (integer) + ]) + ] @property) + +(help_statement + (help_selector) @property) + +; Operators +[ + "+" + "-" + "*" + "/" + "^" + "->" + ":=" + "<" + "<=" + "<>" + "=" + ">" + ">=" + ".." + (ellipsis) +] @operator + +(help_statement + (help_operator) @operator) + +; Keywords +[ + (break_statement) + (continue_statement) + "atomic" + (quit_statement) +] @keyword + +[ + "function" + "local" + "end" +] @keyword.function + +[ + "and" + "in" + "mod" + "not" + "or" +] @keyword.operator + +"rec" @keyword.type + +[ + "readonly" + "readwrite" +] @keyword.modifier + +(atomic_function + "atomic" @keyword.modifier) + +[ + "for" + "while" + "do" + "od" + "repeat" + "until" +] @keyword.repeat + +[ + "if" + "then" + "elif" + "else" + "fi" +] @keyword.conditional + +"return" @keyword.return + +(pragma) @keyword.directive + +;Punctuation +[ + "," + ";" + "." + "!." + ":" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "![" + "]" + "{" + "}" +] @punctuation.bracket + +(help_statement + "?" @punctuation.special) + +;Comments +(comment) @comment @spell diff --git a/runtime/queries/gap/injections.scm b/runtime/queries/gap/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/gap/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/gap/locals.scm b/runtime/queries/gap/locals.scm new file mode 100644 index 000000000..d695d1f2d --- /dev/null +++ b/runtime/queries/gap/locals.scm @@ -0,0 +1,43 @@ +[ + (lambda) + (function) + (atomic_function) +] @local.scope + +(parameters + (identifier) @local.definition.parameter) + +(qualified_parameters + (identifier) @local.definition.parameter) + +(qualified_parameters + (qualified_identifier + (identifier) @local.definition.parameter)) + +(lambda_parameters + (identifier) @local.definition.parameter) + +(locals + (identifier) @local.definition.var) + +(record_entry + left: [ + (identifier) + (integer) + ] @local.definition.field) + +(assignment_statement + left: (identifier) @local.definition.var) + +(for_statement + identifier: (identifier) @local.definition.var) + +(assignment_statement + left: (identifier) @local.definition.function + right: [ + (lambda) + (function) + (atomic_function) + ]) + +(identifier) @local.reference diff --git a/runtime/queries/gaptst/folds.scm b/runtime/queries/gaptst/folds.scm new file mode 100644 index 000000000..0ec72d135 --- /dev/null +++ b/runtime/queries/gaptst/folds.scm @@ -0,0 +1,7 @@ +[ + (if_statement) + (else_clause) + (local_statement) + (exec_statement) + (test_case) +] @fold diff --git a/runtime/queries/gaptst/highlights.scm b/runtime/queries/gaptst/highlights.scm new file mode 100644 index 000000000..22ab2d0a0 --- /dev/null +++ b/runtime/queries/gaptst/highlights.scm @@ -0,0 +1,19 @@ +(output_line) @markup.raw.block + +[ + "#@local" + "#@exec" +] @keyword + +[ + "gap> " + "> " +] @keyword.debug + +[ + "#@if" + "#@else" + "#@fi" +] @keyword.conditional + +(comment) @comment @spell diff --git a/runtime/queries/gaptst/injections.scm b/runtime/queries/gaptst/injections.scm new file mode 100644 index 000000000..bdcba35dc --- /dev/null +++ b/runtime/queries/gaptst/injections.scm @@ -0,0 +1,9 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((gap_expression) @injection.content + (#set! injection.language "gap")) + +((input_line) @injection.content + (#set! injection.language "gap") + (#set! injection.combined)) diff --git a/runtime/queries/gdscript/folds.scm b/runtime/queries/gdscript/folds.scm new file mode 100644 index 000000000..cda709077 --- /dev/null +++ b/runtime/queries/gdscript/folds.scm @@ -0,0 +1,26 @@ +[ + ; Body fold will "join" the next adjacent fold into a SUPER fold. + ; This is an issue with the grammar. + ; (body) + (if_statement) + (elif_clause) + (else_clause) + (for_statement) + (while_statement) + (class_definition) + (enum_definition) + (match_statement) + (pattern_section) + (function_definition) + (lambda) + (constructor_definition) +] @fold + +; It's nice to be able to fold the if/elif/else clauses and the entire +; if_statement. +(if_statement + (body) @fold) + +; Fold strings that are probably doc strings. +(expression_statement + (string) @fold) diff --git a/runtime/queries/gdscript/highlights.scm b/runtime/queries/gdscript/highlights.scm new file mode 100644 index 000000000..cea9093c0 --- /dev/null +++ b/runtime/queries/gdscript/highlights.scm @@ -0,0 +1,422 @@ +; Basic +(identifier) @variable + +(name) @variable + +(type + (identifier) @type) + +(comment) @comment @spell + +(string_name) @string + +(string) @string + +(float) @number.float + +(integer) @number + +(null) @constant + +(setter) @function + +(getter) @function + +(set_body + "set" @keyword.function) + +(get_body + "get" @keyword.function) + +(static_keyword) @keyword.modifier + +(tool_statement) @keyword + +(breakpoint_statement) @keyword.debug + +(inferred_type) @operator + +[ + (true) + (false) +] @boolean + +[ + (get_node) + (node_path) +] @string.special.url + +(class_name_statement + (name) @type) @keyword + +(const_statement + "const" @keyword.modifier + (name) @constant) + +(expression_statement + (string) @comment @spell) + +; Functions +(constructor_definition + "_init" @constructor) + +(function_definition + (name) @function) + +(parameters + (identifier) @variable.parameter) + +(typed_parameter + (identifier) @variable.parameter) + +(default_parameter + (identifier) @variable.parameter) + +(typed_default_parameter + (identifier) @variable.parameter) + +(call + (identifier) @function.call) + +(call + (identifier) @keyword.import + (#any-of? @keyword.import "preload" "load")) + +; Properties and Methods +; We'll use @property since that's the term Godot uses. +; But, should (source (variable_statement (name))) be @property, too? Since a +; script file is a class in gdscript. +(class_definition + (body + (variable_statement + (name) @property))) + +; Same question but for methods? +(class_definition + (body + (function_definition + (name) @function.method))) + +(attribute_call + (identifier) @function.method.call) + +(attribute_subscript + (identifier) @property) + +(attribute + (_) + (identifier) @property) + +; Identifier naming conventions +; - Make sure the following query is below the attribute queries so that it +; takes precedence on a `(type (attribute (identifier)))` +((identifier) @type + (#lua-match? @type "^[A-Z]")) + +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + +; Enums +(enumerator + left: (identifier) @constant) + +; Special Builtins +((identifier) @variable.builtin + (#any-of? @variable.builtin "self" "super")) + +(attribute_call + (identifier) @keyword.operator + (#eq? @keyword.operator "new")) + +; Match Pattern +[ + (underscore) + (pattern_open_ending) +] @character.special + +; Alternations +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "," + "." + ":" +] @punctuation.delimiter + +[ + "if" + "elif" + "else" + "match" +] @keyword.conditional + +(pattern_guard + "when" @keyword.conditional) + +[ + "for" + "while" + "break" + "continue" +] @keyword.repeat + +[ + "~" + "-" + "*" + "/" + "%" + "+" + "-" + "<<" + ">>" + "&" + "^" + "|" + "<" + ">" + "==" + "!=" + ">=" + "<=" + "!" + "&&" + "||" + "=" + "+=" + "-=" + "*=" + "/=" + "%=" + "&=" + "|=" + "->" +] @operator + +[ + "and" + "as" + "in" + "is" + "not" + "or" +] @keyword.operator + +[ + "pass" + "class_name" + "extends" + "signal" + "var" + "onready" + "setget" + "remote" + "master" + "puppet" + "remotesync" + "mastersync" + "puppetsync" +] @keyword + +"export" @keyword.import + +[ + "enum" + "class" +] @keyword.type + +"func" @keyword.function + +"return" @keyword.return + +"await" @keyword.coroutine + +(call + (identifier) @keyword.coroutine + (#eq? @keyword.coroutine "yield")) + +; Builtins +; generated from +; - godot commit: fb10e67fef +; - https://github.com/godotengine/godot/blob/fb10e67fef/doc/classes +; - https://github.com/godotengine/godot/blob/fb10e67fef/doc/classes/@GlobalScope.xml +; - https://github.com/godotengine/godot/blob/fb10e67fef/modules/gdscript/doc_classes/@GDScript.xml +; Built-in Annotations +((annotation + "@" @attribute + (identifier) @attribute) + (#any-of? @attribute + ; from modules/gdscript/doc_classes/@GDScript.xml + "export" "export_category" "export_color_no_alpha" "export_custom" "export_dir" "export_enum" + "export_exp_easing" "export_file" "export_flags" "export_flags_2d_navigation" + "export_flags_2d_physics" "export_flags_2d_render" "export_flags_3d_navigation" + "export_flags_3d_physics" "export_flags_3d_render" "export_flags_avoidance" "export_global_dir" + "export_global_file" "export_group" "export_multiline" "export_node_path" "export_placeholder" + "export_range" "export_storage" "export_subgroup" "icon" "onready" "rpc" "static_unload" "tool" + "warning_ignore")) + +; Builtin Types +((identifier) @type.builtin + (#any-of? @type.builtin + ; from doc/classes/*.xml + "AABB" "Array" "Basis" "Callable" "Color" "Dictionary" "NodePath" "PackedByteArray" + "PackedColorArray" "PackedFloat32Array" "PackedFloat64Array" "PackedInt32Array" + "PackedInt64Array" "PackedStringArray" "PackedVector2Array" "PackedVector3Array" "Plane" + "Projection" "Quaternion" "RID" "Rect2" "Rect2i" "Signal" "String" "StringName" "Transform2D" + "Transform3D" "Vector2" "Vector2i" "Vector3" "Vector3i" "Vector4" "Vector4i" "bool" "float" + "int" + ; from doc/classes/@GlobalScope.xml + "AudioServer" "CameraServer" "ClassDB" "DisplayServer" "EditorInterface" "Engine" + "EngineDebugger" "GDExtensionManager" "Geometry2D" "Geometry3D" "GodotSharp" "IP" "Input" + "InputMap" "JavaClassWrapper" "JavaScriptBridge" "Marshalls" "NavigationMeshGenerator" + "NavigationServer2D" "NavigationServer3D" "OS" "Performance" "PhysicsServer2D" + "PhysicsServer2DManager" "PhysicsServer3D" "PhysicsServer3DManager" "ProjectSettings" + "RenderingServer" "ResourceLoader" "ResourceSaver" "ResourceUID" "TextServerManager" "ThemeDB" + "Time" "TranslationServer" "WorkerThreadPool" "XRServer")) + +; Builtin Funcs +(call + (identifier) @function.builtin + (#any-of? @function.builtin + ; from doc/classes/@GlobalScope.xml + "abs" "absf" "absi" "acos" "acosh" "angle_difference" "asin" "asinh" "atan" "atan2" "atanh" + "bezier_derivative" "bezier_interpolate" "bytes_to_var" "bytes_to_var_with_objects" "ceil" + "ceilf" "ceili" "clamp" "clampf" "clampi" "cos" "cosh" "cubic_interpolate" + "cubic_interpolate_angle" "cubic_interpolate_angle_in_time" "cubic_interpolate_in_time" + "db_to_linear" "deg_to_rad" "ease" "error_string" "exp" "floor" "floorf" "floori" "fmod" + "fposmod" "hash" "instance_from_id" "inverse_lerp" "is_equal_approx" "is_finite" "is_inf" + "is_instance_id_valid" "is_instance_valid" "is_nan" "is_same" "is_zero_approx" "lerp" + "lerp_angle" "lerpf" "linear_to_db" "log" "max" "maxf" "maxi" "min" "minf" "mini" "move_toward" + "nearest_po2" "pingpong" "posmod" "pow" "print" "print_rich" "print_verbose" "printerr" + "printraw" "prints" "printt" "push_error" "push_warning" "rad_to_deg" "rand_from_seed" "randf" + "randf_range" "randfn" "randi" "randi_range" "randomize" "remap" "rid_allocate_id" + "rid_from_int64" "rotate_toward" "round" "roundf" "roundi" "seed" "sign" "signf" "signi" "sin" + "sinh" "smoothstep" "snapped" "snappedf" "snappedi" "sqrt" "step_decimals" "str" "str_to_var" + "tan" "tanh" "type_convert" "type_string" "typeof" "var_to_bytes" "var_to_bytes_with_objects" + "var_to_str" "weakref" "wrap" "wrapf" "wrapi" + ; from modules/gdscript/doc_classes/@GDScript.xml + "Color8" "assert" "char" "convert" "dict_to_inst" "get_stack" "inst_to_dict" "is_instance_of" + "len" "load" "preload" "print_debug" "print_stack" "range" "type_exists")) + +; Builtin Constants +((identifier) @constant.builtin + (#any-of? @constant.builtin + ; from modules/gdscript/doc_classes/@GDScript.xml + "INF" "NAN" "PI" "TAU" + ; from doc/classes/@GlobalScope.xml + "CLOCKWISE" "CORNER_BOTTOM_LEFT" "CORNER_BOTTOM_RIGHT" "CORNER_TOP_LEFT" "CORNER_TOP_RIGHT" + "COUNTERCLOCKWISE" "ERR_ALREADY_EXISTS" "ERR_ALREADY_IN_USE" "ERR_BUG" "ERR_BUSY" + "ERR_CANT_ACQUIRE_RESOURCE" "ERR_CANT_CONNECT" "ERR_CANT_CREATE" "ERR_CANT_FORK" "ERR_CANT_OPEN" + "ERR_CANT_RESOLVE" "ERR_COMPILATION_FAILED" "ERR_CONNECTION_ERROR" "ERR_CYCLIC_LINK" + "ERR_DATABASE_CANT_READ" "ERR_DATABASE_CANT_WRITE" "ERR_DOES_NOT_EXIST" "ERR_DUPLICATE_SYMBOL" + "ERR_FILE_ALREADY_IN_USE" "ERR_FILE_BAD_DRIVE" "ERR_FILE_BAD_PATH" "ERR_FILE_CANT_OPEN" + "ERR_FILE_CANT_READ" "ERR_FILE_CANT_WRITE" "ERR_FILE_CORRUPT" "ERR_FILE_EOF" + "ERR_FILE_MISSING_DEPENDENCIES" "ERR_FILE_NOT_FOUND" "ERR_FILE_NO_PERMISSION" + "ERR_FILE_UNRECOGNIZED" "ERR_HELP" "ERR_INVALID_DATA" "ERR_INVALID_DECLARATION" + "ERR_INVALID_PARAMETER" "ERR_LINK_FAILED" "ERR_LOCKED" "ERR_METHOD_NOT_FOUND" + "ERR_OUT_OF_MEMORY" "ERR_PARAMETER_RANGE_ERROR" "ERR_PARSE_ERROR" "ERR_PRINTER_ON_FIRE" + "ERR_QUERY_FAILED" "ERR_SCRIPT_FAILED" "ERR_SKIP" "ERR_TIMEOUT" "ERR_UNAUTHORIZED" + "ERR_UNAVAILABLE" "ERR_UNCONFIGURED" "EULER_ORDER_XYZ" "EULER_ORDER_XZY" "EULER_ORDER_YXZ" + "EULER_ORDER_YZX" "EULER_ORDER_ZXY" "EULER_ORDER_ZYX" "FAILED" "HORIZONTAL" + "HORIZONTAL_ALIGNMENT_CENTER" "HORIZONTAL_ALIGNMENT_FILL" "HORIZONTAL_ALIGNMENT_LEFT" + "HORIZONTAL_ALIGNMENT_RIGHT" "INLINE_ALIGNMENT_BASELINE_TO" "INLINE_ALIGNMENT_BOTTOM" + "INLINE_ALIGNMENT_BOTTOM_TO" "INLINE_ALIGNMENT_CENTER" "INLINE_ALIGNMENT_CENTER_TO" + "INLINE_ALIGNMENT_IMAGE_MASK" "INLINE_ALIGNMENT_TEXT_MASK" "INLINE_ALIGNMENT_TOP" + "INLINE_ALIGNMENT_TOP_TO" "INLINE_ALIGNMENT_TO_BASELINE" "INLINE_ALIGNMENT_TO_BOTTOM" + "INLINE_ALIGNMENT_TO_CENTER" "INLINE_ALIGNMENT_TO_TOP" "JOY_AXIS_INVALID" "JOY_AXIS_LEFT_X" + "JOY_AXIS_LEFT_Y" "JOY_AXIS_MAX" "JOY_AXIS_RIGHT_X" "JOY_AXIS_RIGHT_Y" "JOY_AXIS_SDL_MAX" + "JOY_AXIS_TRIGGER_LEFT" "JOY_AXIS_TRIGGER_RIGHT" "JOY_BUTTON_A" "JOY_BUTTON_B" "JOY_BUTTON_BACK" + "JOY_BUTTON_DPAD_DOWN" "JOY_BUTTON_DPAD_LEFT" "JOY_BUTTON_DPAD_RIGHT" "JOY_BUTTON_DPAD_UP" + "JOY_BUTTON_GUIDE" "JOY_BUTTON_INVALID" "JOY_BUTTON_LEFT_SHOULDER" "JOY_BUTTON_LEFT_STICK" + "JOY_BUTTON_MAX" "JOY_BUTTON_MISC1" "JOY_BUTTON_PADDLE1" "JOY_BUTTON_PADDLE2" + "JOY_BUTTON_PADDLE3" "JOY_BUTTON_PADDLE4" "JOY_BUTTON_RIGHT_SHOULDER" "JOY_BUTTON_RIGHT_STICK" + "JOY_BUTTON_SDL_MAX" "JOY_BUTTON_START" "JOY_BUTTON_TOUCHPAD" "JOY_BUTTON_X" "JOY_BUTTON_Y" + "KEY_0" "KEY_1" "KEY_2" "KEY_3" "KEY_4" "KEY_5" "KEY_6" "KEY_7" "KEY_8" "KEY_9" "KEY_A" + "KEY_ALT" "KEY_AMPERSAND" "KEY_APOSTROPHE" "KEY_ASCIICIRCUM" "KEY_ASCIITILDE" "KEY_ASTERISK" + "KEY_AT" "KEY_B" "KEY_BACK" "KEY_BACKSLASH" "KEY_BACKSPACE" "KEY_BACKTAB" "KEY_BAR" + "KEY_BRACELEFT" "KEY_BRACERIGHT" "KEY_BRACKETLEFT" "KEY_BRACKETRIGHT" "KEY_C" "KEY_CAPSLOCK" + "KEY_CLEAR" "KEY_CODE_MASK" "KEY_COLON" "KEY_COMMA" "KEY_CTRL" "KEY_D" "KEY_DELETE" "KEY_DOLLAR" + "KEY_DOWN" "KEY_E" "KEY_END" "KEY_ENTER" "KEY_EQUAL" "KEY_ESCAPE" "KEY_EXCLAM" "KEY_F" "KEY_F1" + "KEY_F10" "KEY_F11" "KEY_F12" "KEY_F13" "KEY_F14" "KEY_F15" "KEY_F16" "KEY_F17" "KEY_F18" + "KEY_F19" "KEY_F2" "KEY_F20" "KEY_F21" "KEY_F22" "KEY_F23" "KEY_F24" "KEY_F25" "KEY_F26" + "KEY_F27" "KEY_F28" "KEY_F29" "KEY_F3" "KEY_F30" "KEY_F31" "KEY_F32" "KEY_F33" "KEY_F34" + "KEY_F35" "KEY_F4" "KEY_F5" "KEY_F6" "KEY_F7" "KEY_F8" "KEY_F9" "KEY_FAVORITES" "KEY_FORWARD" + "KEY_G" "KEY_GLOBE" "KEY_GREATER" "KEY_H" "KEY_HELP" "KEY_HOME" "KEY_HOMEPAGE" "KEY_HYPER" + "KEY_I" "KEY_INSERT" "KEY_J" "KEY_JIS_EISU" "KEY_JIS_KANA" "KEY_K" "KEY_KEYBOARD" "KEY_KP_0" + "KEY_KP_1" "KEY_KP_2" "KEY_KP_3" "KEY_KP_4" "KEY_KP_5" "KEY_KP_6" "KEY_KP_7" "KEY_KP_8" + "KEY_KP_9" "KEY_KP_ADD" "KEY_KP_DIVIDE" "KEY_KP_ENTER" "KEY_KP_MULTIPLY" "KEY_KP_PERIOD" + "KEY_KP_SUBTRACT" "KEY_L" "KEY_LAUNCH0" "KEY_LAUNCH1" "KEY_LAUNCH2" "KEY_LAUNCH3" "KEY_LAUNCH4" + "KEY_LAUNCH5" "KEY_LAUNCH6" "KEY_LAUNCH7" "KEY_LAUNCH8" "KEY_LAUNCH9" "KEY_LAUNCHA" + "KEY_LAUNCHB" "KEY_LAUNCHC" "KEY_LAUNCHD" "KEY_LAUNCHE" "KEY_LAUNCHF" "KEY_LAUNCHMAIL" + "KEY_LAUNCHMEDIA" "KEY_LEFT" "KEY_LESS" "KEY_LOCATION_LEFT" "KEY_LOCATION_RIGHT" + "KEY_LOCATION_UNSPECIFIED" "KEY_M" "KEY_MASK_ALT" "KEY_MASK_CMD_OR_CTRL" "KEY_MASK_CTRL" + "KEY_MASK_GROUP_SWITCH" "KEY_MASK_KPAD" "KEY_MASK_META" "KEY_MASK_SHIFT" "KEY_MEDIANEXT" + "KEY_MEDIAPLAY" "KEY_MEDIAPREVIOUS" "KEY_MEDIARECORD" "KEY_MEDIASTOP" "KEY_MENU" "KEY_META" + "KEY_MINUS" "KEY_MODIFIER_MASK" "KEY_N" "KEY_NONE" "KEY_NUMBERSIGN" "KEY_NUMLOCK" "KEY_O" + "KEY_OPENURL" "KEY_P" "KEY_PAGEDOWN" "KEY_PAGEUP" "KEY_PARENLEFT" "KEY_PARENRIGHT" "KEY_PAUSE" + "KEY_PERCENT" "KEY_PERIOD" "KEY_PLUS" "KEY_PRINT" "KEY_Q" "KEY_QUESTION" "KEY_QUOTEDBL" + "KEY_QUOTELEFT" "KEY_R" "KEY_REFRESH" "KEY_RIGHT" "KEY_S" "KEY_SCROLLLOCK" "KEY_SEARCH" + "KEY_SECTION" "KEY_SEMICOLON" "KEY_SHIFT" "KEY_SLASH" "KEY_SPACE" "KEY_SPECIAL" "KEY_STANDBY" + "KEY_STOP" "KEY_SYSREQ" "KEY_T" "KEY_TAB" "KEY_U" "KEY_UNDERSCORE" "KEY_UNKNOWN" "KEY_UP" + "KEY_V" "KEY_VOLUMEDOWN" "KEY_VOLUMEMUTE" "KEY_VOLUMEUP" "KEY_W" "KEY_X" "KEY_Y" "KEY_YEN" + "KEY_Z" "METHOD_FLAGS_DEFAULT" "METHOD_FLAG_CONST" "METHOD_FLAG_EDITOR" "METHOD_FLAG_NORMAL" + "METHOD_FLAG_OBJECT_CORE" "METHOD_FLAG_STATIC" "METHOD_FLAG_VARARG" "METHOD_FLAG_VIRTUAL" + "MIDI_MESSAGE_ACTIVE_SENSING" "MIDI_MESSAGE_AFTERTOUCH" "MIDI_MESSAGE_CHANNEL_PRESSURE" + "MIDI_MESSAGE_CONTINUE" "MIDI_MESSAGE_CONTROL_CHANGE" "MIDI_MESSAGE_NONE" + "MIDI_MESSAGE_NOTE_OFF" "MIDI_MESSAGE_NOTE_ON" "MIDI_MESSAGE_PITCH_BEND" + "MIDI_MESSAGE_PROGRAM_CHANGE" "MIDI_MESSAGE_QUARTER_FRAME" "MIDI_MESSAGE_SONG_POSITION_POINTER" + "MIDI_MESSAGE_SONG_SELECT" "MIDI_MESSAGE_START" "MIDI_MESSAGE_STOP" + "MIDI_MESSAGE_SYSTEM_EXCLUSIVE" "MIDI_MESSAGE_SYSTEM_RESET" "MIDI_MESSAGE_TIMING_CLOCK" + "MIDI_MESSAGE_TUNE_REQUEST" "MOUSE_BUTTON_LEFT" "MOUSE_BUTTON_MASK_LEFT" + "MOUSE_BUTTON_MASK_MB_XBUTTON1" "MOUSE_BUTTON_MASK_MB_XBUTTON2" "MOUSE_BUTTON_MASK_MIDDLE" + "MOUSE_BUTTON_MASK_RIGHT" "MOUSE_BUTTON_MIDDLE" "MOUSE_BUTTON_NONE" "MOUSE_BUTTON_RIGHT" + "MOUSE_BUTTON_WHEEL_DOWN" "MOUSE_BUTTON_WHEEL_LEFT" "MOUSE_BUTTON_WHEEL_RIGHT" + "MOUSE_BUTTON_WHEEL_UP" "MOUSE_BUTTON_XBUTTON1" "MOUSE_BUTTON_XBUTTON2" "OK" "OP_ADD" "OP_AND" + "OP_BIT_AND" "OP_BIT_NEGATE" "OP_BIT_OR" "OP_BIT_XOR" "OP_DIVIDE" "OP_EQUAL" "OP_GREATER" + "OP_GREATER_EQUAL" "OP_IN" "OP_LESS" "OP_LESS_EQUAL" "OP_MAX" "OP_MODULE" "OP_MULTIPLY" + "OP_NEGATE" "OP_NOT" "OP_NOT_EQUAL" "OP_OR" "OP_POSITIVE" "OP_POWER" "OP_SHIFT_LEFT" + "OP_SHIFT_RIGHT" "OP_SUBTRACT" "OP_XOR" "PROPERTY_HINT_ARRAY_TYPE" + "PROPERTY_HINT_COLOR_NO_ALPHA" "PROPERTY_HINT_DIR" "PROPERTY_HINT_ENUM" + "PROPERTY_HINT_ENUM_SUGGESTION" "PROPERTY_HINT_EXPRESSION" "PROPERTY_HINT_EXP_EASING" + "PROPERTY_HINT_FILE" "PROPERTY_HINT_FLAGS" "PROPERTY_HINT_GLOBAL_DIR" + "PROPERTY_HINT_GLOBAL_FILE" "PROPERTY_HINT_GLOBAL_SAVE_FILE" + "PROPERTY_HINT_HIDE_QUATERNION_EDIT" "PROPERTY_HINT_INT_IS_OBJECTID" + "PROPERTY_HINT_INT_IS_POINTER" "PROPERTY_HINT_LAYERS_2D_NAVIGATION" + "PROPERTY_HINT_LAYERS_2D_PHYSICS" "PROPERTY_HINT_LAYERS_2D_RENDER" + "PROPERTY_HINT_LAYERS_3D_NAVIGATION" "PROPERTY_HINT_LAYERS_3D_PHYSICS" + "PROPERTY_HINT_LAYERS_3D_RENDER" "PROPERTY_HINT_LAYERS_AVOIDANCE" "PROPERTY_HINT_LINK" + "PROPERTY_HINT_LOCALE_ID" "PROPERTY_HINT_LOCALIZABLE_STRING" "PROPERTY_HINT_MAX" + "PROPERTY_HINT_MULTILINE_TEXT" "PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE" + "PROPERTY_HINT_NODE_PATH_VALID_TYPES" "PROPERTY_HINT_NODE_TYPE" "PROPERTY_HINT_NONE" + "PROPERTY_HINT_OBJECT_ID" "PROPERTY_HINT_OBJECT_TOO_BIG" "PROPERTY_HINT_PASSWORD" + "PROPERTY_HINT_PLACEHOLDER_TEXT" "PROPERTY_HINT_RANGE" "PROPERTY_HINT_RESOURCE_TYPE" + "PROPERTY_HINT_SAVE_FILE" "PROPERTY_HINT_TYPE_STRING" "PROPERTY_USAGE_ALWAYS_DUPLICATE" + "PROPERTY_USAGE_ARRAY" "PROPERTY_USAGE_CATEGORY" "PROPERTY_USAGE_CHECKABLE" + "PROPERTY_USAGE_CHECKED" "PROPERTY_USAGE_CLASS_IS_BITFIELD" "PROPERTY_USAGE_CLASS_IS_ENUM" + "PROPERTY_USAGE_DEFAULT" "PROPERTY_USAGE_DEFERRED_SET_RESOURCE" "PROPERTY_USAGE_EDITOR" + "PROPERTY_USAGE_EDITOR_BASIC_SETTING" "PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT" + "PROPERTY_USAGE_GROUP" "PROPERTY_USAGE_HIGH_END_GFX" "PROPERTY_USAGE_INTERNAL" + "PROPERTY_USAGE_KEYING_INCREMENTS" "PROPERTY_USAGE_NEVER_DUPLICATE" + "PROPERTY_USAGE_NIL_IS_VARIANT" "PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT" "PROPERTY_USAGE_NONE" + "PROPERTY_USAGE_NO_EDITOR" "PROPERTY_USAGE_NO_INSTANCE_STATE" "PROPERTY_USAGE_READ_ONLY" + "PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT" "PROPERTY_USAGE_RESTART_IF_CHANGED" + "PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE" "PROPERTY_USAGE_SCRIPT_VARIABLE" "PROPERTY_USAGE_SECRET" + "PROPERTY_USAGE_STORAGE" "PROPERTY_USAGE_STORE_IF_NULL" "PROPERTY_USAGE_SUBGROUP" + "PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED" "SIDE_BOTTOM" "SIDE_LEFT" "SIDE_RIGHT" "SIDE_TOP" + "TYPE_AABB" "TYPE_ARRAY" "TYPE_BASIS" "TYPE_BOOL" "TYPE_CALLABLE" "TYPE_COLOR" "TYPE_DICTIONARY" + "TYPE_FLOAT" "TYPE_INT" "TYPE_MAX" "TYPE_NIL" "TYPE_NODE_PATH" "TYPE_OBJECT" + "TYPE_PACKED_BYTE_ARRAY" "TYPE_PACKED_COLOR_ARRAY" "TYPE_PACKED_FLOAT32_ARRAY" + "TYPE_PACKED_FLOAT64_ARRAY" "TYPE_PACKED_INT32_ARRAY" "TYPE_PACKED_INT64_ARRAY" + "TYPE_PACKED_STRING_ARRAY" "TYPE_PACKED_VECTOR2_ARRAY" "TYPE_PACKED_VECTOR3_ARRAY" "TYPE_PLANE" + "TYPE_PROJECTION" "TYPE_QUATERNION" "TYPE_RECT2" "TYPE_RECT2I" "TYPE_RID" "TYPE_SIGNAL" + "TYPE_STRING" "TYPE_STRING_NAME" "TYPE_TRANSFORM2D" "TYPE_TRANSFORM3D" "TYPE_VECTOR2" + "TYPE_VECTOR2I" "TYPE_VECTOR3" "TYPE_VECTOR3I" "TYPE_VECTOR4" "TYPE_VECTOR4I" "VERTICAL" + "VERTICAL_ALIGNMENT_BOTTOM" "VERTICAL_ALIGNMENT_CENTER" "VERTICAL_ALIGNMENT_FILL" + "VERTICAL_ALIGNMENT_TOP")) diff --git a/runtime/queries/gdscript/indents.scm b/runtime/queries/gdscript/indents.scm new file mode 100644 index 000000000..36b989f93 --- /dev/null +++ b/runtime/queries/gdscript/indents.scm @@ -0,0 +1,78 @@ +[ + (lambda) + (function_definition) + (constructor_definition) + (for_statement) + (while_statement) + (if_statement) + (class_definition) + (match_statement) + (pattern_section) + (setget) + (match_body) + (set_body) + (get_body) +] @indent.begin + +[ + (elif_clause) + (else_clause) +] @indent.branch + +[ + (string) + (comment) + (array) + (dictionary) + (parenthesized_expression) + (ERROR) +] @indent.auto + +[ + (pass_statement) + (continue_statement) + (break_statement) + (return_statement) +] @indent.dedent + +[ + (ERROR + "[") + (ERROR + "(") + (ERROR + "{") +] @indent.begin + +; This only works with expanded tabs. +; ((parameters) @indent.align (#set! indent.open_delimiter "(") (#set! indent.close_delimiter ")")) +; ((arguments) @indent.align (#set! indent.open_delimiter "(") (#set! indent.close_delimiter ")")) +; The following queries either do not agree with the current body parsing or are +; attempted workarounds. Specifically as the last statement of a body. Opening +; a new line in between statements works well. +; +; The overall experience is poor, so I've opted for @indent.auto. +; +; The gdscript parser will need to be patched to accommodate more interactive +; edits. As far as I can tell the parser greedily consumes whitespace +; as a zero-width token which causes trouble when inserting indents. +; This indents correctly with tabs. +; (arguments) @indent.begin +; (parameters) @indent.begin +; (array) @indent.begin +; (dictionary) @indent.begin +; (parenthesized_expression) @indent.begin +; Partial workaround for when the cursor is on the bracket character and a newline +; is created with <o>. Without this the newline is opened with extra +; indentation. +; (body (_ (array "]" @indent.end) ) _) +; Problematic behaviors occur at the last statement of a body. +; with @dedent: +; - [ | ] i<CR> will dedent ] to 0. +; - [ +; ]| o will open new line at correct indentation. +; with @auto: +; - [ | ] i<CR> same +; - [ +; ]| o will open new line with extra indent. +;(body (_ (array "]" @indent.auto) ) .) diff --git a/runtime/queries/gdscript/injections.scm b/runtime/queries/gdscript/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/gdscript/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/gdscript/locals.scm b/runtime/queries/gdscript/locals.scm new file mode 100644 index 000000000..62166e6f0 --- /dev/null +++ b/runtime/queries/gdscript/locals.scm @@ -0,0 +1,121 @@ +; Scopes +[ + (if_statement) + (elif_clause) + (else_clause) + (for_statement) + (while_statement) + (function_definition) + (constructor_definition) + (class_definition) + (match_statement) + (pattern_section) + (lambda) + (get_body) + (set_body) +] @local.scope + +; Parameters +(parameters + (identifier) @local.definition.parameter) + +(default_parameter + (identifier) @local.definition.parameter) + +(typed_parameter + (identifier) @local.definition.parameter) + +(typed_default_parameter + (identifier) @local.definition.parameter) + +; Signals +; Can gdscript 2 signals be considered fields? +(signal_statement + (name) @local.definition.field) + +; Variable Definitions +(const_statement + (name) @local.definition.constant) + +; onready and export variations are only properties. +(variable_statement + (name) @local.definition.var) + +(setter) @local.reference + +(getter) @local.reference + +; Function Definition +((function_definition + (name) @local.definition.function) + (#set! definition.function.scope "parent")) + +; Lambda +; lambda names are not accessible and are only for debugging. +(lambda + (name) @local.definition.function) + +; Source +(class_name_statement + (name) @local.definition.type) + +(source + (variable_statement + (name) @local.definition.field)) + +(source + (onready_variable_statement + (name) @local.definition.field)) + +(source + (export_variable_statement + (name) @local.definition.field)) + +; Class +((class_definition + (name) @local.definition.type) + (#set! definition.type.scope "parent")) + +(class_definition + (body + (variable_statement + (name) @local.definition.field))) + +(class_definition + (body + (onready_variable_statement + (name) @local.definition.field))) + +(class_definition + (body + (export_variable_statement + (name) @local.definition.field))) + +(class_definition + (body + (signal_statement + (name) @local.definition.field))) + +; Although a script is also a class, let's only define functions in an inner class as +; methods. +((class_definition + (body + (function_definition + (name) @local.definition.method))) + (#set! definition.method.scope "parent")) + +; Enum +(enum_definition + (name) @local.definition.enum) + +; Repeat +(for_statement + . + (identifier) @local.definition.var) + +; Match Statement +(pattern_binding + (identifier) @local.definition.var) + +; References +(identifier) @local.reference diff --git a/runtime/queries/gdshader/highlights.scm b/runtime/queries/gdshader/highlights.scm new file mode 100644 index 000000000..c93fd4721 --- /dev/null +++ b/runtime/queries/gdshader/highlights.scm @@ -0,0 +1,142 @@ +[ + "render_mode" + "shader_type" + "group_uniforms" + "global" + "instance" + "const" + "varying" + "uniform" +] @keyword + +"struct" @keyword.type + +[ + (precision_qualifier) + (interpolation_qualifier) +] @keyword.modifier + +[ + "in" + "out" + "inout" +] @keyword.modifier + +[ + "while" + "for" +] @keyword.repeat + +[ + "continue" + "break" + "return" +] @keyword.return + +[ + "if" + "else" + "switch" + "case" + "default" +] @keyword.conditional + +[ + "#" + "include" +] @keyword.directive + +(string) @string + +[ + "=" + "+=" + "-=" + "!" + "~" + "+" + "-" + "*" + "/" + "%" + "||" + "&&" + "|" + "^" + "&" + "==" + "!=" + ">" + ">=" + "<=" + "<" + "<<" + ">>" + "++" + "--" +] @operator + +(boolean) @boolean + +(integer) @number + +(float) @number.float + +[ + "." + "," + ";" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(builtin_type) @type.builtin + +(ident_type) @type.definition + +[ + (shader_type) + (render_mode) + (hint_name) +] @attribute + +(builtin_variable) @constant.builtin + +(builtin_function) @function.builtin + +(group_uniforms_declaration + group_name: (ident) @property + subgroup_name: (ident) @property) + +(struct_declaration + name: (ident) @type) + +(struct_member + name: (ident) @property) + +(function_declaration + name: (ident) @function) + +(parameter + name: (ident) @variable.parameter) + +(member_expr + member: (ident) @property) + +(call_expr + function: [ + (ident) + (builtin_type) + ] @function) + +(call_expr + function: (builtin_type) @function.call) + +(comment) @comment @spell diff --git a/runtime/queries/gdshader/injections.scm b/runtime/queries/gdshader/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/gdshader/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/git_config/folds.scm b/runtime/queries/git_config/folds.scm new file mode 100644 index 000000000..cb376d5b5 --- /dev/null +++ b/runtime/queries/git_config/folds.scm @@ -0,0 +1,2 @@ +((section) @fold + (#trim! @fold)) diff --git a/runtime/queries/git_config/highlights.scm b/runtime/queries/git_config/highlights.scm new file mode 100644 index 000000000..6b37e9090 --- /dev/null +++ b/runtime/queries/git_config/highlights.scm @@ -0,0 +1,59 @@ +; Sections +(section_name) @markup.heading + +((section_name) @keyword.import + (#eq? @keyword.import "include")) + +((section_header + (section_name) @keyword.import + (subsection_name)) + (#eq? @keyword.import "includeIf")) + +(variable + (name) @property) + +; Operators +"=" @operator + +; Literals +(integer) @number + +[ + (true) + (false) +] @boolean + +(string) @string + +(escape_sequence) @string.escape + +((string) @string.special.path + (#lua-match? @string.special.path "^[.]?[.]?[/]")) + +((string) @string.special.path + (#lua-match? @string.special.path "^[~]")) + +(section_header + [ + "\"" + (subsection_name) + ] @string.special) + +((section_header + (section_name) @_name + (subsection_name) @string.special.url) + (#any-of? @_name "credential" "url")) + +((variable + (name) @_name + value: (string) @string.special.url) + (#eq? @_name "insteadOf")) + +; Punctuation +[ + "[" + "]" +] @punctuation.bracket + +; Comments +(comment) @comment @spell diff --git a/runtime/queries/git_config/injections.scm b/runtime/queries/git_config/injections.scm new file mode 100644 index 000000000..7bda6979c --- /dev/null +++ b/runtime/queries/git_config/injections.scm @@ -0,0 +1,69 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((variable + (name) @_name + value: (string) @injection.content) + (#any-of? @_name "cmd" "command" "textconv" "sendmailCmd") + (#set! injection.language "bash")) + +(section + (variable + (name) @_name + value: (string) @injection.content) + (#eq? @_name "tool") + (#set! injection.language "bash")) + +(section + (section_header + (section_name) @_pager) + (variable + value: (string) @injection.content) + (#eq? @_pager "pager") + (#set! injection.language "bash")) + +(section + (section_header + (section_name) @_interactive) + (variable + (name) @_name + value: (string) @injection.content) + (#eq? @_interactive "interactive") + (#eq? @_name "diffFilter") + (#set! injection.language "bash")) + +; https://github.com/git-lfs/git-lfs +; git lfs install +(section + (section_header + (section_name) @_filter + (subsection_name) @_lfs) + (variable + (name) @_name + value: (string) @injection.content) + (#eq? @_filter "filter") + (#eq? @_lfs "lfs") + (#any-of? @_name "smudge" "process" "clean") + (#set! injection.language "bash")) + +(section + (section_header + (section_name) @_alias) + (variable + value: (string) @injection.content) + (#eq? @_alias "alias") + (#lua-match? @injection.content "^!") + (#offset! @injection.content 0 1 0 0) + (#set! injection.language "bash")) + +(section + (section_header + (section_name) @_alias) + (variable + value: (string + "\"" + "\"") @injection.content) + (#eq? @_alias "alias") + (#lua-match? @injection.content "^\"!") + (#offset! @injection.content 0 2 0 -1) + (#set! injection.language "bash")) diff --git a/runtime/queries/git_rebase/highlights.scm b/runtime/queries/git_rebase/highlights.scm new file mode 100644 index 000000000..248366e24 --- /dev/null +++ b/runtime/queries/git_rebase/highlights.scm @@ -0,0 +1,7 @@ +((command) @keyword + (label)? @constant + (message)? @none @spell) + +(option) @operator + +(comment) @comment diff --git a/runtime/queries/git_rebase/injections.scm b/runtime/queries/git_rebase/injections.scm new file mode 100644 index 000000000..c831594bd --- /dev/null +++ b/runtime/queries/git_rebase/injections.scm @@ -0,0 +1,8 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((operation + (command) @_command + (message) @injection.content) + (#set! injection.language "bash") + (#any-of? @_command "exec" "x")) diff --git a/runtime/queries/gitattributes/highlights.scm b/runtime/queries/gitattributes/highlights.scm new file mode 100644 index 000000000..aec7750f6 --- /dev/null +++ b/runtime/queries/gitattributes/highlights.scm @@ -0,0 +1,55 @@ +(dir_sep) @punctuation.delimiter + +(quoted_pattern + "\"" @punctuation.special) + +(range_notation) @string.special + +(range_notation + [ + "[" + "]" + ] @punctuation.bracket) + +(wildcard) @character.special + +(range_negation) @operator + +(character_class) @constant + +(class_range + "-" @operator) + +[ + (ansi_c_escape) + (escaped_char) +] @string.escape + +(attribute + (attr_name) @variable.parameter) + +(attribute + (builtin_attr) @variable.builtin) + +[ + (attr_reset) + (attr_unset) + (attr_set) +] @operator + +(boolean_value) @boolean + +(string_value) @string + +(macro_tag) @keyword.directive + +(macro_def + macro_name: (_) @property) + +; we do not lint syntax errors +; [ +; (pattern_negation) +; (redundant_escape) +; (trailing_slash) +; ] @error +(comment) @comment @spell diff --git a/runtime/queries/gitattributes/injections.scm b/runtime/queries/gitattributes/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/gitattributes/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/gitattributes/locals.scm b/runtime/queries/gitattributes/locals.scm new file mode 100644 index 000000000..2471b8bc6 --- /dev/null +++ b/runtime/queries/gitattributes/locals.scm @@ -0,0 +1,8 @@ +(macro_def + (attr_name) @local.definition.macro) + +(attribute + (attr_name) @local.reference) + +(attribute + (builtin_attr) @local.reference) diff --git a/runtime/queries/gitcommit/highlights.scm b/runtime/queries/gitcommit/highlights.scm new file mode 100644 index 000000000..b096056cc --- /dev/null +++ b/runtime/queries/gitcommit/highlights.scm @@ -0,0 +1,49 @@ +(comment) @comment + +(generated_comment) @comment + +(title) @markup.heading + +; (text) @none +(branch) @markup.link + +(change) @keyword + +(filepath) @string.special.path + +(arrow) @punctuation.delimiter + +(subject) @markup.heading @spell + +(subject + (subject_prefix) @function @nospell) + +(prefix + (type) @keyword @nospell) + +(prefix + (scope) @variable.parameter @nospell) + +(prefix + [ + "(" + ")" + ":" + ] @punctuation.delimiter) + +(prefix + "!" @punctuation.special) + +(message) @spell + +(trailer + (token) @label) + +; (trailer (value) @none) +(breaking_change + (token) @comment.error) + +(breaking_change + (value) @none @spell) + +(scissor) @comment diff --git a/runtime/queries/gitcommit/injections.scm b/runtime/queries/gitcommit/injections.scm new file mode 100644 index 000000000..5613d7e8e --- /dev/null +++ b/runtime/queries/gitcommit/injections.scm @@ -0,0 +1,5 @@ +((diff) @injection.content + (#set! injection.language "diff")) + +((rebase_command) @injection.content + (#set! injection.language "git_rebase")) diff --git a/runtime/queries/gitignore/highlights.scm b/runtime/queries/gitignore/highlights.scm new file mode 100644 index 000000000..aafbe541e --- /dev/null +++ b/runtime/queries/gitignore/highlights.scm @@ -0,0 +1,36 @@ +(comment) @comment @spell + +(pattern_char) @string.special.path + +[ + (directory_separator) + (directory_separator_escaped) +] @punctuation.delimiter + +[ + (wildcard_char_single) + (wildcard_chars) + (wildcard_chars_allow_slash) +] @character.special + +[ + (pattern_char_escaped) + (bracket_char_escaped) +] @string.escape + +(negation) @punctuation.special + +(bracket_negation) @operator + +; bracket expressions +[ + "[" + "]" +] @punctuation.bracket + +(bracket_char) @constant + +(bracket_range + "-" @operator) + +(bracket_char_class) @constant.builtin diff --git a/runtime/queries/gitignore/injections.scm b/runtime/queries/gitignore/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/gitignore/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/gleam/folds.scm b/runtime/queries/gleam/folds.scm new file mode 100644 index 000000000..b4cd225e7 --- /dev/null +++ b/runtime/queries/gleam/folds.scm @@ -0,0 +1,7 @@ +; Folds +[ + (case) + (function) + (anonymous_function) + (type_definition) +] @fold diff --git a/runtime/queries/gleam/highlights.scm b/runtime/queries/gleam/highlights.scm new file mode 100644 index 000000000..f80bda240 --- /dev/null +++ b/runtime/queries/gleam/highlights.scm @@ -0,0 +1,200 @@ +; Keywords +[ + "as" + "let" + "panic" + "todo" + "use" + "echo" +] @keyword + +"type" @keyword.type + +; Function Keywords +"fn" @keyword.function + +; Imports +"import" @keyword.import + +; Conditionals +[ + "case" + "if" +] @keyword.conditional + +; Exceptions +"assert" @keyword.exception + +; Punctuation +[ + "(" + ")" + "<<" + ">>" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "," + "." + ":" + "->" +] @punctuation.delimiter + +"#" @punctuation.special + +; Operators +[ + "%" + "&&" + "*" + "*." + "+" + "+." + "-" + "-." + ".." + "/" + "/." + "<" + "<." + "<=" + "<=." + "=" + "==" + ">" + ">." + ">=" + ">=." + "|>" + "||" +] @operator + +; Identifiers +(identifier) @variable + +; Comments +(comment) @comment @spell + +[ + (module_comment) + (statement_comment) +] @comment.documentation @spell + +; Unused Identifiers +[ + (discard) + (hole) +] @comment + +; Modules & Imports +(module) @module + +(import + alias: ((identifier) @module)?) + +(remote_type_identifier + module: (identifier) @module) + +(unqualified_import + name: (identifier) @function) + +; Strings +(string) @string + +; Bit Strings +(bit_string_segment) @string.special + +; Numbers +(integer) @number + +(float) @number.float + +; Function Parameter Labels +(function_call + arguments: (arguments + (argument + label: (label) @label))) + +(function_parameter + label: (label)? @label + name: (identifier) @variable.parameter) + +; Records +(record + arguments: (arguments + (argument + label: (label) @variable.member)?)) + +(record_pattern_argument + label: (label) @variable.member) + +(record_update_argument + label: (label) @variable.member) + +(field_access + record: (identifier) @variable + field: (label) @variable.member) + +(data_constructor_argument + (label) @variable.member) + +; Types +[ + (type_identifier) + (type_parameter) + (type_var) +] @type + +; Type Qualifiers +[ + "const" + "external" + (opacity_modifier) + (visibility_modifier) +] @keyword.modifier + +; Tuples +(tuple_access + index: (integer) @operator) + +; Functions +(function + name: (identifier) @function) + +(function_call + function: (identifier) @function.call) + +(function_call + function: (field_access + field: (label) @function.call)) + +; External Functions +(external_function + name: (identifier) @function) + +(external_function_body + (string) @module + . + (string) @function) + +; Constructors +(constructor_name) @type @constructor + +([ + (type_identifier) + (constructor_name) +] @constant.builtin + (#any-of? @constant.builtin "Ok" "Error")) + +; Booleans +((constructor_name) @boolean + (#any-of? @boolean "True" "False")) + +; Pipe Operator +(binary_expression + operator: "|>" + right: (identifier) @function) diff --git a/runtime/queries/gleam/indents.scm b/runtime/queries/gleam/indents.scm new file mode 100644 index 000000000..3a44ea4c0 --- /dev/null +++ b/runtime/queries/gleam/indents.scm @@ -0,0 +1,30 @@ +; Gleam indents similar to Rust and JavaScript +[ + (anonymous_function) + (assert) + (case) + (case_clause) + (constant) + (external_function) + (function) + (let) + (list) + (constant) + (function) + (type_definition) + (type_alias) + (todo) + (tuple) + (unqualified_imports) +] @indent.begin + +[ + ")" + "]" + "}" +] @indent.end @indent.branch + +; Gleam pipelines are not indented, but other binary expression chains are +((binary_expression + operator: _ @_operator) @indent.begin + (#not-eq? @_operator "|>")) diff --git a/runtime/queries/gleam/injections.scm b/runtime/queries/gleam/injections.scm new file mode 100644 index 000000000..11d4f5d55 --- /dev/null +++ b/runtime/queries/gleam/injections.scm @@ -0,0 +1,7 @@ +; Comments +([ + (module_comment) + (statement_comment) + (comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/gleam/locals.scm b/runtime/queries/gleam/locals.scm new file mode 100644 index 000000000..0058b660e --- /dev/null +++ b/runtime/queries/gleam/locals.scm @@ -0,0 +1,31 @@ +; Let Binding Definition +(let + pattern: (identifier) @local.definition) + +; List Pattern Definitions +(list_pattern + (identifier) @local.definition) + +(list_pattern + assign: (identifier) @local.definition) + +; Tuple Pattern Definition +(tuple_pattern + (identifier) @local.definition) + +; Record Pattern Definition +(record_pattern_argument + pattern: (identifier) @local.definition) + +; Function Parameter Definition +(function_parameter + name: (identifier) @local.definition) + +; References +(identifier) @local.reference + +; Block Scope +(block) @local.scope + +; Case Scope +(case_clause) @local.scope diff --git a/runtime/queries/glimmer/folds.scm b/runtime/queries/glimmer/folds.scm new file mode 100644 index 000000000..6502455d8 --- /dev/null +++ b/runtime/queries/glimmer/folds.scm @@ -0,0 +1,5 @@ +[ + (element_node + (element_node_start)) + (block_statement) +] @fold diff --git a/runtime/queries/glimmer/highlights.scm b/runtime/queries/glimmer/highlights.scm new file mode 100644 index 000000000..9f11468d4 --- /dev/null +++ b/runtime/queries/glimmer/highlights.scm @@ -0,0 +1,117 @@ +; === Tag Names === +; Tags that start with a lower case letter are HTML tags +; We'll also use this highlighting for named blocks (which start with `:`) +((tag_name) @tag + (#lua-match? @tag "^:?[%l]")) + +; Tags that start with a capital letter are Glimmer components +((tag_name) @constructor + (#lua-match? @constructor "^%u")) + +(attribute_name) @attribute + +(string_literal) @string + +(number_literal) @number + +(boolean_literal) @boolean + +(concat_statement) @string + +; === Block Statements === +; Highlight the brackets +(block_statement_start) @tag.delimiter + +(block_statement_end) @tag.delimiter + +; Highlight `if`/`each`/`let` +(block_statement_start + path: (identifier) @keyword.conditional) + +(block_statement_end + path: (identifier) @keyword.conditional) + +((mustache_statement + (identifier) @keyword.conditional) + (#lua-match? @keyword.conditional "else")) + +; == Mustache Statements === +; Highlight the whole statement, to color brackets and separators +(mustache_statement) @tag.delimiter + +; An identifier in a mustache expression is a variable +((mustache_statement + [ + (path_expression + (identifier) @variable) + (identifier) @variable + ]) + (#not-any-of? @variable "yield" "outlet" "this" "else")) + +; As are arguments in a block statement +(block_statement_start + argument: [ + (path_expression + (identifier) @variable) + (identifier) @variable + ]) + +; As is an identifier in a block param +(block_params + (identifier) @variable) + +; As are helper arguments +((helper_invocation + argument: [ + (path_expression + (identifier) @variable) + (identifier) @variable + ]) + (#not-eq? @variable "this")) + +; `this` should be highlighted as a built-in variable +((identifier) @variable.builtin + (#eq? @variable.builtin "this")) + +; If the identifier is just "yield" or "outlet", it's a keyword +((mustache_statement + (identifier) @keyword) + (#any-of? @keyword "yield" "outlet")) + +; Helpers are functions +((helper_invocation + helper: [ + (path_expression + (identifier) @function) + (identifier) @function + ]) + (#not-any-of? @function "if" "yield")) + +((helper_invocation + helper: (identifier) @keyword.conditional) + (#eq? @keyword.conditional "if")) + +((helper_invocation + helper: (identifier) @keyword) + (#eq? @keyword "yield")) + +(hash_pair + key: (identifier) @property) + +(comment_statement) @comment @spell + +(attribute_node + "=" @operator) + +(block_params + "as" @keyword) + +(block_params + "|" @operator) + +[ + "<" + ">" + "</" + "/>" +] @tag.delimiter diff --git a/runtime/queries/glimmer/indents.scm b/runtime/queries/glimmer/indents.scm new file mode 100644 index 000000000..c1ef130c0 --- /dev/null +++ b/runtime/queries/glimmer/indents.scm @@ -0,0 +1,34 @@ +[ + (element_node + (element_node_start)) + (element_node_void) + (block_statement + (block_statement_start)) + (mustache_statement) +] @indent.begin + +(element_node + (element_node_end + ">" @indent.end)) + +(element_node_void + "/>" @indent.end) + +[ + ">" + "/>" + "</" + "{{/" + "}}" +] @indent.branch + +(mustache_statement + (helper_invocation + helper: (identifier) @_identifier + (#eq? @_identifier "else"))) @indent.branch + +(mustache_statement + ((identifier) @_identifier + (#eq? @_identifier "else"))) @indent.branch + +(comment_statement) @indent.ignore diff --git a/runtime/queries/glimmer/injections.scm b/runtime/queries/glimmer/injections.scm new file mode 100644 index 000000000..30b438682 --- /dev/null +++ b/runtime/queries/glimmer/injections.scm @@ -0,0 +1,21 @@ +; comments +((comment_statement) @injection.content + (#set! injection.language "comment")) + +; <style> tags +((element_node + (element_node_start + (tag_name) @_tag_name + (#eq? @_tag_name "style"))) @injection.content + (#offset! @injection.content 0 7 0 -8) + (#set! injection.language "css") + (#set! injection.include-children)) + +; <script> tags +((element_node + (element_node_start + (tag_name) @_tag_name + (#eq? @_tag_name "script"))) @injection.content + (#offset! @injection.content 0 8 0 -9) + (#set! injection.language "glimmer_javascript") + (#set! injection.include-children)) diff --git a/runtime/queries/glimmer/locals.scm b/runtime/queries/glimmer/locals.scm new file mode 100644 index 000000000..8fde3a297 --- /dev/null +++ b/runtime/queries/glimmer/locals.scm @@ -0,0 +1,9 @@ +[ + (element_node) + (block_statement) +] @local.scope + +(identifier) @local.reference + +(block_params + (identifier) @local.definition.var) diff --git a/runtime/queries/glimmer_javascript/highlights.scm b/runtime/queries/glimmer_javascript/highlights.scm new file mode 100644 index 000000000..5bec5b149 --- /dev/null +++ b/runtime/queries/glimmer_javascript/highlights.scm @@ -0,0 +1,61 @@ +; inherits: ecma + +(glimmer_opening_tag) @tag.builtin + +(glimmer_closing_tag) @tag.builtin + +; Copied from javascript +; Parameters +(formal_parameters + (identifier) @variable.parameter) + +(formal_parameters + (rest_pattern + (identifier) @variable.parameter)) + +; ({ a }) => null +(formal_parameters + (object_pattern + (shorthand_property_identifier_pattern) @variable.parameter)) + +; ({ a = b }) => null +(formal_parameters + (object_pattern + (object_assignment_pattern + (shorthand_property_identifier_pattern) @variable.parameter))) + +; ({ a: b }) => null +(formal_parameters + (object_pattern + (pair_pattern + value: (identifier) @variable.parameter))) + +; ([ a ]) => null +(formal_parameters + (array_pattern + (identifier) @variable.parameter)) + +; ({ a } = { a }) => null +(formal_parameters + (assignment_pattern + (object_pattern + (shorthand_property_identifier_pattern) @variable.parameter))) + +; ({ a = b } = { a }) => null +(formal_parameters + (assignment_pattern + (object_pattern + (object_assignment_pattern + (shorthand_property_identifier_pattern) @variable.parameter)))) + +; a => null +(arrow_function + parameter: (identifier) @variable.parameter) + +; optional parameters +(formal_parameters + (assignment_pattern + left: (identifier) @variable.parameter)) + +; punctuation +(optional_chain) @punctuation.delimiter diff --git a/runtime/queries/glimmer_javascript/indents.scm b/runtime/queries/glimmer_javascript/indents.scm new file mode 100644 index 000000000..2bf2b7801 --- /dev/null +++ b/runtime/queries/glimmer_javascript/indents.scm @@ -0,0 +1,5 @@ +; inherits: ecma + +(glimmer_opening_tag) @indent.begin + +(glimmer_closing_tag) @indent.end diff --git a/runtime/queries/glimmer_javascript/injections.scm b/runtime/queries/glimmer_javascript/injections.scm new file mode 100644 index 000000000..174372a48 --- /dev/null +++ b/runtime/queries/glimmer_javascript/injections.scm @@ -0,0 +1,7 @@ +; inherits: ecma + +; Ember Unified <template> syntax +; e.g.: <template><SomeComponent @arg={{double @value}} /></template> +((glimmer_template) @injection.content + (#set! injection.language "glimmer") + (#set! injection.include-children)) diff --git a/runtime/queries/glimmer_javascript/locals.scm b/runtime/queries/glimmer_javascript/locals.scm new file mode 100644 index 000000000..04328f099 --- /dev/null +++ b/runtime/queries/glimmer_javascript/locals.scm @@ -0,0 +1 @@ +; inherits: ecma diff --git a/runtime/queries/glimmer_typescript/highlights.scm b/runtime/queries/glimmer_typescript/highlights.scm new file mode 100644 index 000000000..042387b21 --- /dev/null +++ b/runtime/queries/glimmer_typescript/highlights.scm @@ -0,0 +1,6 @@ +; inherits: typescript + +; Sub-language delimeters +(glimmer_opening_tag) @tag.builtin + +(glimmer_closing_tag) @tag.builtin diff --git a/runtime/queries/glimmer_typescript/indents.scm b/runtime/queries/glimmer_typescript/indents.scm new file mode 100644 index 000000000..237254d4c --- /dev/null +++ b/runtime/queries/glimmer_typescript/indents.scm @@ -0,0 +1,3 @@ +(glimmer_opening_tag) @indent.begin + +(glimmer_closing_tag) @indent.end diff --git a/runtime/queries/glimmer_typescript/injections.scm b/runtime/queries/glimmer_typescript/injections.scm new file mode 100644 index 000000000..4c79d635a --- /dev/null +++ b/runtime/queries/glimmer_typescript/injections.scm @@ -0,0 +1,7 @@ +; inherits: typescript + +; Ember Unified <template> syntax +; e.g.: <template><SomeComponent @arg={{double @value}} /></template> +((glimmer_template) @injection.content + (#set! injection.language "glimmer") + (#set! injection.include-children)) diff --git a/runtime/queries/glsl/folds.scm b/runtime/queries/glsl/folds.scm new file mode 100644 index 000000000..a5a5208ca --- /dev/null +++ b/runtime/queries/glsl/folds.scm @@ -0,0 +1 @@ +; inherits: c diff --git a/runtime/queries/glsl/highlights.scm b/runtime/queries/glsl/highlights.scm new file mode 100644 index 000000000..d4583f0ea --- /dev/null +++ b/runtime/queries/glsl/highlights.scm @@ -0,0 +1,35 @@ +; inherits: c + +[ + "in" + "out" + "inout" + "uniform" + "shared" + "layout" + "attribute" + "varying" + "buffer" + "coherent" + "readonly" + "writeonly" + "precision" + "highp" + "mediump" + "lowp" + "centroid" + "sample" + "patch" + "smooth" + "flat" + "noperspective" + "invariant" + "precise" +] @keyword.modifier + +"subroutine" @keyword.function + +(extension_storage_class) @keyword.modifier + +((identifier) @variable.builtin + (#lua-match? @variable.builtin "^gl_")) diff --git a/runtime/queries/glsl/indents.scm b/runtime/queries/glsl/indents.scm new file mode 100644 index 000000000..a5a5208ca --- /dev/null +++ b/runtime/queries/glsl/indents.scm @@ -0,0 +1 @@ +; inherits: c diff --git a/runtime/queries/glsl/injections.scm b/runtime/queries/glsl/injections.scm new file mode 100644 index 000000000..a5a5208ca --- /dev/null +++ b/runtime/queries/glsl/injections.scm @@ -0,0 +1 @@ +; inherits: c diff --git a/runtime/queries/glsl/locals.scm b/runtime/queries/glsl/locals.scm new file mode 100644 index 000000000..a5a5208ca --- /dev/null +++ b/runtime/queries/glsl/locals.scm @@ -0,0 +1 @@ +; inherits: c diff --git a/runtime/queries/gn/folds.scm b/runtime/queries/gn/folds.scm new file mode 100644 index 000000000..352b0f0ec --- /dev/null +++ b/runtime/queries/gn/folds.scm @@ -0,0 +1,6 @@ +[ + (list) + (block) + (if_statement) + (else_statement) +] @fold diff --git a/runtime/queries/gn/highlights.scm b/runtime/queries/gn/highlights.scm new file mode 100644 index 000000000..7bd97ff38 --- /dev/null +++ b/runtime/queries/gn/highlights.scm @@ -0,0 +1,78 @@ +; Includes +"import" @keyword.import + +; Conditionals +[ + "if" + "else" +] @keyword.conditional + +; Repeats +"foreach" @keyword.repeat + +; Operators +[ + "=" + "+=" + "-=" + "!" + "+" + "-" + "<" + "<=" + ">" + ">=" + "==" + "!=" + "&&" + "||" +] @operator + +; Variables +(identifier) @variable + +; Functions +(call_expression + function: (identifier) @function.call) + +; Fields +(scope_access + field: (identifier) @variable.member) + +; Literals +(string) @string + +(escape_sequence) @string.escape + +(expansion) @none + +(integer) @number + +(hex) @string.special + +(boolean) @boolean + +; Punctuation +[ + "{" + "}" + "[" + "]" + "(" + ")" +] @punctuation.bracket + +[ + "." + "," +] @punctuation.delimiter + +(expansion + [ + "$" + "${" + "}" + ] @punctuation.special) + +; Comments +(comment) @comment diff --git a/runtime/queries/gn/indents.scm b/runtime/queries/gn/indents.scm new file mode 100644 index 000000000..82f44711d --- /dev/null +++ b/runtime/queries/gn/indents.scm @@ -0,0 +1,12 @@ +[ + (block) + (parenthesized_expression) +] @indent.begin + +[ + "}" + ")" + "]" +] @indent.end @indent.branch + +(comment) @indent.auto diff --git a/runtime/queries/gn/injections.scm b/runtime/queries/gn/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/gn/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/gn/locals.scm b/runtime/queries/gn/locals.scm new file mode 100644 index 000000000..eecb3426a --- /dev/null +++ b/runtime/queries/gn/locals.scm @@ -0,0 +1,6 @@ +[ + (source_file) + (block) +] @local.scope + +(identifier) @local.reference diff --git a/runtime/queries/gnuplot/highlights.scm b/runtime/queries/gnuplot/highlights.scm new file mode 100644 index 000000000..884c7263d --- /dev/null +++ b/runtime/queries/gnuplot/highlights.scm @@ -0,0 +1,648 @@ +; highlights.scm +(comment) @comment @spell + +(identifier) @variable + +[ + "-" + "+" + "~" + "!" + "$" + "|" + "**" + "*" + "/" + "%" + "==" + "!=" + "<" + "<=" + ">" + ">=" + "<<" + ">>" + "&" + "^" + "&&" + "||" + "=" + "," + "." +] @operator + +[ + "eq" + "ne" +] @keyword.operator + +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +"sum" @function.builtin + +[ + "for" + "in" + "do" + "while" +] @keyword.repeat + +[ + (c_break) + (c_cd) + (c_clear) + "evaluate" + "fit" + "help" + "load" + "lower" + "print" + (c_replot) + (c_reread) + "reset" + "splot" + "cmd" + "test" + "undefine" + "vfill" +] @keyword + +(c_pause + "pause" @keyword + "mouse" @variable.member + _? @attribute + ("," + _ @attribute)?) + +(c_plot + "plot" @keyword) + +(c_show + "show" @keyword + "plot"? @attribute) + +(c_stats + "stats" @keyword + ("name" + (_))? @variable.member) + +[ + "via" + "inverse" + "sample" +] @keyword.function + +[ + "if" + "else" +] @keyword.conditional + +(plot_element + "axes"? @variable.member) + +(cntrparam + "auto"? @variable.member) + +(colorbox + "origin"? @attribute) + +(contourfill + "auto"? @variable.member) + +(format + _? @attribute + (_) + _? @attribute) + +(key + "auto"? @variable.member) + +(style ; TODO: complete + [ + "arrow" + "boxplot" + ("data" + [ + (_) + "spiderplot" @attribute + ]) + "fs" + "function" + "line" + "circle" + "rectangle" + "ellipse" + "parallelaxis" + ; (spiderplot) ; TODO: complete + "textbox" + ("watchpoint" + "labels" @attribute + (_)?) + ] @variable.member) + +(terminal + "name" @variable.member) + +; TODO: complete terminals in grammar and then simplify its options here +(t_cairolatex + [ + "eps" + "pdf" + "png" + "standalone" + "input" + "blacktext" + "colortext" + "colourtext" + ("header" + (_)) + "mono" + "color" + "background" + "rounded" + "butt" + ]* @attribute) + +; (t_canvas) +; (t_cgm) +; (t_context) +; (t_domterm) +; (t_dumb) +; (t_dxf) +; (t_emf) +; (t_epscairo) +; (t_epslatex) +; (t_fig) +; (t_gif) +; (t_hpgl) +; (t_jpeg) +; (t_lua) +; (t_pc15) +; (t_pdfcairo) +; (t_png) +; (t_pngcairo) +; (t_postscript) +; (t_pslatex) +; (t_pstricks) +; (t_qt) +; (t_sixelgd) +; (t_svg [(font_spec)]* @attribute) +; (t_tek4xxx) +; (t_texdraw) +; (t_tikz) +; (t_tkcanvas) +(plot_style + [ + "lines" + "points" + "lp" + "financebars" + "dots" + "impulses" + "labels" + "surface" + "steps" + "fsteps" + "histeps" + "arrows" + "vectors" + "sectors" + "contourfill" + "errorbar" + "errorlines" + "parallelaxes" + "boxes" + "boxerrorbars" + "boxxyerror" + "isosurface" + "boxplot" + "candlesticks" + "circles" + "zerrorfill" + "ellipses" + "filledcurves" + "fillsteps" + "histograms" + "image" + "spiderplot" + "pm3d" + "rgbalpha" + "rgbimage" + "polygons" + "table" + "mask" + ] @attribute) + +[ + "tc" + "fc" + "fs" + "lc" + "ls" + "lw" + "lt" + "pt" + "ps" + "pi" + "pn" + "dt" + "as" + "start" + "cycles" + "saturation" + "interval" + "format" + "keywidth" + "samplen" + "columns" + "title" + "notitle" + "every" + "index" + "using" + "with" + "frac" + "cb" + "arg" + "prefix" + "output" + "primary" + "specular" + "spec2" + "firstlinetype" + "width" + "height" + "expand" + "array" + "dx" + "dy" + "dz" + "filetype" + "center" + "record" +] @variable.member + +; Workaround because formatter cannot handle 300 list nodes +[ + (angles) + (clip) + (colorsequence) + (contour) + (encoding) + (mapping) + (xdata) + (theta) + "wall" + "on" + "off" + "opaque" + "inside" + "outside" + "margin" + "cen" + "lef" + "rig" + "top" + "bot" + "lr" + "a" + "maxcols" + "maxrows" + "autojustify" + "overlap" + "spread" + "wrap" + "swarm" + "range" + "label" + "mixed" + "triangles" + "insidecolor" + "noinsidecolor" + "cycle" + "tics" + "ztics" + "cbtics" + "user" + "front" + "back" + "bdefault" + "time" + "palette" + "terminal" + "onecolor" + "invert" + "reverse" + "writeback" + "extend" + "restore" + "linear" + "cubicspline" + "bspline" + "points" + "order" + "levels" + "sorted" + "autofreq" + "add" + "inout" + "axis" + "mirror" + "type" + "rowsfirst" + "columnsfirst" + "downwards" + "upwards" + "prevnext" + "gray" + "color" + "gamma" + "defined" + "cubehelix" + "model" + "maxcolors" + "file" + "colormap" + "rgbformulae" + "viridis" + "positive" + "negative" + "nops_allcF" + "ps_allcF" + "quiet" + "full" + "trip" + "numbers" + "small" + "large" + "fullwidth" + "append" + "bind" + "errors" + "session" + "behind" + "polar" + "layerdefault" + "locale" + "axes" + "fix" + "keepfix" + "noextend" + "head" + "fixed" + "filled" + "nofilled" + "absolute" + "at" + "relative" + "enhanced" + "border" + "noborder" + "rgbcolor" + "empty" + "black" + "bgnd" + "nodraw" + "size" + "new" + "first" + "second" + "screen" + "graph" + "character" + "trianglepattern" + "undefined" + "noundefined" + "altdiagonal" + "bentover" + "vertical" + "horizontal" + "square" + "ratio" + "noratio" + "solid" + "transparent" + "pattern" + "from" + "to_rto" + "length" + "angle" + "columnheaders" + "fortran" + "nofpe_trap" + "missing" + "separator" + "commentschars" + "log" + "rangelimited" + "offset" + "nooffset" + "scale" + "font" + "point" + "nopoint" + "boxed" + "noboxed" + "hypertext" + "defaults" + "keyentry" + "splines" + "qnorm" + "gauss" + "cauchy" + "exp" + "box" + "hann" + "implicit" + "explicit" + "rotate" + "by" + "parallel" + "norotate" + "map" + "projection" + "equal" + "azimuth" + "nohidden3d" + "nocontours" + "nosurface" + "colornames" + "functions" + "variables" + "version" + "nologfile" + "logfile" + "fit_out" + "errorvariables" + "covariancevariables" + "errorscaling" + "prescale" + "maxiter" + "limit" + "limit_abs" + "start-lambda" + "lambda-factor" + "script" + "clip" + "fontscale" + "lighting" + "depthorder" + "interpolate" + "corners2color" + "flush" + "scanorder" + "hidden3d" + "clipcb" + "layout" + "margins" + "spacing" + "smooth" + "binary" + "skip" + "bins" + "binrange" + "binwidth" + "binvalue" + "mask" + "convexhull" + "concavehull" + "volatile" + "zsort" + "nonuniform" + "sparse" + "matrix" +] @attribute + +[ + "x1" + "x2" + "y1" + "y2" + "y" + "r" + "z" + "xy" + "xz" + "yz" + "xyz" + "x1y1" + "x2y2" + "x1y2" + "x2y1" + "columnheader" + "seconds" + "minutes" + "hours" + "days" + "weeks" + "months" + "years" + "cm" + "in" + "discrete" + "incremental" + "default" + "long" + "nogrid" + "unique" + "frequency" + "fnormal" + "cumulative" + "cnormal" + "csplines" + "acsplines" + "mcsplines" + "path" + "bezier" + "sbezier" + "unwrap" + "kdensity" + "closed" + "between" + "above" + "below" + "variable" + "pixels" + "RGB" + "CMY" + "HSV" + "base" + "begin" + "center" + "end" + "ftriangles" + "clip1in" + "clip4in" + "c2c" + "retrace" + "whitespace" + "tab" + "comma" + "push" + "pop" + "flipx" + "flipy" + "flipz" +] @variable.member + +(colorspec + "palette" @attribute) + +(datafile_modifiers + "origin"? @variable.member) + +((datafile_modifiers + filetype: (identifier) @variable.member) + (#any-of? @variable.member + "avs" "bin" "edf" "ehf" "gif" "gpbin" "jpeg" "jpg" "png" "raw" "rgb" "auto")) + +(macro) @function.macro + +(datablock) @function.macro + +(function + name: (identifier) @function) + +((function + name: (identifier) @function.builtin) + (#any-of? @function.builtin + "abs" "acos" "acosh" "airy" "arg" "asin" "asinh" "atan" "atan2" "atanh" "besj0" "besj1" "besjn" + "besy0" "besy1" "besyn" "besi0" "besi1" "besin" "cbrt" "ceil" "conj" "cos" "cosh" "EllipticK" + "EllipticE" "EllipticPi" "erf" "erfc" "exp" "expint" "floor" "gamma" "ibeta" "inverf" "igamma" + "imag" "int" "invnorm" "invibeta" "invigamma" "LambertW" "lambertw" "lgamma" "lnGamma" "log" + "log10" "norm" "rand" "real" "round" "sgn" "sin" "sinh" "sqrt" "SynchrotronF" "tan" "tanh" + "uigamma" "voigt" "zeta" "cerf" "cdawson" "faddeva" "erfi" "FresnelC" "FresnelS" "VP" "VP_fwhm" + "Ai" "Bi" "BesselH1" "BesselH2" "BesselJ" "BesselY" "BesselI" "BesselK" "gprintf" "sprintf" + "strlen" "strstrt" "substr" "strptime" "srtftime" "system" "trim" "word" "words" "time" + "timecolumn" "tm_hour" "tm_mday" "tm_min" "tm_mon" "tm_sec" "tm_wday" "tm_week" "tm_yday" + "tm_year" "weekday_iso" "weekday_cdc" "column" "columnhead" "exists" "hsv2rgb" "index" "palette" + "rgbcolor" "stringcolumn" "valid" "value" "voxel")) + +((identifier) @variable.builtin + (#match? @variable.builtin + "^\\w+_(records|headers|outofrange|invalid|blank|blocks|columns|column_header|index_(min|max)(_x|_y)?|(min|max)(_x|_y)?|mean(_err)?(_x|_y)?|stddev(_err)?(_x|_y)?)$")) + +((identifier) @variable.builtin + (#match? @variable.builtin + "^\\w+_(sdd(_x|_y)?|(lo|up)_quartile(_x|_y)?|median(_x|_y)?|sum(sq)?(_x|_y)?|skewness(_err)?(_x|_y)?)$")) + +((identifier) @variable.builtin + (#match? @variable.builtin + "^\\w+_(kurtosis(_err)?(_x|_y)?|adev(_x|_y)?|correlation|slope(_err)?|intercept(_err)?|sumxy|pos(_min|_max)_y|size(_x|_y))$")) + +((identifier) @variable.builtin + (#match? @variable.builtin "^((GPVAL|MOUSE|FIT)_\\w+|GNUTERM|NaN|VoxelDistance|GridDistance|pi)$")) + +(array_def + "array" @keyword.function) + +(array + (identifier) @function) + +(number) @number + +(string_literal) @string diff --git a/runtime/queries/gnuplot/injections.scm b/runtime/queries/gnuplot/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/gnuplot/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/go/folds.scm b/runtime/queries/go/folds.scm new file mode 100644 index 000000000..44b452de5 --- /dev/null +++ b/runtime/queries/go/folds.scm @@ -0,0 +1,19 @@ +[ + (const_declaration) + (expression_switch_statement) + (expression_case) + (default_case) + (type_switch_statement) + (type_case) + (for_statement) + (func_literal) + (function_declaration) + (if_statement) + (import_declaration) + (method_declaration) + (type_declaration) + (var_declaration) + (composite_literal) + (literal_element) + (block) +] @fold diff --git a/runtime/queries/go/highlights.scm b/runtime/queries/go/highlights.scm new file mode 100644 index 000000000..7675cb790 --- /dev/null +++ b/runtime/queries/go/highlights.scm @@ -0,0 +1,254 @@ +; Forked from tree-sitter-go +; Copyright (c) 2014 Max Brunsfeld (The MIT License) +; +; Identifiers +(type_identifier) @type + +(type_spec + name: (type_identifier) @type.definition) + +(field_identifier) @property + +(identifier) @variable + +(package_identifier) @module + +(parameter_declaration + (identifier) @variable.parameter) + +(variadic_parameter_declaration + (identifier) @variable.parameter) + +(label_name) @label + +(const_spec + name: (identifier) @constant) + +; Function calls +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (selector_expression + field: (field_identifier) @function.method.call)) + +; Function definitions +(function_declaration + name: (identifier) @function) + +(method_declaration + name: (field_identifier) @function.method) + +(method_elem + name: (field_identifier) @function.method) + +; Constructors +((call_expression + (identifier) @constructor) + (#lua-match? @constructor "^[nN]ew.+$")) + +((call_expression + (identifier) @constructor) + (#lua-match? @constructor "^[mM]ake.+$")) + +; Operators +[ + "--" + "-" + "-=" + ":=" + "!" + "!=" + "..." + "*" + "*" + "*=" + "/" + "/=" + "&" + "&&" + "&=" + "&^" + "&^=" + "%" + "%=" + "^" + "^=" + "+" + "++" + "+=" + "<-" + "<" + "<<" + "<<=" + "<=" + "=" + "==" + ">" + ">=" + ">>" + ">>=" + "|" + "|=" + "||" + "~" +] @operator + +; Keywords +[ + "break" + "const" + "continue" + "default" + "defer" + "goto" + "range" + "select" + "var" + "fallthrough" +] @keyword + +[ + "type" + "struct" + "interface" +] @keyword.type + +"func" @keyword.function + +"return" @keyword.return + +"go" @keyword.coroutine + +"for" @keyword.repeat + +[ + "import" + "package" +] @keyword.import + +[ + "else" + "case" + "switch" + "if" +] @keyword.conditional + +; Builtin types +[ + "chan" + "map" +] @type.builtin + +((type_identifier) @type.builtin + (#any-of? @type.builtin + "any" "bool" "byte" "comparable" "complex128" "complex64" "error" "float32" "float64" "int" + "int16" "int32" "int64" "int8" "rune" "string" "uint" "uint16" "uint32" "uint64" "uint8" + "uintptr")) + +; Builtin functions +((identifier) @function.builtin + (#any-of? @function.builtin + "append" "cap" "clear" "close" "complex" "copy" "delete" "imag" "len" "make" "max" "min" "new" + "panic" "print" "println" "real" "recover")) + +; Delimiters +"." @punctuation.delimiter + +"," @punctuation.delimiter + +":" @punctuation.delimiter + +";" @punctuation.delimiter + +"(" @punctuation.bracket + +")" @punctuation.bracket + +"{" @punctuation.bracket + +"}" @punctuation.bracket + +"[" @punctuation.bracket + +"]" @punctuation.bracket + +; Literals +(interpreted_string_literal) @string + +(raw_string_literal) @string + +(rune_literal) @string + +(escape_sequence) @string.escape + +(int_literal) @number + +(float_literal) @number.float + +(imaginary_literal) @number + +[ + (true) + (false) +] @boolean + +[ + (nil) + (iota) +] @constant.builtin + +(keyed_element + . + (literal_element + (identifier) @variable.member)) + +(field_declaration + name: (field_identifier) @variable.member) + +; Comments +(comment) @comment @spell + +; Doc Comments +(source_file + . + (comment)+ @comment.documentation) + +(source_file + (comment)+ @comment.documentation + . + (const_declaration)) + +(source_file + (comment)+ @comment.documentation + . + (function_declaration)) + +(source_file + (comment)+ @comment.documentation + . + (type_declaration)) + +(source_file + (comment)+ @comment.documentation + . + (var_declaration)) + +; Spell +((interpreted_string_literal) @spell + (#not-has-parent? @spell import_spec)) + +; Regex +(call_expression + (selector_expression) @_function + (#any-of? @_function + "regexp.Match" "regexp.MatchReader" "regexp.MatchString" "regexp.Compile" "regexp.CompilePOSIX" + "regexp.MustCompile" "regexp.MustCompilePOSIX") + (argument_list + . + [ + (raw_string_literal + (raw_string_literal_content) @string.regexp) + (interpreted_string_literal + (interpreted_string_literal_content) @string.regexp) + ])) diff --git a/runtime/queries/go/indents.scm b/runtime/queries/go/indents.scm new file mode 100644 index 000000000..28edfe973 --- /dev/null +++ b/runtime/queries/go/indents.scm @@ -0,0 +1,48 @@ +[ + (import_declaration) + (const_declaration) + (var_declaration) + (type_declaration) + (func_literal) + (literal_value) + (expression_case) + (communication_case) + (type_case) + (default_case) + (block) + (call_expression) + (parameter_list) + (field_declaration_list) + (interface_type) +] @indent.begin + +(literal_value + "}" @indent.branch) + +(block + "}" @indent.branch) + +(field_declaration_list + "}" @indent.branch) + +(interface_type + "}" @indent.branch) + +(const_declaration + ")" @indent.branch) + +(import_spec_list + ")" @indent.branch) + +(var_spec_list + ")" @indent.branch) + +[ + "}" + ")" +] @indent.end + +(parameter_list + ")" @indent.branch) + +(comment) @indent.ignore diff --git a/runtime/queries/go/injections.scm b/runtime/queries/go/injections.scm new file mode 100644 index 000000000..4e914a3ec --- /dev/null +++ b/runtime/queries/go/injections.scm @@ -0,0 +1,42 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +(call_expression + (selector_expression) @_function + (#any-of? @_function + "regexp.Match" "regexp.MatchReader" "regexp.MatchString" "regexp.Compile" "regexp.CompilePOSIX" + "regexp.MustCompile" "regexp.MustCompilePOSIX") + (argument_list + . + [ + (raw_string_literal + (raw_string_literal_content) @injection.content) + (interpreted_string_literal + (interpreted_string_literal_content) @injection.content) + ] + (#set! injection.language "regex"))) + +((comment) @injection.content + (#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c") + (#set! injection.language "re2c")) + +((call_expression + function: (selector_expression + field: (field_identifier) @_method) + arguments: (argument_list + . + (interpreted_string_literal + (interpreted_string_literal_content) @injection.content))) + (#any-of? @_method "Printf" "Sprintf" "Fatalf" "Scanf" "Errorf" "Skipf" "Logf") + (#set! injection.language "printf")) + +((call_expression + function: (selector_expression + field: (field_identifier) @_method) + arguments: (argument_list + (_) + . + (interpreted_string_literal + (interpreted_string_literal_content) @injection.content))) + (#any-of? @_method "Fprintf" "Fscanf" "Appendf" "Sscanf") + (#set! injection.language "printf")) diff --git a/runtime/queries/go/locals.scm b/runtime/queries/go/locals.scm new file mode 100644 index 000000000..608c45826 --- /dev/null +++ b/runtime/queries/go/locals.scm @@ -0,0 +1,88 @@ +((function_declaration + name: (identifier) @local.definition.function) ; @function + ) + +((method_declaration + name: (field_identifier) @local.definition.method) ; @function.method + ) + +(short_var_declaration + left: (expression_list + (identifier) @local.definition.var)) + +(var_spec + name: (identifier) @local.definition.var) + +(parameter_declaration + (identifier) @local.definition.var) + +(variadic_parameter_declaration + (identifier) @local.definition.var) + +(for_statement + (range_clause + left: (expression_list + (identifier) @local.definition.var))) + +(const_declaration + (const_spec + name: (identifier) @local.definition.var)) + +(type_declaration + (type_spec + name: (type_identifier) @local.definition.type)) + +; reference +(identifier) @local.reference + +(type_identifier) @local.reference + +(field_identifier) @local.reference + +((package_identifier) @local.reference + (#set! reference.kind "namespace")) + +(package_clause + (package_identifier) @local.definition.namespace) + +(import_spec_list + (import_spec + name: (package_identifier) @local.definition.namespace)) + +; Call references +((call_expression + function: (identifier) @local.reference) + (#set! reference.kind "call")) + +((call_expression + function: (selector_expression + field: (field_identifier) @local.reference)) + (#set! reference.kind "call")) + +((call_expression + function: (parenthesized_expression + (identifier) @local.reference)) + (#set! reference.kind "call")) + +((call_expression + function: (parenthesized_expression + (selector_expression + field: (field_identifier) @local.reference))) + (#set! reference.kind "call")) + +; Scopes +(func_literal) @local.scope + +(source_file) @local.scope + +(function_declaration) @local.scope + +(if_statement) @local.scope + +(block) @local.scope + +(expression_switch_statement) @local.scope + +(for_statement) @local.scope + +(method_declaration) @local.scope diff --git a/runtime/queries/goctl/folds.scm b/runtime/queries/goctl/folds.scm new file mode 100644 index 000000000..704928675 --- /dev/null +++ b/runtime/queries/goctl/folds.scm @@ -0,0 +1,11 @@ +[ + (typeGroupSpec) + (typeSingleSpec) + (typeStruct) + (serviceSpec) + (serviceBody) + (importStatement) + (serviceServerSpec) + (infoStatement) + (structType) +] @fold diff --git a/runtime/queries/goctl/highlights.scm b/runtime/queries/goctl/highlights.scm new file mode 100644 index 000000000..a4b809a1c --- /dev/null +++ b/runtime/queries/goctl/highlights.scm @@ -0,0 +1,79 @@ +; Key Symbol +"=" @operator + +[ + "." + "," + ":" + ";" +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +; Keywords +[ + "syntax" + "info" + "service" +] @keyword + +"import" @keyword.import + +"returns" @keyword.return + +[ + "type" + "struct" +] @keyword.type + +[ + "@doc" + "@handler" + "@server" +] @attribute + +; Service +(serviceName) @type + +; Httpmethod +(HTTPMETHOD) @keyword.operator + +; Field +(fieldType) @type.builtin + +(fieldName) @variable.member + +(anonymousField) @variable.member + +; Functions +(handlerValue) @function.method + +; Strings +(VALUE) @string + +(tag) @string.documentation + +(PATH) @string.special.path + +; Comments +(comment) @comment @spell + +(key) @variable.member + +(identValue) @string + +(DURATION) @number + +(NUMBER) @number + +; Struct +(structNameId) @type + +(body) @type diff --git a/runtime/queries/goctl/indents.scm b/runtime/queries/goctl/indents.scm new file mode 100644 index 000000000..ffa126905 --- /dev/null +++ b/runtime/queries/goctl/indents.scm @@ -0,0 +1,15 @@ +[ + (importGroup) + (typeGroupSpec) + (structType) + (infoStatement) + (serviceServerSpec) + (serviceSpec) +] @indent.begin + +[ + ")" + "}" +] @indent.branch @indent.end + +(comment) @indent.ignore diff --git a/runtime/queries/goctl/injections.scm b/runtime/queries/goctl/injections.scm new file mode 100644 index 000000000..a53abee57 --- /dev/null +++ b/runtime/queries/goctl/injections.scm @@ -0,0 +1,3 @@ +; Inject comment language for goctl +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/godot_resource/folds.scm b/runtime/queries/godot_resource/folds.scm new file mode 100644 index 000000000..911798f5a --- /dev/null +++ b/runtime/queries/godot_resource/folds.scm @@ -0,0 +1 @@ +(section) @fold diff --git a/runtime/queries/godot_resource/highlights.scm b/runtime/queries/godot_resource/highlights.scm new file mode 100644 index 000000000..15cbadd10 --- /dev/null +++ b/runtime/queries/godot_resource/highlights.scm @@ -0,0 +1,49 @@ +(identifier) @variable + +(section + (identifier) @tag) + +(section + [ + "[" + "]" + ] @tag.delimiter) + +(attribute + (identifier) @tag.attribute) + +(property + (path) @property) + +(constructor + (identifier) @constructor) + +(string) @string + +(integer) @number + +(float) @number.float + +[ + (true) + (false) +] @boolean + +(null) @constant.builtin + +(array + [ + "[" + "]" + ] @punctuation.bracket) + +[ + "(" + ")" + "{" + "}" +] @punctuation.bracket + +"=" @operator + +(comment) @comment @spell diff --git a/runtime/queries/godot_resource/injections.scm b/runtime/queries/godot_resource/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/godot_resource/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/godot_resource/locals.scm b/runtime/queries/godot_resource/locals.scm new file mode 100644 index 000000000..b946a5eec --- /dev/null +++ b/runtime/queries/godot_resource/locals.scm @@ -0,0 +1 @@ +(section) @local.scope diff --git a/runtime/queries/gomod/highlights.scm b/runtime/queries/gomod/highlights.scm new file mode 100644 index 000000000..b30be0944 --- /dev/null +++ b/runtime/queries/gomod/highlights.scm @@ -0,0 +1,34 @@ +[ + "require" + "replace" + "go" + "toolchain" + "exclude" + "retract" + "module" +] @keyword + +"=>" @operator + +(comment) @comment @spell + +(module_path) @string.special.url + +(tool_directive) @keyword.directive + +(tool) @string.special.url + +[ + (version) + (go_version) + (toolchain_name) +] @string.special + +[ + "(" + ")" + "[" + "]" +] @punctuation.bracket + +"," @punctuation.delimiter diff --git a/runtime/queries/gomod/injections.scm b/runtime/queries/gomod/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/gomod/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/gosum/highlights.scm b/runtime/queries/gosum/highlights.scm new file mode 100644 index 000000000..f20c5f176 --- /dev/null +++ b/runtime/queries/gosum/highlights.scm @@ -0,0 +1,32 @@ +[ + "alpha" + "beta" + "dev" + "pre" + "rc" + "+incompatible" +] @keyword + +(module_path) @string.special.url + +(module_version) @string.special + +(hash_version) @attribute + +(hash) @string.special.symbol + +[ + (number) + (number_with_decimal) + (hex_number) +] @number + +(checksum + "go.mod" @string) + +[ + ":" + "." + "-" + "/" +] @punctuation.delimiter diff --git a/runtime/queries/gotmpl/folds.scm b/runtime/queries/gotmpl/folds.scm new file mode 100644 index 000000000..f3a22e90c --- /dev/null +++ b/runtime/queries/gotmpl/folds.scm @@ -0,0 +1,8 @@ +[ + (if_action) + (range_action) + (block_action) + (with_action) + (define_action) + (comment) +] @fold diff --git a/runtime/queries/gotmpl/highlights.scm b/runtime/queries/gotmpl/highlights.scm new file mode 100644 index 000000000..4ee768c28 --- /dev/null +++ b/runtime/queries/gotmpl/highlights.scm @@ -0,0 +1,133 @@ +; Priorities of the highlight queries are raised, so that they overrule the +; often surrounding and overlapping highlights from the non-gotmpl injections. +; +; Identifiers +([ + (field) + (field_identifier) +] @variable.member + (#set! priority 110)) + +((variable) @variable + (#set! priority 110)) + +; Function calls +(function_call + function: (identifier) @function + (#set! priority 110)) + +(method_call + method: (selector_expression + field: (field_identifier) @function + (#set! priority 110))) + +; Builtin functions +(function_call + function: (identifier) @function.builtin + (#set! priority 110) + (#any-of? @function.builtin + "and" "call" "html" "index" "slice" "js" "len" "not" "or" "print" "printf" "println" "urlquery" + "eq" "ne" "lt" "ge" "gt" "ge")) + +; Operators +([ + "|" + "=" + ":=" +] @operator + (#set! priority 110)) + +; Delimiters +([ + "." + "," +] @punctuation.delimiter + (#set! priority 110)) + +([ + "{{" + "}}" + "{{-" + "-}}" + ")" + "(" +] @punctuation.bracket + (#set! priority 110)) + +; Actions +(if_action + [ + "if" + "else" + "else if" + "end" + ] @keyword.conditional + (#set! priority 110)) + +(range_action + [ + "range" + "else" + "end" + ] @keyword.repeat + (#set! priority 110)) + +(template_action + "template" @function.builtin + (#set! priority 110)) + +(block_action + [ + "block" + "end" + ] @keyword.directive + (#set! priority 110)) + +(define_action + [ + "define" + "end" + ] @keyword.directive.define + (#set! priority 110)) + +(with_action + [ + "with" + "else" + "end" + ] @keyword.conditional + (#set! priority 110)) + +; Literals +([ + (interpreted_string_literal) + (raw_string_literal) +] @string + (#set! priority 110)) + +((rune_literal) @string.special.symbol + (#set! priority 110)) + +((escape_sequence) @string.escape + (#set! priority 110)) + +([ + (int_literal) + (imaginary_literal) +] @number + (#set! priority 110)) + +((float_literal) @number.float + (#set! priority 110)) + +([ + (true) + (false) +] @boolean + (#set! priority 110)) + +((nil) @constant.builtin + (#set! priority 110)) + +((comment) @comment @spell + (#set! priority 110)) diff --git a/runtime/queries/gotmpl/injections.scm b/runtime/queries/gotmpl/injections.scm new file mode 100644 index 000000000..3cfc26361 --- /dev/null +++ b/runtime/queries/gotmpl/injections.scm @@ -0,0 +1,31 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; {{"put" | printf "%s%s" "out" | printf "%q"}} +(function_call + function: (identifier) @_function + arguments: (argument_list + . + (interpreted_string_literal) @injection.content) + (#eq? @_function "printf") + (#set! injection.language "printf")) + +; {{ js "var a = 1 + 1" }} +(function_call + function: (identifier) @_function + arguments: (argument_list + . + (interpreted_string_literal) @injection.content) + (#eq? @_function "js") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "javascript")) + +; {{ html "<h1>hello</h1>" }} +(function_call + function: (identifier) @_function + arguments: (argument_list + . + (interpreted_string_literal) @injection.content) + (#eq? @_function "html") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "html")) diff --git a/runtime/queries/gotmpl/locals.scm b/runtime/queries/gotmpl/locals.scm new file mode 100644 index 000000000..528e9fabb --- /dev/null +++ b/runtime/queries/gotmpl/locals.scm @@ -0,0 +1,12 @@ +[ + (if_action) + (range_action) + (block_action) + (with_action) + (define_action) +] @local.scope + +(variable_definition + variable: (variable) @local.definition.var) + +(variable) @local.reference diff --git a/runtime/queries/gowork/highlights.scm b/runtime/queries/gowork/highlights.scm new file mode 100644 index 000000000..bca9a5f80 --- /dev/null +++ b/runtime/queries/gowork/highlights.scm @@ -0,0 +1,14 @@ +[ + "replace" + "go" + "use" +] @keyword + +"=>" @operator + +(comment) @comment @spell + +[ + (version) + (go_version) +] @string diff --git a/runtime/queries/gowork/injections.scm b/runtime/queries/gowork/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/gowork/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/gpg/highlights.scm b/runtime/queries/gpg/highlights.scm new file mode 100644 index 000000000..f02834429 --- /dev/null +++ b/runtime/queries/gpg/highlights.scm @@ -0,0 +1,54 @@ +(option + . + _ @keyword) + +(option + ("no-" @variable.parameter)? + (name) @variable.parameter) + +(string + (content) @string) + +[ + (value) + "clear" +] @string.special + +(url) @string.special.url + +(key) @constant + +[ + (number) + (expire_time) + (iso_time) +] @number + +(format) @character.special + +"sensitive:" @keyword.modifier + +(filter_name) @variable.parameter + +(filter_scope) @module + +(filter_property) @property + +(filter_value) @string + +[ + (filter_op0) + (filter_op1) + (filter_lc) + "=" +] @operator + +"!" @punctuation.special + +[ + "\"" + "'" + "," +] @punctuation.delimiter + +(comment) @comment @spell diff --git a/runtime/queries/gpg/injections.scm b/runtime/queries/gpg/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/gpg/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/graphql/highlights.scm b/runtime/queries/graphql/highlights.scm new file mode 100644 index 000000000..c1ee501c4 --- /dev/null +++ b/runtime/queries/graphql/highlights.scm @@ -0,0 +1,163 @@ +; Types +;------ +(scalar_type_definition + (name) @type) + +(object_type_definition + (name) @type) + +(interface_type_definition + (name) @type) + +(union_type_definition + (name) @type) + +(enum_type_definition + (name) @type) + +(input_object_type_definition + (name) @type) + +(scalar_type_extension + (name) @type) + +(object_type_extension + (name) @type) + +(interface_type_extension + (name) @type) + +(union_type_extension + (name) @type) + +(enum_type_extension + (name) @type) + +(input_object_type_extension + (name) @type) + +(named_type + (name) @type) + +; Directives +;----------- +(directive_definition + "@" @attribute + (name) @attribute) + +(directive) @attribute + +; Properties +;----------- +(field + (name) @property) + +(field + (alias + (name) @property)) + +(field_definition + (name) @property) + +(object_value + (object_field + (name) @property)) + +(enum_value + (name) @property) + +; Variable Definitions and Arguments +;----------------------------------- +(operation_definition + (name) @variable) + +(fragment_name + (name) @variable) + +(input_fields_definition + (input_value_definition + (name) @variable.parameter)) + +(argument + (name) @variable.parameter) + +(arguments_definition + (input_value_definition + (name) @variable.parameter)) + +(variable_definition + (variable) @variable.parameter) + +(argument + (value + (variable) @variable)) + +; Constants +;---------- +(string_value) @string + +(int_value) @number + +(float_value) @number.float + +(boolean_value) @boolean + +; Literals +;--------- +(description + (string_value) @string.documentation @spell) + +(comment) @comment @spell + +(directive_location + (executable_directive_location) @type.builtin) + +(directive_location + (type_system_directive_location) @type.builtin) + +; Keywords +;---------- +[ + "query" + "mutation" + "subscription" + "fragment" + "scalar" + "input" + "extend" + "directive" + "schema" + "on" + "repeatable" + "implements" +] @keyword + +[ + "enum" + "union" + "type" + "interface" +] @keyword.type + +; Punctuation +;------------ +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +"=" @operator + +"|" @punctuation.delimiter + +"&" @punctuation.delimiter + +":" @punctuation.delimiter + +"..." @punctuation.special + +"!" @punctuation.special diff --git a/runtime/queries/graphql/indents.scm b/runtime/queries/graphql/indents.scm new file mode 100644 index 000000000..fcffeb822 --- /dev/null +++ b/runtime/queries/graphql/indents.scm @@ -0,0 +1,11 @@ +[ + (definition) + (selection) +] @indent.begin + +[ + "{" + "}" +] @indent.branch + +"}" @indent.end diff --git a/runtime/queries/graphql/injections.scm b/runtime/queries/graphql/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/graphql/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/gren/highlights.scm b/runtime/queries/gren/highlights.scm new file mode 100644 index 000000000..030cf7fad --- /dev/null +++ b/runtime/queries/gren/highlights.scm @@ -0,0 +1,121 @@ +; Keywords +[ + (as) + (port) + (exposing) + (alias) + (infix) +] @keyword + +; Keywords - Conditionals +[ + "if" + "then" + "else" + "let" + "in" + (when) + (is) +] @keyword.conditional + +; Keywords - Imports +[ + (import) + (module) +] @keyword.import + +; Operators +[ + (arrow) + (backslash) + (colon) + (operator_identifier) + (eq) +] @operator + +; Punctuation +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + "," + "|" + (dot) +] @punctuation.delimiter + +; Comments +[ + (block_comment) + (line_comment) +] @comment + +; Strings +[ + (close_quote) + (open_quote) + (regular_string_part) +] @string + +; Strings - Escape +(string_escape) @string.escape + +; Characters +[ + (open_char) + (close_char) +] @character + +(type_annotation + (lower_case_identifier) @function) + +(port_annotation + (lower_case_identifier) @function) + +(function_declaration_left + (lower_case_identifier) @function) + +(function_call_expr + target: (value_expr) @function) + +(field_access_expr + (value_expr + (value_qid) @variable.member)) + +(lower_pattern) @variable.parameter + +(record_base_identifier) @variable + +(number_constant_expr) @number + +(type) @keyword.type + +(type_declaration + (upper_case_identifier) @type) + +(type_ref) @type + +(type_alias_declaration + name: (upper_case_identifier) @type) + +(union_variant + (upper_case_identifier) @type) + +(union_pattern + constructor: (upper_case_qid + (upper_case_identifier) @label + (dot) + (upper_case_identifier) @type)) + +(union_pattern + constructor: (upper_case_qid + (upper_case_identifier) @type)) + +(value_expr + (upper_case_qid + (upper_case_identifier)) @type) diff --git a/runtime/queries/gren/injections.scm b/runtime/queries/gren/injections.scm new file mode 100644 index 000000000..3cd6aac8e --- /dev/null +++ b/runtime/queries/gren/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/groovy/folds.scm b/runtime/queries/groovy/folds.scm new file mode 100644 index 000000000..354861a61 --- /dev/null +++ b/runtime/queries/groovy/folds.scm @@ -0,0 +1,6 @@ +[ + (argument_list) + (closure) + (list) + (map) +] @fold diff --git a/runtime/queries/groovy/highlights.scm b/runtime/queries/groovy/highlights.scm new file mode 100644 index 000000000..4504e16e2 --- /dev/null +++ b/runtime/queries/groovy/highlights.scm @@ -0,0 +1,269 @@ +[ + "!instanceof" + "assert" + "extends" + "instanceof" + "package" +] @keyword + +"class" @keyword.type + +[ + "!in" + "as" + "in" +] @keyword.operator + +[ + "case" + "default" + "else" + "if" + "switch" +] @keyword.conditional + +[ + "catch" + "finally" + "try" +] @keyword.exception + +"def" @keyword.function + +"import" @keyword.import + +[ + "for" + "while" + (break) + (continue) +] @keyword.repeat + +"return" @keyword.return + +[ + "true" + "false" +] @boolean + +(null) @constant.builtin + +"this" @variable.builtin + +[ + "int" + "char" + "short" + "long" + "boolean" + "float" + "double" + "void" +] @type.builtin + +[ + "final" + "private" + "protected" + "public" + "static" + "synchronized" +] @keyword.modifier + +(comment) @comment @spell + +(shebang) @keyword.directive + +(string) @string + +(string + (escape_sequence) @string.escape) + +(string + (interpolation + "$" @punctuation.special)) + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + ":" + "," + "." +] @punctuation.delimiter + +(number_literal) @number + +(identifier) @variable + +((identifier) @constant + (#match? @constant "^[A-Z][A-Z_]+")) + +[ + "%" + "*" + "/" + "+" + "-" + "<<" + ">>" + ">>>" + ".." + "..<" + "<..<" + "<.." + "<" + "<=" + ">" + ">=" + "==" + "!=" + "<=>" + "===" + "!==" + "=~" + "==~" + "&" + "^" + "|" + "&&" + "||" + "?:" + "+" + "*" + ".&" + ".@" + "?." + "*." + "*" + "*:" + "++" + "--" + "!" +] @operator + +(wildcard_import) @character.special + +(string + "/" @string) + +(ternary_op + ([ + "?" + ":" + ]) @keyword.conditional.ternary) + +(map + (map_item + key: (identifier) @variable.parameter)) + +(parameter + type: (identifier) @type + name: (identifier) @variable.parameter) + +(generic_param + name: (identifier) @variable.parameter) + +(declaration + type: (identifier) @type) + +(function_definition + type: (identifier) @type) + +(function_declaration + type: (identifier) @type) + +(class_definition + name: (identifier) @type) + +(class_definition + superclass: (identifier) @type) + +(generic_param + superclass: (identifier) @type) + +(type_with_generics + (identifier) @type) + +(type_with_generics + (generics + (identifier) @type)) + +(generics + [ + "<" + ">" + ] @punctuation.bracket) + +(generic_parameters + [ + "<" + ">" + ] @punctuation.bracket) + +; TODO: Class literals with PascalCase +(declaration + "=" @operator) + +(assignment + "=" @operator) + +(function_call + function: (identifier) @function) + +(function_call + function: (dotted_identifier + (identifier) @function .)) + +(function_call + (argument_list + (map_item + key: (identifier) @variable.parameter))) + +(juxt_function_call + function: (identifier) @function) + +(juxt_function_call + function: (dotted_identifier + (identifier) @function .)) + +(juxt_function_call + (argument_list + (map_item + key: (identifier) @variable.parameter))) + +(function_definition + function: (identifier) @function) + +(function_declaration + function: (identifier) @function) + +(annotation) @function.macro + +(annotation + (identifier) @function.macro) + +"@interface" @function.macro + +(groovy_doc) @comment.documentation @spell + +(groovy_doc + [ + (groovy_doc_param) + (groovy_doc_throws) + (groovy_doc_tag) + ] @string.special @nospell) + +(groovy_doc + (groovy_doc_param + (identifier) @variable.parameter) @nospell) + +(groovy_doc + (groovy_doc_throws + (identifier) @type @nospell)) diff --git a/runtime/queries/groovy/indents.scm b/runtime/queries/groovy/indents.scm new file mode 100644 index 000000000..ba3a2e844 --- /dev/null +++ b/runtime/queries/groovy/indents.scm @@ -0,0 +1,35 @@ +[ + (closure) + (map) + (list) + (argument_list) + (parameter_list) + (for_parameters) +] @indent.begin + +; (function_definition "(" @indent.begin) +(closure + "}" @indent.end) + +(argument_list + ")" @indent.end) + +(for_parameters + ")" @indent.end) + +((for_loop + body: (_) @_body) @indent.begin + (#not-kind-eq? @_body "closure")) + +; TODO: while, try +(list + "]" @indent.end) + +(map + "]" @indent.end) + +[ + "}" + ")" + "]" +] @indent.branch diff --git a/runtime/queries/groovy/injections.scm b/runtime/queries/groovy/injections.scm new file mode 100644 index 000000000..1c04c65fb --- /dev/null +++ b/runtime/queries/groovy/injections.scm @@ -0,0 +1,5 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((groovy_doc) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/groovy/locals.scm b/runtime/queries/groovy/locals.scm new file mode 100644 index 000000000..23cb5f0cb --- /dev/null +++ b/runtime/queries/groovy/locals.scm @@ -0,0 +1,6 @@ +(function_definition) @local.scope + +(parameter + name: (identifier) @local.definition.parameter) + +(identifier) @local.reference diff --git a/runtime/queries/gstlaunch/highlights.scm b/runtime/queries/gstlaunch/highlights.scm new file mode 100644 index 000000000..90729f876 --- /dev/null +++ b/runtime/queries/gstlaunch/highlights.scm @@ -0,0 +1,35 @@ +[ + "!" + "=" +] @operator + +[ + "," + "." + ";" + "/" +] @punctuation.delimiter + +[ + "(" + ")" +] @punctuation.bracket + +(property + key: (identifier) @variable.member) + +(value) @string + +(string_literal) @string + +(cap + . + (identifier) @string + . + (identifier) @string) + +(simple_element + type: (_) @type) + +(bin + type: (_) @type) diff --git a/runtime/queries/hack/highlights.scm b/runtime/queries/hack/highlights.scm new file mode 100644 index 000000000..bb9d2a55c --- /dev/null +++ b/runtime/queries/hack/highlights.scm @@ -0,0 +1,366 @@ +(variable) @variable + +(identifier) @variable + +((variable) @variable.builtin + (#eq? @variable.builtin "$this")) + +(braced_expression) @none + +(scoped_identifier + (qualified_identifier + (identifier) @type)) + +[ + (comment) + (heredoc) +] @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +"function" @keyword.function + +[ + "implements" + "using" + "attribute" + "const" + "extends" + "insteadof" +] @keyword + +[ + "class" + "type" + "interface" + "namespace" +] @keyword.type + +[ + "async" + "await" +] @keyword.coroutine + +[ + "use" + "include" + "include_once" + "require" + "require_once" +] @keyword.import + +[ + "new" + "print" + "echo" + "newtype" + "clone" + "as" +] @keyword.operator + +"return" @keyword.return + +[ + (abstract_modifier) + (final_modifier) + (static_modifier) + (visibility_modifier) + (xhp_modifier) +] @keyword.modifier + +[ + "shape" + "tuple" + (array_type) + "bool" + "float" + "int" + "string" + "arraykey" + "void" + "nonnull" + "mixed" + "dynamic" + "noreturn" +] @type.builtin + +(null) @constant.builtin + +[ + (true) + (false) +] @boolean + +(type_specifier) @type + +(new_expression + (_) @type) + +(alias_declaration + "newtype" + . + (_) @type) + +(alias_declaration + "type" + . + (_) @type) + +(class_declaration + name: (identifier) @type) + +(type_parameter + name: (identifier) @type) + +(collection + (qualified_identifier + (identifier) @type .)) + +[ + "@required" + "@lateinit" + (attribute_modifier) +] @attribute + +[ + "=" + "??=" + ".=" + "|=" + "^=" + "&=" + "<<=" + ">>=" + "+=" + "-=" + "*=" + "/=" + "%=" + "**=" + "==>" + "|>" + "??" + "||" + "&&" + "|" + "^" + "&" + "==" + "!=" + "===" + "!==" + "<" + ">" + "<=" + ">=" + "<=>" + "<<" + ">>" + "->" + "+" + "-" + "." + "*" + "/" + "%" + "**" + "++" + "--" + "!" + "?:" + "=" + "??=" + ".=" + "|=" + "^=" + "&=" + "<<=" + ">>=" + "+=" + "-=" + "*=" + "/=" + "%=" + "**=" + "=>" + ; type modifiers + "@" + "?" + "~" +] @operator + +(integer) @number + +(float) @number.float + +(parameter + (variable) @variable.parameter) + +(call_expression + function: (qualified_identifier + (identifier) @function.call .)) + +(call_expression + function: (scoped_identifier + (identifier) @function.call .)) + +(call_expression + function: (selection_expression + (qualified_identifier + (identifier) @function.method.call .))) + +(qualified_identifier + (_) @module + . + (_)) + +(use_statement + (qualified_identifier + (_) @module .) + (use_clause)) + +(use_statement + (use_type + "namespace") + (use_clause + (qualified_identifier + (identifier) @module .) + alias: (identifier)? @module)) + +(use_statement + (use_type + "const") + (use_clause + (qualified_identifier + (identifier) @constant .) + alias: (identifier)? @constant)) + +(use_statement + (use_type + "function") + (use_clause + (qualified_identifier + (identifier) @function .) + alias: (identifier)? @function)) + +(use_statement + (use_type + "type") + (use_clause + (qualified_identifier + (identifier) @type .) + alias: (identifier)? @type)) + +(use_clause + (use_type + "namespace") + (qualified_identifier + (_) @module .) + alias: (identifier)? @module) + +(use_clause + (use_type + "function") + (qualified_identifier + (_) @function .) + alias: (identifier)? @function) + +(use_clause + (use_type + "const") + (qualified_identifier + (_) @constant .) + alias: (identifier)? @constant) + +(use_clause + (use_type + "type") + (qualified_identifier + (_) @type .) + alias: (identifier)? @type) + +(function_declaration + name: (identifier) @function) + +(method_declaration + name: (identifier) @function.method) + +(type_arguments + [ + "<" + ">" + ] @punctuation.bracket) + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<<" + ">>" +] @punctuation.bracket + +(xhp_open + [ + "<" + ">" + ] @tag.delimiter) + +(xhp_close + [ + "</" + ">" + ] @tag.delimiter) + +[ + "." + ";" + "::" + ":" + "," +] @punctuation.delimiter + +(qualified_identifier + "\\" @punctuation.delimiter) + +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +[ + "if" + "else" + "elseif" + "switch" + "case" +] @keyword.conditional + +[ + "try" + "catch" + "finally" +] @keyword.exception + +[ + "for" + "while" + "foreach" + "do" + "continue" + "break" +] @keyword.repeat + +[ + (string) + (xhp_string) +] @string + +[ + (xhp_open) + (xhp_close) +] @tag diff --git a/runtime/queries/hack/injections.scm b/runtime/queries/hack/injections.scm new file mode 100644 index 000000000..655c29ec5 --- /dev/null +++ b/runtime/queries/hack/injections.scm @@ -0,0 +1,5 @@ +([ + (comment) + (heredoc) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/hare/folds.scm b/runtime/queries/hare/folds.scm new file mode 100644 index 000000000..58b10bfdc --- /dev/null +++ b/runtime/queries/hare/folds.scm @@ -0,0 +1,18 @@ +[ + (imports) + (function_declaration) + (enum_type) + (struct_type) + (tuple_type) + (union_type) + (block) + (if_statement) + (for_statement) + (call_expression) + (switch_expression) + (match_expression) + (case) + (array_literal) + (struct_literal) + (tuple_literal) +] @fold diff --git a/runtime/queries/hare/highlights.scm b/runtime/queries/hare/highlights.scm new file mode 100644 index 000000000..deaecd283 --- /dev/null +++ b/runtime/queries/hare/highlights.scm @@ -0,0 +1,272 @@ +; Variables +(identifier) @variable + +; Types +(type) @type + +(scoped_type_identifier + (identifier) + . + (identifier) @type) + +(struct_literal + . + (identifier) @type) + +(builtin_type) @type.builtin + +; Constants +((identifier) @constant + (#lua-match? @constant "^[A-Z_]+$")) + +; Includes +[ + "use" + "export" +] @keyword.import + +(use_statement + (scoped_type_identifier + (identifier) @module)) + +(use_statement + (identifier) @module + "{") + +(use_statement + . + (identifier) @module .) + +((scoped_type_identifier + path: (_) @module) + (#set! priority 105)) + +; Keywords +[ + "def" + "let" +] @keyword + +[ + "enum" + "struct" + "union" + "type" +] @keyword.type + +"fn" @keyword.function + +[ + "defer" + "yield" + "return" +] @keyword.return + +[ + "as" + "is" +] @keyword.operator + +; Typedefs +(type_declaration + "type" + (identifier) @type.definition + . + "=") + +; Qualifiers +[ + "const" + "static" + "nullable" +] @keyword.modifier + +; Attributes +[ + "@fini" + "@init" + "@test" + "@noreturn" + "@packed" + (declaration_attribute) +] @attribute + +; Labels +((label) @label + (#set! priority 105)) + +; Functions +(function_declaration + "fn" + . + (identifier) @function) + +(call_expression + . + (identifier) @function.call) + +(call_expression + . + (scoped_type_identifier + . + (identifier) + . + "::" + . + (identifier) @function.method.call)) + +((call_expression + . + (identifier) @function.builtin) + (#any-of? @function.builtin "align" "assert" "free" "len" "offset" "size")) + +(size_expression + "size" @function.builtin) + +((function_declaration + "fn" + . + (identifier) @constructor) + (#eq? @constructor "init")) + +((call_expression + . + (identifier) @constructor) + (#eq? @constructor "init")) + +; Parameters +(parameter + (_) @variable.parameter + . + ":") + +; Fields +((member_expression + "." + (_) @variable.member) + (#set! priority 105)) + +(field + . + (identifier) @variable.member) + +(field_assignment + . + (identifier) @variable.member) + +; Repeats +"for" @keyword.repeat + +; Conditionals +[ + "if" + "else" + "break" + "switch" + "match" + "case" +] @keyword.conditional + +; Operators +[ + "+" + "-" + "*" + "/" + "%" + "||" + "&&" + "^^" + "|" + "&" + "^" + "==" + "!=" + ">" + ">=" + "<=" + "<" + "<<" + ">>" + "~" + "!" + "+=" + "-=" + "*=" + "/=" + "%=" + "<<=" + ">>=" + "|=" + "&=" + "^=" + "||=" + "&&=" + "^^=" + "=" + "?" +] @operator + +; Punctuation +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + ".." + "..." + "_" +] @punctuation.special + +(pointer_type + "*" @punctuation.special) + +(slice_type + "*" @punctuation.special) + +(error_type + "!" @punctuation.special) + +[ + "," + "." + ":" + ";" + "::" + "=>" +] @punctuation.delimiter + +; Literals +[ + (string) + (raw_string) +] @string + +(rune) @character + +(escape_sequence) @string.escape + +(number) @number + +(float) @number.float + +(boolean) @boolean + +[ + (void) + (null) +] @constant.builtin + +; Comments +(comment) @comment @spell diff --git a/runtime/queries/hare/indents.scm b/runtime/queries/hare/indents.scm new file mode 100644 index 000000000..9e41ea6d0 --- /dev/null +++ b/runtime/queries/hare/indents.scm @@ -0,0 +1,45 @@ +[ + (enum_type) + (struct_type) + (tuple_type) + (union_type) + (block) + (for_statement) + (call_expression) + (case) + (array_literal) + (struct_literal) + (tuple_literal) +] @indent.begin + +(if_statement + ("(" + condition: (_) + ")") @indent.begin) + +[ + "}" + "]" + ")" +] @indent.end + +[ + "{" + "}" +] @indent.branch + +[ + "[" + "]" +] @indent.branch + +[ + "(" + ")" +] @indent.branch + +[ + (ERROR) + (comment) + (concatenated_string) +] @indent.auto diff --git a/runtime/queries/hare/injections.scm b/runtime/queries/hare/injections.scm new file mode 100644 index 000000000..88a3f1cdd --- /dev/null +++ b/runtime/queries/hare/injections.scm @@ -0,0 +1,18 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((call_expression + . + (_) @_fnname + . + "(" + . + (_ + [ + (string_content) + (raw_string_content) + ] @injection.content) + . + ")") + (#any-of? @_fnname "compile" "regex::compile") + (#set! injection.language "regex")) diff --git a/runtime/queries/hare/locals.scm b/runtime/queries/hare/locals.scm new file mode 100644 index 000000000..12a214bf7 --- /dev/null +++ b/runtime/queries/hare/locals.scm @@ -0,0 +1,65 @@ +; Scopes +[ + (module) + (function_declaration) + (if_statement) + (for_statement) + (match_expression) + (switch_expression) +] @local.scope + +; References +[ + (identifier) + (scoped_type_identifier) +] @local.reference + +; Definitions +(global_binding + (identifier) @local.definition.constant + . + ":" + (_)) + +(const_declaration + "const" + (identifier) @local.definition.constant + . + "=") + +(field + . + (identifier) @local.definition.field) + +(field_assignment + . + (identifier) @local.definition.field) + +(function_declaration + "fn" + . + (identifier) @local.definition.function) + +(parameter + (_) @local.definition.parameter + . + ":") + +(type_declaration + "type" + (identifier) @local.definition.type + . + "=") + +(type_declaration + "type" + (identifier) @local.definition.enum + . + "=" + (enum_type)) + +(let_declaration + "let" + . + (identifier) @local.definition.var + ","?) diff --git a/runtime/queries/haskell/folds.scm b/runtime/queries/haskell/folds.scm new file mode 100644 index 000000000..d7b820c9f --- /dev/null +++ b/runtime/queries/haskell/folds.scm @@ -0,0 +1,6 @@ +[ + (apply) + (do) + (function) + (import)+ +] @fold diff --git a/runtime/queries/haskell/highlights.scm b/runtime/queries/haskell/highlights.scm new file mode 100644 index 000000000..0880f020e --- /dev/null +++ b/runtime/queries/haskell/highlights.scm @@ -0,0 +1,467 @@ +; ---------------------------------------------------------------------------- +; Parameters and variables +; NOTE: These are at the top, so that they have low priority, +; and don't override destructured parameters +(variable) @variable + +(decl/function + patterns: (patterns + (_) @variable.parameter)) + +(expression/lambda + (_)+ @variable.parameter + "->") + +(decl/function + (infix + (pattern) @variable.parameter)) + +; ---------------------------------------------------------------------------- +; Literals and comments +(integer) @number + +(negation) @number + +(expression/literal + (float)) @number.float + +(char) @character + +(string) @string + +(comment) @comment + +(haddock) @comment.documentation + +; ---------------------------------------------------------------------------- +; Punctuation +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + "," + ";" +] @punctuation.delimiter + +; ---------------------------------------------------------------------------- +; Keywords, operators, includes +[ + "forall" + ; "∀" ; utf-8 is not cross-platform safe +] @keyword.repeat + +(pragma) @keyword.directive + +[ + "if" + "then" + "else" + "case" + "of" +] @keyword.conditional + +[ + "import" + "qualified" + "module" +] @keyword.import + +[ + (operator) + (constructor_operator) + (all_names) + "." + ".." + "=" + "|" + "::" + "=>" + "->" + "<-" + "\\" + "`" + "@" +] @operator + +(wildcard) @character.special + +(module + (module_id) @module) + +[ + "where" + "let" + "in" + "class" + "instance" + "pattern" + "data" + "newtype" + "family" + "type" + "as" + "hiding" + "deriving" + "via" + "stock" + "anyclass" + "do" + "mdo" + "rec" + "infix" + "infixl" + "infixr" +] @keyword + +; ---------------------------------------------------------------------------- +; Functions and variables +(decl + [ + name: (variable) @function + names: (binding_list + (variable) @function) + ]) + +(decl/bind + name: (variable) @variable) + +; Consider signatures (and accompanying functions) +; with only one value on the rhs as variables +(decl/signature + name: (variable) @variable + type: (type)) + +((decl/signature + name: (variable) @_name + type: (type)) + . + (decl + name: (variable) @variable) + match: (_) + (#eq? @_name @variable)) + +; but consider a type that involves 'IO' a decl/function +(decl/signature + name: (variable) @function + type: (type/apply + constructor: (name) @_type) + (#eq? @_type "IO")) + +((decl/signature + name: (variable) @_name + type: (type/apply + constructor: (name) @_type) + (#eq? @_type "IO")) + . + (decl + name: (variable) @function) + match: (_) + (#eq? @_name @function)) + +((decl/signature) @function + . + (decl/function + name: (variable) @function)) + +(decl/bind + name: (variable) @function + (match + expression: (expression/lambda))) + +; view patterns +(view_pattern + [ + (expression/variable) @function.call + (expression/qualified + (variable) @function.call) + ]) + +; consider infix functions as operators +(infix_id + [ + (variable) @operator + (qualified + (variable) @operator) + ]) + +; decl/function calls with an infix operator +; e.g. func <$> a <*> b +(infix + left_operand: [ + (variable) @function.call + (qualified + ((module) @module + (variable) @function.call)) + ]) + +; infix operators applied to variables +((expression/variable) @variable + . + (operator)) + +((operator) + . + [ + (expression/variable) @variable + (expression/qualified + (variable) @variable) + ]) + +; infix operator function definitions +(function + (infix + left_operand: [ + (variable) @variable + (qualified + ((module) @module + (variable) @variable)) + ]) + match: (match)) + +; decl/function calls with infix operators +([ + (expression/variable) @function.call + (expression/qualified + (variable) @function.call) +] + . + (operator) @_op + (#any-of? @_op "$" "<$>" ">>=" "=<<")) + +; right hand side of infix operator +((infix + [ + (operator) + (infix_id + (variable)) + ] ; infix or `func` + . + [ + (variable) @function.call + (qualified + (variable) @function.call) + ]) + . + (operator) @_op + (#any-of? @_op "$" "<$>" "=<<")) + +; decl/function composition, arrows, monadic composition (lhs) +([ + (expression/variable) @function + (expression/qualified + (variable) @function) +] + . + (operator) @_op + (#any-of? @_op "." ">>>" "***" ">=>" "<=<")) + +; right hand side of infix operator +((infix + [ + (operator) + (infix_id + (variable)) + ] ; infix or `func` + . + [ + (variable) @function + (qualified + (variable) @function) + ]) + . + (operator) @_op + (#any-of? @_op "." ">>>" "***" ">=>" "<=<")) + +; function composition, arrows, monadic composition (rhs) +((operator) @_op + . + [ + (expression/variable) @function + (expression/qualified + (variable) @function) + ] + (#any-of? @_op "." ">>>" "***" ">=>" "<=<")) + +; function defined in terms of a function composition +(decl/function + name: (variable) @function + (match + expression: (infix + operator: (operator) @_op + (#any-of? @_op "." ">>>" "***" ">=>" "<=<")))) + +(apply + [ + (expression/variable) @function.call + (expression/qualified + (variable) @function.call) + ]) + +; function compositions, in parentheses, applied +; lhs +(apply + . + (expression/parens + (infix + [ + (variable) @function.call + (qualified + (variable) @function.call) + ] + . + (operator)))) + +; rhs +(apply + . + (expression/parens + (infix + (operator) + . + [ + (variable) @function.call + (qualified + (variable) @function.call) + ]))) + +; variables being passed to a function call +(apply + (_) + . + [ + (expression/variable) @variable + (expression/qualified + (variable) @variable) + ]) + +; main is always a function +; (this prevents `main = undefined` from being highlighted as a variable) +(decl/bind + name: (variable) @function + (#eq? @function "main")) + +; scoped function types (func :: a -> b) +(signature + pattern: (pattern/variable) @function + type: (function)) + +; signatures that have a function type +; + binds that follow them +(decl/signature + name: (variable) @function + type: (function)) + +((decl/signature + name: (variable) @_name + type: (quantified_type)) + . + (decl/bind + (variable) @function) + (#eq? @function @_name)) + +; Treat constructor assignments (smart constructors) as functions, e.g. mkJust = Just +(bind + name: (variable) @function + match: (match + expression: (constructor))) + +; Function composition +(bind + name: (variable) @function + match: (match + expression: (infix + operator: (operator) @_op + (#eq? @_op ".")))) + +; ---------------------------------------------------------------------------- +; Types +(name) @type + +(type/unit) @type + +(type/unit + [ + "(" + ")" + ] @type) + +(type/list + [ + "[" + "]" + ] @type) + +(type/star) @type + +(constructor) @constructor + +; True or False +((constructor) @boolean + (#any-of? @boolean "True" "False")) + +; otherwise (= True) +((variable) @boolean + (#eq? @boolean "otherwise")) + +; ---------------------------------------------------------------------------- +; Quasi-quotes +(quoter) @function.call + +(quasiquote + quoter: [ + (quoter) @_name + (quoter + (qualified + id: (variable) @_name)) + ] + (#eq? @_name "qq") + body: (quasiquote_body) @string) + +; namespaced quasi-quoter +(quoter + [ + (variable) @function.call + (_ + (module) @module + . + (variable) @function.call) + ]) + +; Highlighting of quasiquote_body for other languages is handled by injections.scm +; ---------------------------------------------------------------------------- +; Exceptions/error handling +((variable) @keyword.exception + (#any-of? @keyword.exception + "error" "undefined" "try" "tryJust" "tryAny" "catch" "catches" "catchJust" "handle" "handleJust" + "throw" "throwIO" "throwTo" "throwError" "ioError" "mask" "mask_" "uninterruptibleMask" + "uninterruptibleMask_" "bracket" "bracket_" "bracketOnErrorSource" "finally" "fail" + "onException" "expectationFailure")) + +; ---------------------------------------------------------------------------- +; Debugging +((variable) @keyword.debug + (#any-of? @keyword.debug + "trace" "traceId" "traceShow" "traceShowId" "traceWith" "traceShowWith" "traceStack" "traceIO" + "traceM" "traceShowM" "traceEvent" "traceEventWith" "traceEventIO" "flushEventLog" "traceMarker" + "traceMarkerIO")) + +; ---------------------------------------------------------------------------- +; Fields +(field_name + (variable) @variable.member) + +(import_name + (name) + . + (children + (variable) @variable.member)) + +; ---------------------------------------------------------------------------- +; Spell checking +(comment) @spell diff --git a/runtime/queries/haskell/injections.scm b/runtime/queries/haskell/injections.scm new file mode 100644 index 000000000..a82addbce --- /dev/null +++ b/runtime/queries/haskell/injections.scm @@ -0,0 +1,84 @@ +; ----------------------------------------------------------------------------- +; General language injection +(quasiquote + (quoter) @injection.language + (quasiquote_body) @injection.content) + +((comment) @injection.content + (#set! injection.language "comment")) + +; ----------------------------------------------------------------------------- +; shakespeare library +; NOTE: doesn't support templating +; TODO: add once CoffeeScript parser is added +; ; CoffeeScript: Text.Coffee +; (quasiquote +; (quoter) @_name +; (#eq? @_name "coffee") +; ((quasiquote_body) @injection.content +; (#set! injection.language "coffeescript"))) +; CSS: Text.Cassius, Text.Lucius +(quasiquote + (quoter) @_name + (#any-of? @_name "cassius" "lucius") + (quasiquote_body) @injection.content + (#set! injection.language "css")) + +; HTML: Text.Hamlet +(quasiquote + (quoter) @_name + (#any-of? @_name "shamlet" "xshamlet" "hamlet" "xhamlet" "ihamlet") + (quasiquote_body) @injection.content + (#set! injection.language "html")) + +; JS: Text.Julius +(quasiquote + (quoter) @_name + (#any-of? @_name "js" "julius") + (quasiquote_body) @injection.content + (#set! injection.language "javascript")) + +; TS: Text.TypeScript +(quasiquote + (quoter) @_name + (#any-of? @_name "tsc" "tscJSX") + (quasiquote_body) @injection.content + (#set! injection.language "typescript")) + +; ----------------------------------------------------------------------------- +; HSX +(quasiquote + (quoter) @_name + (#eq? @_name "hsx") + (quasiquote_body) @injection.content + (#set! injection.language "html")) + +; ----------------------------------------------------------------------------- +; Inline JSON from aeson +(quasiquote + (quoter) @_name + (#eq? @_name "aesonQQ") + (quasiquote_body) @injection.content + (#set! injection.language "json")) + +; ----------------------------------------------------------------------------- +; SQL +; postgresql-simple +(quasiquote + (quoter) @injection.language + (#eq? @injection.language "sql") + (quasiquote_body) @injection.content) + +(quasiquote + (quoter) @_name + (#any-of? @_name "persistUpperCase" "persistLowerCase" "persistWith") + (quasiquote_body) @injection.content + (#set! injection.language "haskell_persistent")) + +; ----------------------------------------------------------------------------- +; Python +; inline-python +(quasiquote + (quoter) @injection.language + (#any-of? @injection.language "pymain" "pye" "py_" "pyf") + (quasiquote_body) @injection.content) diff --git a/runtime/queries/haskell/locals.scm b/runtime/queries/haskell/locals.scm new file mode 100644 index 000000000..7177f9dee --- /dev/null +++ b/runtime/queries/haskell/locals.scm @@ -0,0 +1,9 @@ +(signature + name: (variable)) @local.definition + +(function + name: (variable)) @local.definition + +(pattern/variable) @local.definition + +(expression/variable) @local.reference diff --git a/runtime/queries/haskell_persistent/folds.scm b/runtime/queries/haskell_persistent/folds.scm new file mode 100644 index 000000000..dd34d9f15 --- /dev/null +++ b/runtime/queries/haskell_persistent/folds.scm @@ -0,0 +1 @@ +(entity_definition) @fold diff --git a/runtime/queries/haskell_persistent/highlights.scm b/runtime/queries/haskell_persistent/highlights.scm new file mode 100644 index 000000000..22cbf5cb3 --- /dev/null +++ b/runtime/queries/haskell_persistent/highlights.scm @@ -0,0 +1,38 @@ +; ---------------------------------------------------------------------------- +; Literals and comments +(integer) @number + +(float) @number.float + +(char) @character + +(string) @string + +(attribute_name) @attribute + +(attribute_exclamation_mark) @attribute + +(con_unit) @string.special.symbol ; unit, as in () + +(comment) @comment @spell + +; ---------------------------------------------------------------------------- +; Keywords, operators, includes +[ + "Id" + "Primary" + "Foreign" + "deriving" +] @keyword + +"=" @operator + +; ---------------------------------------------------------------------------- +; Functions and variables +(variable) @variable + +; ---------------------------------------------------------------------------- +; Types +(type) @type + +(constructor) @constructor diff --git a/runtime/queries/hcl/folds.scm b/runtime/queries/hcl/folds.scm new file mode 100644 index 000000000..e0c5313a2 --- /dev/null +++ b/runtime/queries/hcl/folds.scm @@ -0,0 +1,6 @@ +[ + (comment) + (block) + (heredoc_template) + (object) +] @fold diff --git a/runtime/queries/hcl/highlights.scm b/runtime/queries/hcl/highlights.scm new file mode 100644 index 000000000..4fb7d1fca --- /dev/null +++ b/runtime/queries/hcl/highlights.scm @@ -0,0 +1,118 @@ +; highlights.scm +[ + "!" + "\*" + "/" + "%" + "\+" + "-" + ">" + ">=" + "<" + "<=" + "==" + "!=" + "&&" + "||" +] @operator + +[ + "{" + "}" + "[" + "]" + "(" + ")" +] @punctuation.bracket + +[ + "." + ".*" + "," + "[*]" +] @punctuation.delimiter + +[ + (ellipsis) + "\?" + "=>" +] @punctuation.special + +[ + ":" + "=" +] @none + +[ + "for" + "endfor" + "in" +] @keyword.repeat + +[ + "if" + "else" + "endif" +] @keyword.conditional + +[ + (quoted_template_start) ; " + (quoted_template_end) ; " + (template_literal) ; non-interpolation/directive content +] @string + +[ + (heredoc_identifier) ; END + (heredoc_start) ; << or <<- +] @punctuation.delimiter + +[ + (template_interpolation_start) ; ${ + (template_interpolation_end) ; } + (template_directive_start) ; %{ + (template_directive_end) ; } + (strip_marker) ; ~ +] @punctuation.special + +(numeric_lit) @number + +(bool_lit) @boolean + +(null_lit) @constant + +(comment) @comment @spell + +(identifier) @variable + +(body + (block + (identifier) @keyword)) + +(body + (block + (body + (block + (identifier) @type)))) + +(function_call + (identifier) @function) + +(attribute + (identifier) @variable.member) + +; { key: val } +; +; highlight identifier keys as though they were block attributes +(object_elem + key: (expression + (variable_expr + (identifier) @variable.member))) + +; var.foo, data.bar +; +; first element in get_attr is a variable.builtin or a reference to a variable.builtin +(expression + (variable_expr + (identifier) @variable.builtin) + (get_attr + (identifier) @variable.member)) diff --git a/runtime/queries/hcl/indents.scm b/runtime/queries/hcl/indents.scm new file mode 100644 index 000000000..1d7dc49d9 --- /dev/null +++ b/runtime/queries/hcl/indents.scm @@ -0,0 +1,16 @@ +[ + (block) + (object) + (tuple) + (function_call) +] @indent.begin + +[ + "]" + ")" + "}" +] @indent.branch @indent.end + +(comment) @indent.auto + +(ERROR) @indent.auto diff --git a/runtime/queries/hcl/injections.scm b/runtime/queries/hcl/injections.scm new file mode 100644 index 000000000..b68f4caea --- /dev/null +++ b/runtime/queries/hcl/injections.scm @@ -0,0 +1,7 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +(heredoc_template + (template_literal) @injection.content + (heredoc_identifier) @injection.language + (#downcase! @injection.language)) diff --git a/runtime/queries/heex/folds.scm b/runtime/queries/heex/folds.scm new file mode 100644 index 000000000..88d4f17ff --- /dev/null +++ b/runtime/queries/heex/folds.scm @@ -0,0 +1,6 @@ +; HEEx tags, components, and slots fold similar to HTML +[ + (component) + (tag) + (slot) +] @fold diff --git a/runtime/queries/heex/highlights.scm b/runtime/queries/heex/highlights.scm new file mode 100644 index 000000000..e2fb01880 --- /dev/null +++ b/runtime/queries/heex/highlights.scm @@ -0,0 +1,54 @@ +; HEEx delimiters +[ + "%>" + "--%>" + "-->" + "/>" + "<!" + "<!--" + "<" + "<%!--" + "<%" + "<%#" + "<%%=" + "<%=" + "</" + "</:" + "<:" + ">" + "{" + "}" +] @tag.delimiter + +; HEEx operators are highlighted as such +"=" @operator + +; HEEx inherits the DOCTYPE tag from HTML +(doctype) @constant + +; HEEx comments are highlighted as such +(comment) @comment @spell + +; HEEx text content is treated as markup +; (text) @none +; HEEx tags and slots are highlighted as HTML +[ + (tag_name) + (slot_name) +] @tag + +; HEEx attributes are highlighted as HTML attributes +(attribute_name) @tag.attribute + +[ + (attribute_value) + (quoted_attribute_value) +] @string + +; HEEx components are highlighted as modules and function calls +(component_name + [ + (module) @type + (function) @function + "." @punctuation.delimiter + ]) diff --git a/runtime/queries/heex/indents.scm b/runtime/queries/heex/indents.scm new file mode 100644 index 000000000..82a2f8912 --- /dev/null +++ b/runtime/queries/heex/indents.scm @@ -0,0 +1,20 @@ +; HEEx tags, components, and slots indent like HTML +[ + (component) + (slot) + (tag) +] @indent.begin + +; Dedent at the end of each tag, component, and slot +[ + (end_component) + (end_slot) + (end_tag) +] @indent.branch @indent.dedent + +; Self-closing tags and components should not change +; indentation level of sibling nodes +[ + (self_closing_component) + (self_closing_tag) +] @indent.auto diff --git a/runtime/queries/heex/injections.scm b/runtime/queries/heex/injections.scm new file mode 100644 index 000000000..4f179ee80 --- /dev/null +++ b/runtime/queries/heex/injections.scm @@ -0,0 +1,30 @@ +; directives are standalone tags like '<%= @x %>' +; +; partial_expression_values are elixir code that is part of an expression that +; spans multiple directive nodes, so they must be combined. For example: +; <%= if true do %> +; <p>hello, tree-sitter!</p> +; <% end %> +(directive + [ + (partial_expression_value) + (ending_expression_value) + ] @injection.content + (#set! injection.language "elixir") + (#set! injection.include-children) + (#set! injection.combined)) + +; Regular expression_values do not need to be combined +((directive + (expression_value) @injection.content) + (#set! injection.language "elixir")) + +; expressions live within HTML tags, and do not need to be combined +; <link href={ Routes.static_path(..) } /> +(expression + (expression_value) @injection.content + (#set! injection.language "elixir")) + +; HEEx comments +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/heex/locals.scm b/runtime/queries/heex/locals.scm new file mode 100644 index 000000000..cfa239e5f --- /dev/null +++ b/runtime/queries/heex/locals.scm @@ -0,0 +1,13 @@ +; HEEx tags, components, and slots are references +[ + (component_name) + (slot_name) + (tag_name) +] @local.reference + +; Create a new scope within each HEEx tag, component, and slot +[ + (component) + (slot) + (tag) +] @local.scope diff --git a/runtime/queries/helm/folds.scm b/runtime/queries/helm/folds.scm new file mode 100644 index 000000000..6ffb4b7d4 --- /dev/null +++ b/runtime/queries/helm/folds.scm @@ -0,0 +1 @@ +; inherits: gotmpl diff --git a/runtime/queries/helm/highlights.scm b/runtime/queries/helm/highlights.scm new file mode 100644 index 000000000..e9d221bee --- /dev/null +++ b/runtime/queries/helm/highlights.scm @@ -0,0 +1,49 @@ +; inherits: gotmpl + +; For the reasoning concerning the priorities, see gotmpl highlights. +; +; Builtin functions +(function_call + function: (identifier) @function.builtin + (#set! priority 110) + (#any-of? @function.builtin + "and" "or" "not" "eq" "ne" "lt" "le" "gt" "ge" "default" "required" "empty" "fail" "coalesce" + "ternary" "print" "println" "printf" "trim" "trimAll" "trimPrefix" "trimSuffix" "lower" "upper" + "title" "untitle" "repeat" "substr" "nospace" "trunc" "abbrev" "abbrevboth" "initials" + "randAlphaNum" "randAlpha" "randNumeric" "randAscii" "wrap" "wrapWith" "contains" "hasPrefix" + "hasSuffix" "quote" "squote" "cat" "indent" "nindent" "replace" "plural" "snakecase" "camelcase" + "kebabcase" "swapcase" "shuffle" "toStrings" "toDecimal" "toJson" "mustToJson" "toPrettyJson" + "mustToPrettyJson" "toRawJson" "mustToRawJson" "fromYaml" "fromJson" "fromJsonArray" + "fromYamlArray" "toYaml" "regexMatch" "mustRegexMatch" "regexFindAll" "mustRegexFinDall" + "regexFind" "mustRegexFind" "regexReplaceAll" "mustRegexReplaceAll" "regexReplaceAllLiteral" + "mustRegexReplaceAllLiteral" "regexSplit" "mustRegexSplit" "sha1sum" "sha256sum" "adler32sum" + "htpasswd" "derivePassword" "genPrivateKey" "buildCustomCert" "genCA" "genSelfSignedCert" + "genSignedCert" "encryptAES" "decryptAES" "now" "ago" "date" "dateInZone" "duration" + "durationRound" "unixEpoch" "dateModify" "mustDateModify" "htmlDate" "htmlDateInZone" "toDate" + "mustToDate" "dict" "get" "set" "unset" "hasKey" "pluck" "dig" "merge" "mustMerge" + "mergeOverwrite" "mustMergeOverwrite" "keys" "pick" "omit" "values" "deepCopy" "mustDeepCopy" + "b64enc" "b64dec" "b32enc" "b32dec" "list" "first" "mustFirst" "rest" "mustRest" "last" + "mustLast" "initial" "mustInitial" "append" "mustAppend" "prepend" "mustPrepend" "concat" + "reverse" "mustReverse" "uniq" "mustUniq" "without" "mustWithout" "has" "mustHas" "compact" + "mustCompact" "index" "slice" "mustSlice" "until" "untilStep" "seq" "add" "add1" "sub" "div" + "mod" "mul" "max" "min" "len" "addf" "add1f" "subf" "divf" "mulf" "maxf" "minf" "floor" "ceil" + "round" "getHostByName" "base" "dir" "clean" "ext" "isAbs" "kindOf" "kindIs" "typeOf" "typeIs" + "typeIsLike" "deepequal" "semver" "semverCompare" "urlParse" "urlJoin" "urlquery" "lookup" + "include")) + +; {{ .Values.test }} +(selector_expression + operand: (field + name: (identifier) @constant.builtin + (#set! priority 110) + (#any-of? @constant.builtin + "Values" "Chart" "Release" "Capabilities" "Files" "Subcharts" "Template")) + (field_identifier)) + +; {{ $.Values.test }} +(selector_expression + operand: (variable) + field: (field_identifier) @constant.builtin + (#set! priority 110) + (#any-of? @constant.builtin + "Values" "Chart" "Release" "Capabilities" "Files" "Subcharts" "Template")) diff --git a/runtime/queries/helm/injections.scm b/runtime/queries/helm/injections.scm new file mode 100644 index 000000000..2adf8743a --- /dev/null +++ b/runtime/queries/helm/injections.scm @@ -0,0 +1,36 @@ +; inherits: gotmpl + +((text) @injection.content + (#set! injection.language "yaml") + (#set! injection.combined)) + +; {{ regexFind "[a-zA-Z][1-9]" "abcd1234" }} +(function_call + function: (identifier) @_function + arguments: (argument_list + . + (interpreted_string_literal) @injection.content) + (#any-of? @_function + "regexMatch" "mustRegexMatch" "regexFindAll" "mustRegexFinDall" "regexFind" "mustRegexFind" + "regexReplaceAll" "mustRegexReplaceAll" "regexReplaceAllLiteral" "mustRegexReplaceAllLiteral" + "regexSplit" "mustRegexSplit") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "regex")) + +(function_call + function: (identifier) @_function + arguments: (argument_list + . + (interpreted_string_literal) @injection.content) + (#any-of? @_function "fromYaml" "fromYamlArray") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "yaml")) + +(function_call + function: (identifier) @_function + arguments: (argument_list + . + (interpreted_string_literal) @injection.content) + (#any-of? @_function "fromJson" "fromJsonArray") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "json")) diff --git a/runtime/queries/helm/locals.scm b/runtime/queries/helm/locals.scm new file mode 100644 index 000000000..6ffb4b7d4 --- /dev/null +++ b/runtime/queries/helm/locals.scm @@ -0,0 +1 @@ +; inherits: gotmpl diff --git a/runtime/queries/hjson/folds.scm b/runtime/queries/hjson/folds.scm new file mode 100644 index 000000000..41269219e --- /dev/null +++ b/runtime/queries/hjson/folds.scm @@ -0,0 +1 @@ +; inherits: json diff --git a/runtime/queries/hjson/highlights.scm b/runtime/queries/hjson/highlights.scm new file mode 100644 index 000000000..8333d8fe5 --- /dev/null +++ b/runtime/queries/hjson/highlights.scm @@ -0,0 +1,28 @@ +(true) @boolean + +(false) @boolean + +(null) @constant.builtin + +(number) @number + +(pair + key: (string) @label) + +(pair + value: (string) @string) + +(array + (string) @string) + +; (string_content (escape_sequence) @string.escape) +; "," @punctuation.delimiter +"[" @punctuation.bracket + +"]" @punctuation.bracket + +"{" @punctuation.bracket + +"}" @punctuation.bracket + +(comment) @comment @spell diff --git a/runtime/queries/hjson/indents.scm b/runtime/queries/hjson/indents.scm new file mode 100644 index 000000000..3b01ca999 --- /dev/null +++ b/runtime/queries/hjson/indents.scm @@ -0,0 +1,3 @@ +; inherits: json + +(comment) @indent.ignore diff --git a/runtime/queries/hjson/injections.scm b/runtime/queries/hjson/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/hjson/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/hjson/locals.scm b/runtime/queries/hjson/locals.scm new file mode 100644 index 000000000..41269219e --- /dev/null +++ b/runtime/queries/hjson/locals.scm @@ -0,0 +1 @@ +; inherits: json diff --git a/runtime/queries/hlsl/folds.scm b/runtime/queries/hlsl/folds.scm new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/runtime/queries/hlsl/folds.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/runtime/queries/hlsl/highlights.scm b/runtime/queries/hlsl/highlights.scm new file mode 100644 index 000000000..839d8d79a --- /dev/null +++ b/runtime/queries/hlsl/highlights.scm @@ -0,0 +1,38 @@ +; inherits: cpp + +[ + "in" + "out" + "inout" + "uniform" + "shared" + "groupshared" + "discard" + "cbuffer" + "row_major" + "column_major" + "globallycoherent" + "centroid" + "noperspective" + "nointerpolation" + "sample" + "linear" + "snorm" + "unorm" + "point" + "line" + "triangleadj" + "lineadj" + "triangle" +] @keyword.modifier + +((identifier) @variable.builtin + (#lua-match? @variable.builtin "^SV_")) + +(hlsl_attribute) @attribute + +(hlsl_attribute + [ + "[" + "]" + ] @attribute) diff --git a/runtime/queries/hlsl/indents.scm b/runtime/queries/hlsl/indents.scm new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/runtime/queries/hlsl/indents.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/runtime/queries/hlsl/injections.scm b/runtime/queries/hlsl/injections.scm new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/runtime/queries/hlsl/injections.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/runtime/queries/hlsl/locals.scm b/runtime/queries/hlsl/locals.scm new file mode 100644 index 000000000..b617fdc56 --- /dev/null +++ b/runtime/queries/hlsl/locals.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/runtime/queries/hlsplaylist/highlights.scm b/runtime/queries/hlsplaylist/highlights.scm new file mode 100644 index 000000000..9852aed6d --- /dev/null +++ b/runtime/queries/hlsplaylist/highlights.scm @@ -0,0 +1,41 @@ +; Comments +(comment) @comment @spell + +; General +(uri) @string.special.url + +(tag_name) @keyword + +(attribute_name) @attribute + +[ + (dec) + (hex) + (resolution) + (range) +] @number + +(float) @number.float + +(string) @string + +[ + (enum) + (date_time_msec) +] @string.special + +(title) @markup.heading + +; Literals +[ + "=" + "x" + "@" +] @operator + +[ + ":" + "," +] @punctuation.delimiter + +"#" @punctuation.special diff --git a/runtime/queries/hlsplaylist/injections.scm b/runtime/queries/hlsplaylist/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/hlsplaylist/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/hocon/folds.scm b/runtime/queries/hocon/folds.scm new file mode 100644 index 000000000..cc8a231a4 --- /dev/null +++ b/runtime/queries/hocon/folds.scm @@ -0,0 +1,4 @@ +[ + (object) + (array) +] @fold diff --git a/runtime/queries/hocon/highlights.scm b/runtime/queries/hocon/highlights.scm new file mode 100644 index 000000000..0eb94e6dd --- /dev/null +++ b/runtime/queries/hocon/highlights.scm @@ -0,0 +1,65 @@ +(comment) @comment @spell + +(null) @constant.builtin + +[ + (true) + (false) +] @boolean + +(number) @number + +(unit) @keyword + +(string) @string + +(multiline_string) @string + +(string + (escape_sequence) @string.escape) + +(unquoted_string) @string + +[ + "url" + "file" + "classpath" + "required" +] @keyword + +(include + "include" @keyword.import) + +(substitution + [ + "${" + "${?" + "}" + ] @punctuation.special) + +(substitution + (_) @variable.member) + +(path + (_) @variable.member) + +(value + [ + ":" + "=" + "+=" + ] @operator) + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +"," @punctuation.delimiter + +(unquoted_path + "." @punctuation.delimiter) diff --git a/runtime/queries/hocon/injections.scm b/runtime/queries/hocon/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/hocon/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/hoon/folds.scm b/runtime/queries/hoon/folds.scm new file mode 100644 index 000000000..cfb4b6d0c --- /dev/null +++ b/runtime/queries/hoon/folds.scm @@ -0,0 +1,6 @@ +[ + (bartisTall) + (luslusTall) + (lusbucTall) + (barcenTall) +] @fold diff --git a/runtime/queries/hoon/highlights.scm b/runtime/queries/hoon/highlights.scm new file mode 100644 index 000000000..90ac87217 --- /dev/null +++ b/runtime/queries/hoon/highlights.scm @@ -0,0 +1,35 @@ +(number) @number + +(string) @string + +[ + "(" + ")" + "[" + "]" +] @punctuation.bracket + +[ + (coreTerminator) + (seriesTerminator) +] @punctuation.delimiter + +(rune) @operator + +(term) @constant + +(aura) @constant.builtin + +(lineComment) @comment + +(boolean) @constant.builtin + +(date) @string.special + +(mold) @string.special.symbol + +(specialIndex) @number + +(lark) @operator + +(fullContext) @string.special.symbol diff --git a/runtime/queries/hoon/injections.scm b/runtime/queries/hoon/injections.scm new file mode 100644 index 000000000..a004ba0b4 --- /dev/null +++ b/runtime/queries/hoon/injections.scm @@ -0,0 +1,2 @@ +((lineComment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/hoon/locals.scm b/runtime/queries/hoon/locals.scm new file mode 100644 index 000000000..fd7cc026d --- /dev/null +++ b/runtime/queries/hoon/locals.scm @@ -0,0 +1,4 @@ +(tisfasTall + name: (name) @local.definition.var) + +(name) @local.reference diff --git a/runtime/queries/html/folds.scm b/runtime/queries/html/folds.scm new file mode 100644 index 000000000..69b57eac5 --- /dev/null +++ b/runtime/queries/html/folds.scm @@ -0,0 +1,5 @@ +[ + (element) + (style_element) + (script_element) +] @fold diff --git a/runtime/queries/html/highlights.scm b/runtime/queries/html/highlights.scm new file mode 100644 index 000000000..4e2371d64 --- /dev/null +++ b/runtime/queries/html/highlights.scm @@ -0,0 +1,7 @@ +; inherits: html_tags + +(doctype) @constant + +"<!" @tag.delimiter + +(entity) @character.special diff --git a/runtime/queries/html/indents.scm b/runtime/queries/html/indents.scm new file mode 100644 index 000000000..448e94275 --- /dev/null +++ b/runtime/queries/html/indents.scm @@ -0,0 +1 @@ +; inherits: html_tags diff --git a/runtime/queries/html/injections.scm b/runtime/queries/html/injections.scm new file mode 100644 index 000000000..adb067d15 --- /dev/null +++ b/runtime/queries/html/injections.scm @@ -0,0 +1,26 @@ +; inherits html_tags +(element + (start_tag + (tag_name) @_py_script) + (text) @injection.content + (#any-of? @_py_script "py-script" "py-repl") + (#set! injection.language "python")) + +(script_element + (start_tag + (attribute + (attribute_name) @_attr + (quoted_attribute_value + (attribute_value) @_type))) + (raw_text) @injection.content + (#eq? @_attr "type") + ; not adding type="py" here as it's handled by html_tags + (#any-of? @_type "pyscript" "py-script") + (#set! injection.language "python")) + +(element + (start_tag + (tag_name) @_py_config) + (text) @injection.content + (#eq? @_py_config "py-config") + (#set! injection.language "toml")) diff --git a/runtime/queries/html/locals.scm b/runtime/queries/html/locals.scm new file mode 100644 index 000000000..4e3325db8 --- /dev/null +++ b/runtime/queries/html/locals.scm @@ -0,0 +1 @@ +(element) @local.scope diff --git a/runtime/queries/html_tags/highlights.scm b/runtime/queries/html_tags/highlights.scm new file mode 100644 index 000000000..9eaf813be --- /dev/null +++ b/runtime/queries/html_tags/highlights.scm @@ -0,0 +1,106 @@ +(tag_name) @tag + +; (erroneous_end_tag_name) @error ; we do not lint syntax errors +(comment) @comment @spell + +(attribute_name) @tag.attribute + +((attribute + (quoted_attribute_value) @string) + (#set! priority 99)) + +(text) @none @spell + +((element + (start_tag + (tag_name) @_tag) + (text) @markup.heading) + (#eq? @_tag "title")) + +((element + (start_tag + (tag_name) @_tag) + (text) @markup.heading.1) + (#eq? @_tag "h1")) + +((element + (start_tag + (tag_name) @_tag) + (text) @markup.heading.2) + (#eq? @_tag "h2")) + +((element + (start_tag + (tag_name) @_tag) + (text) @markup.heading.3) + (#eq? @_tag "h3")) + +((element + (start_tag + (tag_name) @_tag) + (text) @markup.heading.4) + (#eq? @_tag "h4")) + +((element + (start_tag + (tag_name) @_tag) + (text) @markup.heading.5) + (#eq? @_tag "h5")) + +((element + (start_tag + (tag_name) @_tag) + (text) @markup.heading.6) + (#eq? @_tag "h6")) + +((element + (start_tag + (tag_name) @_tag) + (text) @markup.strong) + (#any-of? @_tag "strong" "b")) + +((element + (start_tag + (tag_name) @_tag) + (text) @markup.italic) + (#any-of? @_tag "em" "i")) + +((element + (start_tag + (tag_name) @_tag) + (text) @markup.strikethrough) + (#any-of? @_tag "s" "del")) + +((element + (start_tag + (tag_name) @_tag) + (text) @markup.underline) + (#eq? @_tag "u")) + +((element + (start_tag + (tag_name) @_tag) + (text) @markup.raw) + (#any-of? @_tag "code" "kbd")) + +((element + (start_tag + (tag_name) @_tag) + (text) @markup.link.label) + (#eq? @_tag "a")) + +((attribute + (attribute_name) @_attr + (quoted_attribute_value + (attribute_value) @string.special.url)) + (#any-of? @_attr "href" "src") + (#set! @string.special.url url @string.special.url)) + +[ + "<" + ">" + "</" + "/>" +] @tag.delimiter + +"=" @operator diff --git a/runtime/queries/html_tags/indents.scm b/runtime/queries/html_tags/indents.scm new file mode 100644 index 000000000..dc57c333a --- /dev/null +++ b/runtime/queries/html_tags/indents.scm @@ -0,0 +1,37 @@ +((element + (start_tag + (tag_name) @_not_void_element)) + (#not-any-of? @_not_void_element + "area" "base" "basefont" "bgsound" "br" "col" "command" "embed" "frame" "hr" "image" "img" + "input" "isindex" "keygen" "link" "menuitem" "meta" "nextid" "param" "source" "track" "wbr")) @indent.begin + +(element + (self_closing_tag)) @indent.begin + +((start_tag + (tag_name) @_void_element) + (#any-of? @_void_element + "area" "base" "basefont" "bgsound" "br" "col" "command" "embed" "frame" "hr" "image" "img" + "input" "isindex" "keygen" "link" "menuitem" "meta" "nextid" "param" "source" "track" "wbr")) @indent.begin + +; These are the nodes that will be captured when we do `normal o` +; But last element has already been ended, so capturing this +; to mark end of last element +(element + (end_tag + ">" @indent.end)) + +(element + (self_closing_tag + "/>" @indent.end)) + +; Script/style elements aren't indented, so only branch the end tag of other elements +(element + (end_tag) @indent.branch) + +[ + ">" + "/>" +] @indent.branch + +(comment) @indent.ignore diff --git a/runtime/queries/html_tags/injections.scm b/runtime/queries/html_tags/injections.scm new file mode 100644 index 000000000..5b78e37b4 --- /dev/null +++ b/runtime/queries/html_tags/injections.scm @@ -0,0 +1,91 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; <style>...</style> +; <style blocking> ...</style> +; Add "lang" to predicate check so that vue/svelte can inherit this +; without having this element being captured twice +((style_element + (start_tag) @_no_type_lang + (raw_text) @injection.content) + (#not-lua-match? @_no_type_lang "%slang%s*=") + (#not-lua-match? @_no_type_lang "%stype%s*=") + (#set! injection.language "css")) + +((style_element + (start_tag + (attribute + (attribute_name) @_type + (quoted_attribute_value + (attribute_value) @_css))) + (raw_text) @injection.content) + (#eq? @_type "type") + (#eq? @_css "text/css") + (#set! injection.language "css")) + +; <script>...</script> +; <script defer>...</script> +((script_element + (start_tag) @_no_type_lang + (raw_text) @injection.content) + (#not-lua-match? @_no_type_lang "%slang%s*=") + (#not-lua-match? @_no_type_lang "%stype%s*=") + (#set! injection.language "javascript")) + +; <script type="mimetype-or-well-known-script-type"> +(script_element + (start_tag + (attribute + (attribute_name) @_attr + (#eq? @_attr "type") + (quoted_attribute_value + (attribute_value) @_type))) + (raw_text) @injection.content + (#set-lang-from-mimetype! @_type)) + +; <a style="/* css */"> +((attribute + (attribute_name) @_attr + (quoted_attribute_value + (attribute_value) @injection.content)) + (#eq? @_attr "style") + (#set! injection.language "css")) + +; lit-html style template interpolation +; <a @click=${e => console.log(e)}> +; <a @click="${e => console.log(e)}"> +((attribute + (quoted_attribute_value + (attribute_value) @injection.content)) + (#lua-match? @injection.content "%${") + (#offset! @injection.content 0 2 0 -1) + (#set! injection.language "javascript")) + +((attribute + (attribute_value) @injection.content) + (#lua-match? @injection.content "%${") + (#offset! @injection.content 0 2 0 -2) + (#set! injection.language "javascript")) + +; <input pattern="[0-9]"> or <input pattern=[0-9]> +(element + (_ + (tag_name) @_tagname + (#eq? @_tagname "input") + (attribute + (attribute_name) @_attr + [ + (quoted_attribute_value + (attribute_value) @injection.content) + (attribute_value) @injection.content + ] + (#eq? @_attr "pattern")) + (#set! injection.language "regex"))) + +; <input type="checkbox" onchange="this.closest('form').elements.output.value = this.checked"> +(attribute + (attribute_name) @_name + (#lua-match? @_name "^on[a-z]+$") + (quoted_attribute_value + (attribute_value) @injection.content) + (#set! injection.language "javascript")) diff --git a/runtime/queries/htmldjango/folds.scm b/runtime/queries/htmldjango/folds.scm new file mode 100644 index 000000000..5e8f17c78 --- /dev/null +++ b/runtime/queries/htmldjango/folds.scm @@ -0,0 +1,4 @@ +[ + (paired_statement) + (paired_comment) +] @fold diff --git a/runtime/queries/htmldjango/highlights.scm b/runtime/queries/htmldjango/highlights.scm new file mode 100644 index 000000000..3992b826d --- /dev/null +++ b/runtime/queries/htmldjango/highlights.scm @@ -0,0 +1,73 @@ +; adapted from https://github.com/interdependence/tree-sitter-htmldjango +[ + (unpaired_comment) + (paired_comment) +] @comment @spell + +[ + "{{" + "}}" + "{%" + "%}" + (end_paired_statement) +] @punctuation.special + +(tag_name) @function + +((tag_name) @keyword.conditional + (#any-of? @keyword.conditional "if" "elif" "else" "endif")) + +((tag_name) @keyword.repeat + (#any-of? @keyword.repeat "for" "endfor")) + +(variable_name) @variable + +(unpaired_statement + (tag_name) + (variable + (variable_name) @variable.parameter) + . + "=" + . + (_)) + +(filter_name) @function.method + +(filter_argument) @variable.parameter + +(keyword) @keyword + +[ + "|" + "=" + (operator) +] @operator + +(keyword_operator) @keyword.operator + +(string) @string + +(filter + [ + "'" + "\"" + ] + . + (filter_argument) @string) + +(number) @number + +((filter + (filter_argument) @number) + (#lua-match? @number "^%d+$")) + +(boolean) @boolean + +((filter + (filter_argument) @boolean) + (#any-of? @boolean "True" "False")) + +[ + ":" + "," +] @punctuation.delimiter diff --git a/runtime/queries/htmldjango/indents.scm b/runtime/queries/htmldjango/indents.scm new file mode 100644 index 000000000..d671f045d --- /dev/null +++ b/runtime/queries/htmldjango/indents.scm @@ -0,0 +1,5 @@ +(paired_statement) @indent.begin + +(end_paired_statement) @indent.end + +(branch_statement) @indent.branch diff --git a/runtime/queries/htmldjango/injections.scm b/runtime/queries/htmldjango/injections.scm new file mode 100644 index 000000000..2d3bdb6cd --- /dev/null +++ b/runtime/queries/htmldjango/injections.scm @@ -0,0 +1,9 @@ +([ + (paired_comment) + (unpaired_comment) +] @injection.content + (#set! injection.language "comment")) + +((content) @injection.content + (#set! injection.language "html") + (#set! injection.combined)) diff --git a/runtime/queries/http/folds.scm b/runtime/queries/http/folds.scm new file mode 100644 index 000000000..f7108a551 --- /dev/null +++ b/runtime/queries/http/folds.scm @@ -0,0 +1,5 @@ +[ + (section) + (json_body) + (variable_declaration)+ +] @fold diff --git a/runtime/queries/http/highlights.scm b/runtime/queries/http/highlights.scm new file mode 100644 index 000000000..1ac243729 --- /dev/null +++ b/runtime/queries/http/highlights.scm @@ -0,0 +1,64 @@ +; Methods +(method) @function.method + +; Headers +(header + name: (_) @constant) + +(header + value: (_) @string) + +; Variables +(identifier) @variable + +(variable_declaration + "@" @character.special) + +(variable_declaration + (value) @string) + +; Operators +(comment + "=" @operator) + +(variable_declaration + "=" @operator) + +; keywords +(comment + "@" @keyword + name: (_) @keyword) + +; Literals +(request + url: (_) @string.special.url) + +(http_version) @string.special + +; Response +(status_code) @number + +(status_text) @string + +; Punctuation +[ + "{{" + "}}" + "{%" + "%}" +] @punctuation.bracket + +">" @punctuation.special + +(header + ":" @punctuation.delimiter) + +; external JSON body +(external_body + path: (_) @string.special.path) + +; Comments +[ + (comment) + (request_separator) +] @comment @spell diff --git a/runtime/queries/http/injections.scm b/runtime/queries/http/injections.scm new file mode 100644 index 000000000..f0e086580 --- /dev/null +++ b/runtime/queries/http/injections.scm @@ -0,0 +1,24 @@ +; Comments +((comment) @injection.content + (#set! injection.language "comment")) + +; Body +((json_body) @injection.content + (#set! injection.language "json")) + +((xml_body) @injection.content + (#set! injection.language "xml")) + +((graphql_data) @injection.content + (#set! injection.language "graphql")) + +; Script (default to javascript) +((comment + name: (_) @_name + (#eq? @_name "lang") + value: (_) @injection.language)? + . + (_ + (script) @injection.content + (#offset! @injection.content 0 2 0 -2)) + (#set! injection.language "javascript")) diff --git a/runtime/queries/hurl/folds.scm b/runtime/queries/hurl/folds.scm new file mode 100644 index 000000000..a0edfa930 --- /dev/null +++ b/runtime/queries/hurl/folds.scm @@ -0,0 +1,19 @@ +; fold.scm +[ + (comment) + (entry) + (request) + (response) + (header) + (request_section) + (body) + (response_section) + (multipart_form_data_section) + (cookies_section) + (captures_section) + (asserts_section) + (options_section) + (basic_auth_section) + (json_object) + (json_array) +] @fold diff --git a/runtime/queries/hurl/highlights.scm b/runtime/queries/hurl/highlights.scm new file mode 100644 index 000000000..70b220985 --- /dev/null +++ b/runtime/queries/hurl/highlights.scm @@ -0,0 +1,148 @@ +; highlights.scm +[ + (key_string) + (json_key_string) +] @property + +[ + "[QueryStringParams]" + "[FormParams]" + "[MultipartFormData]" + "[Cookies]" + "[Captures]" + "[Asserts]" + "[Options]" + "[BasicAuth]" +] @module + +[ + "\\" + (regex_escaped_char) + (quoted_string_escaped_char) + (key_string_escaped_char) + (value_string_escaped_char) + (oneline_string_escaped_char) + (multiline_string_escaped_char) + (filename_escaped_char) + (json_string_escaped_char) +] @string.escape + +[ + "status" + "url" + "header" + "cookie" + "body" + "xpath" + "jsonpath" + "regex" + "variable" + "duration" + "sha256" + "md5" + "bytes" +] @function.builtin + +[ + "null" + "cacert" + "compressed" + "location" + "insecure" + "path-as-is" + "proxy" + "max-redirs" + "retry" + "retry-interval" + "retry-max-count" + "verbose" + "very-verbose" +] @constant.builtin + +(variable_option + "variable" @constant.builtin) + +(boolean) @boolean + +(variable_name) @variable + +[ + "not" + "equals" + "notEquals" + "greaterThan" + "greaterThanOrEquals" + "lessThan" + "lessThanOrEquals" + "startsWith" + "endsWith" + "contains" + "matches" + "exists" + "includes" + "isInteger" + "isFloat" + "isBoolean" + "isString" + "isCollection" +] @keyword.operator + +[ + "==" + "!=" + ">" + ">=" + "<" + "<=" +] @operator + +[ + (integer) + (status) +] @number + +[ + (float) + (json_number) +] @number.float + +[ + ":" + "," +] @punctuation.delimiter + +[ + "[" + "]" + "{" + "}" + "{{" + "}}" +] @punctuation.bracket + +[ + (value_string) + (quoted_string) + (json_string) +] @string + +[ + "base64," + "hex," + (version) +] @string.special + +[ + "file," + (file_value) +] @string.special.path + +(regex) @string.regexp + +(multiline_string_type) @type + +(comment) @comment @spell + +(filter) @attribute + +(method) @type.builtin diff --git a/runtime/queries/hurl/indents.scm b/runtime/queries/hurl/indents.scm new file mode 100644 index 000000000..af6fdfa4e --- /dev/null +++ b/runtime/queries/hurl/indents.scm @@ -0,0 +1,14 @@ +; indents.scm +[ + (json_object) + (json_array) +] @indent.begin + +[ + "}" + "]" +] @indent.branch + +(xml_tag) @indent.begin + +(xml_close_tag) @indent.branch diff --git a/runtime/queries/hurl/injections.scm b/runtime/queries/hurl/injections.scm new file mode 100644 index 000000000..41abb387b --- /dev/null +++ b/runtime/queries/hurl/injections.scm @@ -0,0 +1,15 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; injections.scm +((json_value) @injection.content + (#set! injection.language "json")) + +((xml) @injection.content + (#set! injection.language "xml")) + +(multiline_string + (multiline_string_type) @_lang + (multiline_string_content) @injection.content + (#set-lang-from-info-string! @_lang) + (#set! injection.combined)) diff --git a/runtime/queries/hyprlang/folds.scm b/runtime/queries/hyprlang/folds.scm new file mode 100644 index 000000000..911798f5a --- /dev/null +++ b/runtime/queries/hyprlang/folds.scm @@ -0,0 +1 @@ +(section) @fold diff --git a/runtime/queries/hyprlang/highlights.scm b/runtime/queries/hyprlang/highlights.scm new file mode 100644 index 000000000..5e3514125 --- /dev/null +++ b/runtime/queries/hyprlang/highlights.scm @@ -0,0 +1,65 @@ +(comment) @comment @spell + +[ + "source" + "exec" + "exec-once" +] @keyword + +(keyword + (name) @keyword) + +(assignment + (name) @property) + +(section + (name) @module) + +(section + device: (device_name) @string.special) + +(variable) @variable + +"$" @punctuation.special + +(boolean) @boolean + +[ + "deg" + (string) + (string_literal) +] @string + +(mod) @constant.builtin + +[ + "rgb" + "rgba" +] @function.builtin + +[ + (number) + (legacy_hex) + (angle) + (hex) +] @number + +[ + "," + ":" + "x" + "@" +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" +] @punctuation.bracket + +[ + "=" + "-" + "+" +] @operator diff --git a/runtime/queries/hyprlang/indents.scm b/runtime/queries/hyprlang/indents.scm new file mode 100644 index 000000000..731ae9a61 --- /dev/null +++ b/runtime/queries/hyprlang/indents.scm @@ -0,0 +1,6 @@ +(section) @indent.begin + +(section + "}" @indent.end) + +"}" @indent.branch diff --git a/runtime/queries/hyprlang/injections.scm b/runtime/queries/hyprlang/injections.scm new file mode 100644 index 000000000..c7929e24d --- /dev/null +++ b/runtime/queries/hyprlang/injections.scm @@ -0,0 +1,31 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +(exec + (string) @injection.content + (#set! injection.language "bash")) + +((keyword + (name) @_bind + (params + . + (_) + . + (_) + . + (_)? + . + (string) @_exec + . + (string) @injection.content)) + (#lua-match? @_bind "^bind") + (#lua-match? @_exec "^%s*exec%s*$") + (#set! injection.language "bash")) + +((assignment + (name) @_name + (string) @injection.content) + (#any-of? @_name + "lock_cmd" "unlock_cmd" "before_sleep_cmd" "after_sleep_cmd" "on-timeout" "on-resume" + "reload_cmd") + (#set! injection.language "bash")) diff --git a/runtime/queries/idl/highlights.scm b/runtime/queries/idl/highlights.scm new file mode 100644 index 000000000..de1937203 --- /dev/null +++ b/runtime/queries/idl/highlights.scm @@ -0,0 +1,379 @@ +; https://neovim.io/doc/user/treesitter.html#treesitter-highlight-groups +(comment) @comment @spell + +[ + "enum" + "struct" + "union" + "bitmask" + "bitset" + "@annotation" + "exception" + "typedef" + "home" + "typeid" + "typeprefix" + (interface_kind) + (value_kind) + "component" + "porttype" + "connector" + "eventtype" + "valuetype" +] @keyword.type + +(import_dcl + "import" @keyword.directive) + +[ + "module" + "attribute" + "factory" + "manages" +] @keyword + +[ + "const" + "readonly" + "abstract" + "custom" + "supports" + "provides" + "uses" + "port" + "mirrorport" + "emits" + "publishes" + "consumes" + "primarykey" + "finder" +] @keyword.modifier + +[ + "switch" + "case" + "default" +] @keyword.conditional + +[ + "void" + (signed_short_int) + (signed_long_int) + (signed_longlong_int) + (unsigned_tiny_int) + (boolean_type) + (fixed_pt_const_type) + (octet_type) + (signed_tiny_int) + (unsigned_short_int) + (unsigned_long_int) + (unsigned_longlong_int) + (floating_pt_type) + (char_type) + (string_type) + (any_type) + (fixed_pt_type) + (sequence_type) + (map_type) + (object_type) + (value_base_type) + (wide_string_type) + (wide_char_type) +] @type.builtin + +(escape_sequence) @string.escape + +(scoped_name) @type + +(boolean_literal) @boolean + +(integer_literal) @number + +[ + (floating_pt_literal) + (fixed_pt_literal) +] @number.float + +(char_literal) @character + +(wide_character_literal) @character + +(string_literal) @string + +(wide_string_literal) @string + +[ + "(" + ")" + "[" + "]" + "<" + ">" + "{" + "}" +] @punctuation.bracket + +[ + "-" + "*" + "+" + "=" + "<<" + ">>" + "%" + "~" + "|" + "^" + "&" +] @operator + +[ + "::" + ";" + ":" + "," +] @punctuation.delimiter + +(readonly_attr_declarator + (simple_declarator) @variable.member) + +(attr_declarator + (simple_declarator) @variable.member) + +(annotation_appl + "@" @attribute) + +(annotation_appl_custom_body + (scoped_name) @attribute) + +(op_dcl + (identifier) @function.method) + +(type_declarator + (simple_type_spec) @type) + +(type_declarator + (any_declarators) @variable.member) + +(param_dcl + (simple_declarator) @variable.parameter) + +(raises_expr + "raises" @keyword.exception + (scoped_name + (identifier) @type)) + +(param_dcl + (param_attribute) @keyword.modifier) + +(preproc_call + directive: (preproc_directive) @keyword.directive + argument: (_)? @constant) + +(module_dcl + (identifier) @module) + +(struct_def + (identifier) @type + parent: (scoped_name)? @type) + +(enum_dcl + (enumerator + (identifier) @constant)) + +(annotation_dcl + (identifier) @type) + +(struct_forward_dcl + (identifier) @type) + +(bitmask_dcl + (identifier) @type) + +(bitset_dcl + (identifier) @type + (scoped_name)* @type) + +(enum_dcl + (identifier) @type) + +(union_forward_dcl + (identifier) @type) + +(interface_forward_dcl + (identifier) @type) + +(interface_header + (identifier) @type) + +(interface_inheritance_spec + (interface_name) @type) + +(union_def + (identifier) @type + (switch_type_spec) @type) + +(except_dcl + (identifier) @type) + +(annotation_member_type) @type + +(bitfield + (bitfield_spec + "bitfield" @keyword.modifier + (positive_int_const) @number + (destination_type)? @type) + (identifier)* @variable.member) + +(bit_value) @constant + +(annotation_member + (annotation_member_type) @type + (simple_declarator) @property) + +(const_dcl + (const_type) @type + (identifier) @constant) + +(case_label + (const_expr) @constant) + +(simple_type_spec + (scoped_name + (identifier) @type)) + +(annotation_appl_param + (identifier) @attribute) + +(home_header + (identifier) @type) + +(factory_dcl + (identifier) @type) + +(factory_param_dcl + "in" @keyword.modifier) + +(op_oneway_dcl + "oneway" @keyword.modifier + (identifier) @function.method) + +(in_param_dcl + "in" @keyword.modifier) + +(context_expr + "context" @keyword.modifier) + +(get_excep_expr + "getraises" @keyword.exception) + +(set_excep_expr + "setraises" @keyword.exception) + +(value_header + (identifier) @type) + +(value_abs_def + (identifier) @type) + +(value_forward_dcl + (identifier) @type) + +(value_box_def + (identifier) @type) + +(provides_dcl + (interface_type) @type + (identifier) @variable.member) + +(uses_dcl + (identifier) @variable.member) + +(component_forward_dcl + (identifier) @type) + +(component_header + (identifier) @type) + +(porttype_forward_dcl + (identifier) @type) + +(porttype_def + (identifier) @type) + +(port_dcl + (identifier) @variable.member) + +(connector_header + (identifier) @type) + +(emits_dcl + (identifier) @variable.member) + +(publishes_dcl + (identifier) @variable.member) + +(consumes_dcl + (identifier) @variable.member) + +(event_forward_dcl + (identifier) @type) + +(event_header + (identifier) @type) + +(event_abs_def + (identifier) @type) + +(template_module_dcl + (identifier) @type) + +(formal_parameter + (formal_parameter_type) @type + (identifier) @variable.member) + +(init_param_dcl + "in" @keyword.modifier + (simple_declarator) @variable.parameter) + +(finder_dcl + (identifier) @function.method) + +(member + identifier: (declarators) @variable.member) + +(factory_param_dcl + (simple_declarator) @variable.parameter) + +(element_spec + (declarator) @variable.member) + +(preproc_include + (keyword_include) @type + path: (_) @string) + +(system_lib_string + "<" @string + ">" @string) + +(extend_annotation_appl + "//@" @attribute + (annotation_appl_custom_body)) + +(extend_annotation_appl + "//@" @attribute.builtin + (annotation_appl_builtin_body)) + +[ + (autoid_kind) + (extensibility_kind) + (verbatim_language) + (placement_kind) + (service_platform) + (try_construct_fail_action) + (data_representation_mask) +] @constant + +(anno_name) @attribute.builtin + +(range_kind) @attribute.builtin diff --git a/runtime/queries/idl/indents.scm b/runtime/queries/idl/indents.scm new file mode 100644 index 000000000..2256fb701 --- /dev/null +++ b/runtime/queries/idl/indents.scm @@ -0,0 +1,10 @@ +";" @indent.end + +"}" @indent.branch + +(definition) @indent.begin + +[ + (preproc_define) + (preproc_include) +] @indent.ignore diff --git a/runtime/queries/idl/injections.scm b/runtime/queries/idl/injections.scm new file mode 100644 index 000000000..e4a286e42 --- /dev/null +++ b/runtime/queries/idl/injections.scm @@ -0,0 +1,8 @@ +((comment) @injection.content + (#lua-match? @injection.content "/[*\/][!*\/]<?[^a-zA-Z]") + (#set! injection.language "doxygen")) + +((comment) @injection.content + (#not-lua-match? @injection.content "/[*\/][!*\/]<?[^a-zA-Z]") + (#not-lua-match? @injection.content "//@[a-zA-Z]") + (#set! injection.language "comment")) diff --git a/runtime/queries/idris/folds.scm b/runtime/queries/idris/folds.scm new file mode 100644 index 000000000..2f4885165 --- /dev/null +++ b/runtime/queries/idris/folds.scm @@ -0,0 +1 @@ +(function) @fold diff --git a/runtime/queries/idris/highlights.scm b/runtime/queries/idris/highlights.scm new file mode 100644 index 000000000..d3dfa7a9f --- /dev/null +++ b/runtime/queries/idris/highlights.scm @@ -0,0 +1,228 @@ +; ------------------------------------------------------------------------------ +; Literals and comments +[ + (integer) + (quantity) +] @number + +(literal + (number)) @number.float + +(char) @character + +[ + (string) + (pat_string) + (triple_quote_string) +] @string + +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^|||")) + +(unit) @constant + +; more general captures are moved to the top +; before overwritten later by more specific captures +[ + (loname) + (caname) +] @variable + +; ------------------------------------------------------------------------------ +; Punctuation +[ + "(" + ")" + "{" + "@{" + "}" + "[" + "[<" + "]" +] @punctuation.bracket + +[ + (comma) + (colon) + (pat_op) + (tuple_operator) +] @punctuation.delimiter + +(pat_name + (loname) @variable.parameter) + +; ------------------------------------------------------------------------------ +; Types +(signature + (loname) @type) + +; ------------------------------------------------------------------------------ +; Keywords, operators, imports +[ + "if" + "then" + "else" + "case" + "of" +] @keyword.conditional + +[ + "import" + "module" + "namespace" + "parameters" +] @keyword.import + +[ + (operator) + (equal) + (wildcard) + "." + "|" + "=>" + "⇒" + "<=" + "⇐" + "->" + "→" + "<-" + "←" + "\\" + "`" +] @operator + +(qualified_loname + (caname) @module) + +(qualified_caname + (caname) @constructor) + +(qualified_operator + (caname) @module) + +(import + (caname) @module) + +(module + (caname) @module) + +[ + "let" + "in" +] @keyword + +[ + (where) + "rewrite" + "interface" + "implementation" + "using" + "record" + "as" + "do" + (forall) + (fixity) + (impossible) + (with) + (proof) +] @keyword.operator + +[ + (visibility) + (totality) +] @keyword.modifier + +"data" @keyword.type + +[ + "=" + "$=" + ":=" +] @operator + +(hole) @label + +[ + (pragma_language) + (pragma_default) + (pragma_builtin) + (pragma_name) + (pragma_ambiguity_depth) + (pragma_auto_implicit_depth) + (pragma_logging) + (pragma_prefix_record_projections) + (pragma_transform) + (pragma_unbound_implicits) + (pragma_auto_lazy) + (pragma_search_timeout) + (pragma_nf_metavar_threshold) + (pragma_cg) + (pragma_allow_overloads) + (pragma_deprecate) + (pragma_inline) + (pragma_noinline) + (pragma_tcinline) + (pragma_hide) + (pragma_unhide) + (pragma_unsafe) + (pragma_spec) + (pragma_foreign) + (pragma_foreign_impl) + (pragma_export) + (pragma_nomangle) + (pragma_hint) + (pragma_defaulthint) + (pragma_globalhint) + (pragma_extern) + (pragma_macro) + (pragma_start) + (pragma_rewrite) + (pragma_pair) + (pragma_integerLit) + (pragma_stringLit) + (pragma_charLit) + (pragma_doubleLit) + (pragma_TTImpLit) + (pragma_declsLit) + (pragma_nameLit) + (pragma_runElab) + (pragma_search) + (pragma_World) + (pragma_MkWorld) + (pragma_syntactic) +] @label + +; ------------------------------------------------------------------------------ +; Functions and variables +(exp_name + (loname) @function.call) + +(constructor + "constructor" @keyword.function + . + (caname) @constructor) + +(exp_record_access + field: (_) @variable.member) + +(signature + name: (loname) @function) + +(function + (lhs + (funvar + subject: [ + (loname) + (caname) + ] @function))) + +(data + name: (data_name) @type) + +(interface_head + name: (interface_name) @type) + +(implementation_head + (interface_name) @type) diff --git a/runtime/queries/idris/injections.scm b/runtime/queries/idris/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/idris/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/idris/locals.scm b/runtime/queries/idris/locals.scm new file mode 100644 index 000000000..c46f831f7 --- /dev/null +++ b/runtime/queries/idris/locals.scm @@ -0,0 +1,33 @@ +(signature + name: (loname)) @local.definition.var + +(signature + name: (caname)) @local.definition.type + +(function + (lhs + (funvar + subject: (loname)))) @local.definition.function + +(function + (lhs + (funvar + subject: (caname)))) @local.definition.function + +(type_var + (loname)) @local.definition.type + +(pat_name + (loname)) @local.definition.var + +(pat_name + (caname)) @local.definition.var + +(exp_name + (loname)) @local.reference + +(exp_name + (caname)) @local.reference + +(function + (rhs) @local.scope) diff --git a/runtime/queries/ini/folds.scm b/runtime/queries/ini/folds.scm new file mode 100644 index 000000000..911798f5a --- /dev/null +++ b/runtime/queries/ini/folds.scm @@ -0,0 +1 @@ +(section) @fold diff --git a/runtime/queries/ini/highlights.scm b/runtime/queries/ini/highlights.scm new file mode 100644 index 000000000..cbf958e84 --- /dev/null +++ b/runtime/queries/ini/highlights.scm @@ -0,0 +1,16 @@ +(section_name + (text) @markup.heading) + +(comment) @comment @spell + +[ + "[" + "]" +] @punctuation.bracket + +"=" @operator + +(setting + (setting_name) @property) + +(setting_value) @string diff --git a/runtime/queries/ini/injections.scm b/runtime/queries/ini/injections.scm new file mode 100644 index 000000000..8bfeee22d --- /dev/null +++ b/runtime/queries/ini/injections.scm @@ -0,0 +1,3 @@ +((comment + (text) @injection.content) + (#set! injection.language "comment")) diff --git a/runtime/queries/inko/folds.scm b/runtime/queries/inko/folds.scm new file mode 100644 index 000000000..6ec1f5ba4 --- /dev/null +++ b/runtime/queries/inko/folds.scm @@ -0,0 +1,18 @@ +[ + (call) + (class) + (closure) + (define_case) + (define_constant) + (define_field) + (define_variable) + (external_function) + (for) + (if) + (import)+ + (loop) + (match) + (method) + (trait) + (while) +] @fold diff --git a/runtime/queries/inko/highlights.scm b/runtime/queries/inko/highlights.scm new file mode 100644 index 000000000..989bdb9e8 --- /dev/null +++ b/runtime/queries/inko/highlights.scm @@ -0,0 +1,203 @@ +; Brackets and operators +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "," + "->" + "." + ":" +] @punctuation.delimiter + +[ + "!=" + "%" + "%=" + "&" + "&=" + "*" + "**" + "**=" + "*=" + "+" + "+=" + "-" + "-=" + "/" + "/=" + "<" + "<<" + "<<=" + "<=" + "<=" + "==" + ">" + ">=" + ">=" + ">>" + ">>=" + ">>>" + ">>>=" + "^" + "^=" + "|" + "|=" +] @operator + +; Keywords +[ + "as" + "copy" + "for" + "impl" + "in" + "inline" + "let" + "move" + "mut" + "recover" + "ref" + "uni" +] @keyword + +"fn" @keyword.function + +"import" @keyword.import + +[ + "and" + "or" +] @keyword.operator + +[ + "trait" + "type" +] @keyword.type + +[ + "extern" + (modifier) + (visibility) +] @keyword.modifier + +[ + "loop" + "while" + (break) + (next) +] @keyword.repeat + +"return" @keyword.return + +[ + "throw" + "try" +] @keyword.exception + +[ + "case" + "else" + "if" + "match" +] @keyword.conditional + +; Identifiers/variable references +(identifier) @variable + +; Comments +(line_comment) @comment @spell + +; Literals +(self) @variable.builtin + +(nil) @constant.builtin + +[ + (true) + (false) +] @boolean + +(integer) @number + +(float) @number.float + +(string) @string + +(escape_sequence) @string.escape + +(interpolation + "${" @punctuation.special + "}" @punctuation.special) @none + +(constant) @constant + +; Patterns +(integer_pattern) @number + +(string_pattern) @string + +(constant_pattern) @constant + +(boolean_pattern) @boolean + +; Types +(generic_type + name: _ @type) + +(type) @type + +; Imports +(extern_import + path: _ @string) + +(import + (path + (identifier) @module)) + +; Classes +(class + name: _ @type) + +(define_field + name: _ @variable.member) + +; Traits +(trait + name: _ @type) + +; Implementations +(implement_trait + class: _ @type) + +(reopen_class + name: _ @type) + +(bound + name: _ @type) + +; Methods +(method + name: _ @function) + +(external_function + name: _ @function) + +(argument + name: _ @variable.parameter) + +(named_argument + name: _ @variable.parameter) + +(call + name: [ + (name) + (constant) + ] @function) + +(field) @variable.member diff --git a/runtime/queries/inko/indents.scm b/runtime/queries/inko/indents.scm new file mode 100644 index 000000000..d2d9a5724 --- /dev/null +++ b/runtime/queries/inko/indents.scm @@ -0,0 +1,41 @@ +[ + (arguments) + (array) + (assign_field) + (assign_local) + (assign_receiver_field) + (binary) + (block) + (bounds) + (call) + (cast) + (class) + (class_pattern) + (compound_assign_field) + (compound_assign_local) + (compound_assign_receiver_field) + (define_constant) + (define_variable) + (grouped_expression) + (implement_trait) + (match) + (or_pattern) + (reopen_class) + (replace_field) + (replace_local) + (symbols) + (trait) + (tuple) + (tuple_pattern) + (type_arguments) +] @indent.begin + +[ + ")" + "]" + "}" +] @indent.end @indent.branch + +(line_comment) @indent.auto + +(string) @indent.auto diff --git a/runtime/queries/inko/injections.scm b/runtime/queries/inko/injections.scm new file mode 100644 index 000000000..36849c873 --- /dev/null +++ b/runtime/queries/inko/injections.scm @@ -0,0 +1,2 @@ +((line_comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/inko/locals.scm b/runtime/queries/inko/locals.scm new file mode 100644 index 000000000..09450f525 --- /dev/null +++ b/runtime/queries/inko/locals.scm @@ -0,0 +1,57 @@ +[ + (method) + (block) +] @local.scope + +(method + name: _ @local.definition.method) + +(external_function + name: _ @local.definition.function) + +(argument + name: _ @local.definition.parameter) + +(define_variable + name: _ @local.definition.var) + +(define_constant + name: _ @local.definition.constant) + +(define_field + name: _ @local.definition.field) + +(named_argument + name: _ @local.definition.parameter) + +(class + modifier: (modifier + "enum") + name: _ @local.definition.enum) + +(class + modifier: (modifier + "enum") + body: (class_body + (define_case + name: _ @local.definition.field))) + +(class + name: _ @local.definition.type) + +(trait + name: _ @local.definition.type) + +(import + (symbols + [ + (identifier) + (constant) + (self) + ] @local.definition.import)) + +(identifier) @local.reference + +(field) @local.reference + +(constant) @local.reference diff --git a/runtime/queries/ipkg/folds.scm b/runtime/queries/ipkg/folds.scm new file mode 100644 index 000000000..271654f9a --- /dev/null +++ b/runtime/queries/ipkg/folds.scm @@ -0,0 +1,13 @@ +[ + (source_file) + (dependency_list) + (module_list) + (dependency_declaration) + (module_declaration) + (module_declaration) + (package_declaration) + (main_declaration) + (executable_declaration) + (version_declaration) + (langversion_declaration) +] @fold diff --git a/runtime/queries/ipkg/highlights.scm b/runtime/queries/ipkg/highlights.scm new file mode 100644 index 000000000..13c102018 --- /dev/null +++ b/runtime/queries/ipkg/highlights.scm @@ -0,0 +1,56 @@ +; Keywords +"package" @keyword.import + +[ + "authors" + "maintainers" + "license" + "brief" + "readme" + "homepage" + "sourceloc" + "bugtracker" + "opts" + "sourcedir" + "builddir" + "outputdir" + "prebuild" + "postbuild" + "preinstall" + "postinstall" + "preclean" + "postclean" + "version" + "langversion" + "modules" + "main" + "executable" + "depends" +] @keyword + +[ + "=" + (version_range_op) +] @operator + +"," @punctuation.delimiter + +; Field values +(string_value) @string + +(boolean_value) @boolean + +; Version numbers and ranges +(version_number) @string.special + +[ + (dependency_item) + (package_name) + (module_name) +] @module + +; Comments +[ + (line_comment) + (block_comment) +] @comment @spell diff --git a/runtime/queries/ipkg/indents.scm b/runtime/queries/ipkg/indents.scm new file mode 100644 index 000000000..a596e9ebe --- /dev/null +++ b/runtime/queries/ipkg/indents.scm @@ -0,0 +1,33 @@ +; Indentation rules for Idris .ipkg files +[ + (package_declaration) + (field_declaration) + (main_declaration) + (executable_declaration) + (version_declaration) + (langversion_declaration) +] @indent.begin + +(dependency_declaration + "=" @indent.begin + (dependency_list + "," @indent.begin)) + +(module_declaration + "=" @indent.begin + (module_list + "," @indent.begin)) + +(field_declaration + "=" @indent.begin) + +"=" @indent.branch + +(string_value) @indent.begin + +[ + (line_comment) + (block_comment) +] @indent.ignore + +(ERROR) @indent.auto diff --git a/runtime/queries/ipkg/injections.scm b/runtime/queries/ipkg/injections.scm new file mode 100644 index 000000000..3cd6aac8e --- /dev/null +++ b/runtime/queries/ipkg/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/ipkg/locals.scm b/runtime/queries/ipkg/locals.scm new file mode 100644 index 000000000..c1970fcdf --- /dev/null +++ b/runtime/queries/ipkg/locals.scm @@ -0,0 +1,24 @@ +; Scopes +(source_file) @local.scope + +; Definitions +(package_declaration + (package_name) @local.definition.import) + +(module_declaration + (module_list + (module_name) @local.definition.namespace)) + +(main_declaration + (module_name) @local.definition.import) + +(executable_declaration + (package_name) @local.definition.import) + +; References +(dependency_declaration + (dependency_list + (dependency_item + (package_name) @local.reference))) + +(module_name) @local.reference diff --git a/runtime/queries/ispc/folds.scm b/runtime/queries/ispc/folds.scm new file mode 100644 index 000000000..45d0ba131 --- /dev/null +++ b/runtime/queries/ispc/folds.scm @@ -0,0 +1,8 @@ +; inherits: c + +[ + (foreach_statement) + (foreach_instance_statement) + (unmasked_statement) + (template_declaration) +] @fold diff --git a/runtime/queries/ispc/highlights.scm b/runtime/queries/ispc/highlights.scm new file mode 100644 index 000000000..fd9c7262e --- /dev/null +++ b/runtime/queries/ispc/highlights.scm @@ -0,0 +1,110 @@ +; inherits: c + +[ + "soa" + "task" + "launch" + "unmasked" + "template" + "typename" + (sync_expression) +] @keyword + +[ + "in" + "new" + "delete" +] @keyword.operator + +[ + "cdo" + "cfor" + "cwhile" + "foreach" + "foreach_tiled" + "foreach_active" + "foreach_unique" +] @keyword.repeat + +"cif" @keyword.conditional + +[ + "varying" + "uniform" +] @keyword.modifier + +"__regcall" @attribute + +(overload_declarator + name: _ @function) + +(foreach_statement + range_operator: _ @operator) + +(short_vector + [ + "<" + ">" + ] @punctuation.bracket) + +(soa_qualifier + [ + "<" + ">" + ] @punctuation.bracket) + +(template_argument_list + [ + "<" + ">" + ] @punctuation.bracket) + +(template_parameter_list + [ + "<" + ">" + ] @punctuation.bracket) + +(llvm_identifier) @function.builtin + +; built-in variables +((identifier) @variable.builtin + (#any-of? @variable.builtin + "programCount" "programIndex" "taskCount" "taskCount0" "taskCount1" "taskCount2" "taskIndex" + "taskIndex0" "taskIndex1" "taskIndex2" "threadCount" "threadIndex")) + +; preprocessor constants +((identifier) @constant.builtin + (#any-of? @constant.builtin + "ISPC" "ISPC_FP16_SUPPORTED" "ISPC_FP64_SUPPORTED" "ISPC_LLVM_INTRINSICS_ENABLED" + "ISPC_MAJOR_VERSION" "ISPC_MINOR_VERSION" "ISPC_POINTER_SIZE" "ISPC_TARGET_AVX" + "ISPC_TARGET_AVX2" "ISPC_TARGET_AVX512KNL" "ISPC_TARGET_AVX512SKX" "ISPC_TARGET_AVX512SPR" + "ISPC_TARGET_NEON" "ISPC_TARGET_SSE2" "ISPC_TARGET_SSE4" "ISPC_UINT_IS_DEFINED" "PI" + "TARGET_ELEMENT_WIDTH" "TARGET_WIDTH")) + +; standard library built-in +((type_identifier) @type.builtin + (#lua-match? @type.builtin "^RNGState")) + +(call_expression + function: (identifier) @function.builtin + (#any-of? @function.builtin + "abs" "acos" "all" "alloca" "and" "any" "aos_to_soa2" "aos_to_soa3" "aos_to_soa4" "asin" + "assert" "assume" "atan" "atan2" "atomic_add_global" "atomic_add_local" "atomic_and_global" + "atomic_and_local" "atomic_compare_exchange_global" "atomic_compare_exchange_local" + "atomic_max_global" "atomic_max_local" "atomic_min_global" "atomic_min_local" "atomic_or_global" + "atomic_or_local" "atomic_subtract_global" "atomic_subtract_local" "atomic_swap_global" + "atomic_swap_local" "atomic_xor_global" "atomic_xor_local" "avg_down" "avg_up" "broadcast" + "ceil" "clamp" "clock" "cos" "count_leading_zeros" "count_trailing_zeros" "doublebits" + "exclusive_scan_add" "exclusive_scan_and" "exclusive_scan_or" "exp" "extract" "fastmath" + "float16bits" "floatbits" "float_to_half" "float_to_half_fast" "float_to_srgb8" "floor" + "frandom" "frexp" "half_to_float" "half_to_float_fast" "insert" "intbits" "invoke_sycl" "isnan" + "ISPCAlloc" "ISPCLaunch" "ISPCSync" "lanemask" "ldexp" "log" "max" "memcpy" "memcpy64" "memmove" + "memmove64" "memory_barrier" "memset" "memset64" "min" "none" "num_cores" "or" + "packed_load_active" "packed_store_active" "packed_store_active2" "packmask" "popcnt" "pow" + "prefetch_l1" "prefetch_l2" "prefetch_l3" "prefetch_nt" "prefetchw_l1" "prefetchw_l2" + "prefetchw_l3" "print" "random" "rcp" "rcp_fast" "rdrand" "reduce_add" "reduce_equal" + "reduce_max" "reduce_min" "rotate" "round" "rsqrt" "rsqrt_fast" "saturating_add" + "saturating_div" "saturating_mul" "saturating_sub" "seed_rng" "select" "shift" "shuffle" + "signbits" "sign_extend" "sin" "sincos" "soa_to_aos2" "soa_to_aos3" "soa_to_aos4" "sqrt" + "streaming_load" "streaming_load_uniform" "streaming_store" "tan" "trunc")) diff --git a/runtime/queries/ispc/indents.scm b/runtime/queries/ispc/indents.scm new file mode 100644 index 000000000..f8c04e3a9 --- /dev/null +++ b/runtime/queries/ispc/indents.scm @@ -0,0 +1,9 @@ +; inherits: c + +((foreach_statement + body: (_) @_body) @indent.begin + (#not-kind-eq? @_body "compound_statement")) + +((foreach_instance_statement + body: (_) @_body) @indent.begin + (#not-kind-eq? @_body "compound_statement")) diff --git a/runtime/queries/ispc/injections.scm b/runtime/queries/ispc/injections.scm new file mode 100644 index 000000000..a5a5208ca --- /dev/null +++ b/runtime/queries/ispc/injections.scm @@ -0,0 +1 @@ +; inherits: c diff --git a/runtime/queries/ispc/locals.scm b/runtime/queries/ispc/locals.scm new file mode 100644 index 000000000..985b3c9e0 --- /dev/null +++ b/runtime/queries/ispc/locals.scm @@ -0,0 +1,18 @@ +; inherits: c + +(reference_declarator + (identifier) @local.definition.var) + +(type_parameter_declaration + (type_identifier) @local.definition.type) + +(template_declaration) @local.scope + +(template_function + name: (identifier) @local.definition.function) @local.scope + +[ + (foreach_statement) + (foreach_instance_statement) + (unmasked_statement) +] @local.scope diff --git a/runtime/queries/janet_simple/folds.scm b/runtime/queries/janet_simple/folds.scm new file mode 100644 index 000000000..e316af4d5 --- /dev/null +++ b/runtime/queries/janet_simple/folds.scm @@ -0,0 +1,2 @@ +(source + (par_tup_lit) @fold) diff --git a/runtime/queries/janet_simple/highlights.scm b/runtime/queries/janet_simple/highlights.scm new file mode 100644 index 000000000..552f865c6 --- /dev/null +++ b/runtime/queries/janet_simple/highlights.scm @@ -0,0 +1,178 @@ +; >> Literals +(kwd_lit) @string.special.symbol + +(str_lit) @string + +(long_str_lit) @string + +(buf_lit) @string + +(long_buf_lit) @string + +(num_lit) @number + +(bool_lit) @boolean + +(nil_lit) @constant.builtin + +(comment) @comment @spell + +[ + "{" + "@{" + "}" + "[" + "@[" + "]" + "(" + "@(" + ")" +] @punctuation.bracket + +; >> Symbols +; General symbol highlighting +(sym_lit) @variable + +; General function calls +(par_tup_lit + . + (sym_lit) @function.call) + +(short_fn_lit + . + (sym_lit) @function.call) + +; Quoted symbols +(quote_lit + (sym_lit) @string.special.symbol) + +(qq_lit + (sym_lit) @string.special.symbol) + +; Dynamic variables +((sym_lit) @variable.builtin + (#lua-match? @variable.builtin "^[*].+[*]$")) + +; Comment +((sym_lit) @comment + (#any-of? @comment "comment")) + +; Special forms and builtin macros +; +; # special forms were manually added at the beginning +; +; # for macros +; (each name (all-bindings) +; (when-let [info (dyn (symbol name))] +; (when (info :macro) +; (print name)))) +((sym_lit) @function.macro + (#any-of? @function.macro + ; special forms + "break" "def" "do" "fn" "if" "quasiquote" "quote" "set" "splice" "unquote" "upscope" "var" + "while" + ; macros + "%=" "*=" "++" "+=" "--" "-=" "->" "->>" "-?>" "-?>>" "/=" "and" "as->" "as-macro" "as?->" + "assert" "case" "catseq" "chr" "comment" "compif" "comptime" "compwhen" "cond" "coro" "def-" + "default" "defdyn" "defer" "defmacro" "defmacro-" "defn" "defn-" "delay" "doc" "each" "eachk" + "eachp" "edefer" "ev/do-thread" "ev/gather" "ev/spawn" "ev/spawn-thread" "ev/with-deadline" + "ev/with-lock" "ev/with-rlock" "ev/with-wlock" "ffi/defbind" "ffi/defbind-alias" "fiber-fn" + "for" "forever" "forv" "generate" "if-let" "if-not" "if-with" "import" "juxt" "label" "let" + "loop" "match" "or" "prompt" "protect" "repeat" "seq" "short-fn" "tabseq" "toggle" "tracev" + "try" "unless" "use" "var-" "varfn" "when" "when-let" "when-with" "with" "with-dyns" "with-env" + "with-syms" "with-vars" + ; obsolete builtin macros + "eachy")) + +; All builtin functions +; +; (each name (all-bindings) +; (when-let [info (dyn (symbol name))] +; (when (and (nil? (info :macro)) +; (or (function? (info :value)) +; (cfunction? (info :value)))) +; (print name)))) +((sym_lit) @function.builtin + (#any-of? @function.builtin + "%" "*" "+" "-" "/" "<" "<=" "=" ">" ">=" + ; debugging -- start janet with -d and use (debug) to see these + ".break" ".breakall" ".bytecode" ".clear" ".clearall" ".disasm" ".fiber" ".fn" ".frame" + ".locals" ".next" ".nextc" ".ppasm" ".signal" ".slot" ".slots" ".source" ".stack" ".step" + ; back to regularly scheduled program + "abstract?" "accumulate" "accumulate2" "all" "all-bindings" "all-dynamics" "any?" "apply" + "array" "array/clear" "array/concat" "array/ensure" "array/fill" "array/insert" "array/new" + "array/new-filled" "array/peek" "array/pop" "array/push" "array/remove" "array/slice" + "array/trim" "array/weak" "array?" "asm" "bad-compile" "bad-parse" "band" "blshift" "bnot" + "boolean?" "bor" "brshift" "brushift" "buffer" "buffer/bit" "buffer/bit-clear" "buffer/bit-set" + "buffer/bit-toggle" "buffer/blit" "buffer/clear" "buffer/fill" "buffer/format" + "buffer/format-at" "buffer/from-bytes" "buffer/new" "buffer/new-filled" "buffer/popn" + "buffer/push" "buffer/push-at" "buffer/push-byte" "buffer/push-float32" "buffer/push-float64" + "buffer/push-string" "buffer/push-uint16" "buffer/push-uint32" "buffer/push-uint64" + "buffer/push-word" "buffer/slice" "buffer/trim" "buffer?" "bundle/add" "bundle/add-directory" + "bundle/add-file" "bundle/install" "bundle/installed?" "bundle/list" "bundle/manifest" + "bundle/prune" "bundle/reinstall" "bundle/topolist" "bundle/uninstall" "bundle/update-all" + "bxor" "bytes?" "cancel" "cfunction?" "cli-main" "cmp" "comp" "compare" "compare<" "compare<=" + "compare=" "compare>" "compare>=" "compile" "complement" "count" "curenv" "debug" + "debug/arg-stack" "debug/break" "debug/fbreak" "debug/lineage" "debug/stack" "debug/stacktrace" + "debug/step" "debug/unbreak" "debug/unfbreak" "debugger" "debugger-on-status" "dec" "deep-not=" + "deep=" "defglobal" "describe" "dictionary?" "disasm" "distinct" "div" "doc*" "doc-format" + "doc-of" "dofile" "drop" "drop-until" "drop-while" "dyn" "eflush" "empty?" "env-lookup" "eprin" + "eprinf" "eprint" "eprintf" "error" "errorf" "ev/acquire-lock" "ev/acquire-rlock" + "ev/acquire-wlock" "ev/all-tasks" "ev/call" "ev/cancel" "ev/capacity" "ev/chan" "ev/chan-close" + "ev/chunk" "ev/close" "ev/count" "ev/deadline" "ev/full" "ev/give" "ev/give-supervisor" "ev/go" + "ev/lock" "ev/read" "ev/release-lock" "ev/release-rlock" "ev/release-wlock" "ev/rselect" + "ev/rwlock" "ev/select" "ev/sleep" "ev/take" "ev/thread" "ev/thread-chan" "ev/write" "eval" + "eval-string" "even?" "every?" "extreme" "false?" "ffi/align" "ffi/call" + "ffi/calling-conventions" "ffi/close" "ffi/context" "ffi/free" "ffi/jitfn" "ffi/lookup" + "ffi/malloc" "ffi/native" "ffi/pointer-buffer" "ffi/pointer-cfunction" "ffi/read" + "ffi/signature" "ffi/size" "ffi/struct" "ffi/trampoline" "ffi/write" "fiber/can-resume?" + "fiber/current" "fiber/getenv" "fiber/last-value" "fiber/maxstack" "fiber/new" "fiber/root" + "fiber/setenv" "fiber/setmaxstack" "fiber/status" "fiber?" "file/close" "file/flush" + "file/lines" "file/open" "file/read" "file/seek" "file/tell" "file/temp" "file/write" "filter" + "find" "find-index" "first" "flatten" "flatten-into" "flush" "flycheck" "freeze" "frequencies" + "from-pairs" "function?" "gccollect" "gcinterval" "gcsetinterval" "gensym" "get" "get-in" + "getline" "getproto" "group-by" "has-key?" "has-value?" "hash" "idempotent?" "identity" + "import*" "in" "inc" "index-of" "indexed?" "int/s64" "int/to-bytes" "int/to-number" "int/u64" + "int?" "interleave" "interpose" "invert" "juxt*" "keep" "keep-syntax" "keep-syntax!" "keys" + "keyword" "keyword/slice" "keyword?" "kvs" "last" "length" "lengthable?" "load-image" "macex" + "macex1" "maclintf" "make-env" "make-image" "map" "mapcat" "marshal" "math/abs" "math/acos" + "math/acosh" "math/asin" "math/asinh" "math/atan" "math/atan2" "math/atanh" "math/cbrt" + "math/ceil" "math/cos" "math/cosh" "math/erf" "math/erfc" "math/exp" "math/exp2" "math/expm1" + "math/floor" "math/frexp" "math/gamma" "math/gcd" "math/hypot" "math/lcm" "math/ldexp" + "math/log" "math/log-gamma" "math/log10" "math/log1p" "math/log2" "math/next" "math/pow" + "math/random" "math/rng" "math/rng-buffer" "math/rng-int" "math/rng-uniform" "math/round" + "math/seedrandom" "math/sin" "math/sinh" "math/sqrt" "math/tan" "math/tanh" "math/trunc" "max" + "max-of" "mean" "memcmp" "merge" "merge-into" "merge-module" "min" "min-of" "mod" + "module/add-paths" "module/expand-path" "module/find" "module/value" "nan?" "nat?" "native" + "neg?" "net/accept" "net/accept-loop" "net/address" "net/address-unpack" "net/chunk" "net/close" + "net/connect" "net/flush" "net/listen" "net/localname" "net/peername" "net/read" "net/recv-from" + "net/send-to" "net/server" "net/setsockopt" "net/shutdown" "net/write" "next" "nil?" "not" + "not=" "number?" "odd?" "one?" "os/arch" "os/cd" "os/chmod" "os/clock" "os/compiler" + "os/cpu-count" "os/cryptorand" "os/cwd" "os/date" "os/dir" "os/environ" "os/execute" "os/exit" + "os/getenv" "os/isatty" "os/link" "os/lstat" "os/mkdir" "os/mktime" "os/open" "os/perm-int" + "os/perm-string" "os/pipe" "os/posix-exec" "os/posix-fork" "os/proc-close" "os/proc-kill" + "os/proc-wait" "os/readlink" "os/realpath" "os/rename" "os/rm" "os/rmdir" "os/setenv" + "os/setlocale" "os/shell" "os/sigaction" "os/sleep" "os/spawn" "os/stat" "os/strftime" + "os/symlink" "os/time" "os/touch" "os/umask" "os/which" "pairs" "parse" "parse-all" + "parser/byte" "parser/clone" "parser/consume" "parser/eof" "parser/error" "parser/flush" + "parser/has-more" "parser/insert" "parser/new" "parser/produce" "parser/state" "parser/status" + "parser/where" "partial" "partition" "partition-by" "peg/compile" "peg/find" "peg/find-all" + "peg/match" "peg/replace" "peg/replace-all" "pos?" "postwalk" "pp" "prewalk" "prin" "prinf" + "print" "printf" "product" "propagate" "put" "put-in" "quit" "range" "reduce" "reduce2" "repl" + "require" "resume" "return" "reverse" "reverse!" "run-context" "sandbox" "scan-number" "setdyn" + "signal" "slice" "slurp" "some" "sort" "sort-by" "sorted" "sorted-by" "spit" "string" + "string/ascii-lower" "string/ascii-upper" "string/bytes" "string/check-set" "string/find" + "string/find-all" "string/format" "string/from-bytes" "string/has-prefix?" "string/has-suffix?" + "string/join" "string/repeat" "string/replace" "string/replace-all" "string/reverse" + "string/slice" "string/split" "string/trim" "string/triml" "string/trimr" "string?" "struct" + "struct/getproto" "struct/proto-flatten" "struct/to-table" "struct/with-proto" "struct?" "sum" + "symbol" "symbol/slice" "symbol?" "table" "table/clear" "table/clone" "table/getproto" + "table/new" "table/proto-flatten" "table/rawget" "table/setproto" "table/to-struct" "table/weak" + "table/weak-keys" "table/weak-values" "table?" "take" "take-until" "take-while" "thaw" "trace" + "true?" "truthy?" "tuple" "tuple/brackets" "tuple/setmap" "tuple/slice" "tuple/sourcemap" + "tuple/type" "tuple?" "type" "unmarshal" "untrace" "update" "update-in" "values" "varglobal" + "walk" "warn-compile" "xprin" "xprinf" "xprint" "xprintf" "yield" "zero?" "zipcoll" + ; XXX: obsolete + "tarray/buffer" "tarray/copy-bytes" "tarray/length" "tarray/new" "tarray/properties" + "tarray/slice" "tarray/swap-bytes" "thread/close" "thread/current" "thread/exit" "thread/new" + "thread/receive" "thread/send")) diff --git a/runtime/queries/janet_simple/injections.scm b/runtime/queries/janet_simple/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/janet_simple/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/janet_simple/locals.scm b/runtime/queries/janet_simple/locals.scm new file mode 100644 index 000000000..e47adce45 --- /dev/null +++ b/runtime/queries/janet_simple/locals.scm @@ -0,0 +1 @@ +; placeholder file to get incremental selection to work diff --git a/runtime/queries/java/folds.scm b/runtime/queries/java/folds.scm new file mode 100644 index 000000000..2cc143a78 --- /dev/null +++ b/runtime/queries/java/folds.scm @@ -0,0 +1,8 @@ +[ + (block) + (class_body) + (constructor_declaration) + (argument_list) + (annotation_argument_list) + (import_declaration)+ +] @fold diff --git a/runtime/queries/java/highlights.scm b/runtime/queries/java/highlights.scm new file mode 100644 index 000000000..df9ca14d4 --- /dev/null +++ b/runtime/queries/java/highlights.scm @@ -0,0 +1,330 @@ +; CREDITS @maxbrunsfeld (maxbrunsfeld@gmail.com) +; Variables +(identifier) @variable + +(underscore_pattern) @character.special + +; Methods +(method_declaration + name: (identifier) @function.method) + +(method_invocation + name: (identifier) @function.method.call) + +(super) @function.builtin + +; Parameters +(formal_parameter + name: (identifier) @variable.parameter) + +(spread_parameter + (variable_declarator + name: (identifier) @variable.parameter)) ; int... foo + +; Lambda parameter +(inferred_parameters + (identifier) @variable.parameter) ; (x,y) -> ... + +(lambda_expression + parameters: (identifier) @variable.parameter) ; x -> ... + +; Operators +[ + "+" + ":" + "++" + "-" + "--" + "&" + "&&" + "|" + "||" + "!" + "!=" + "==" + "*" + "/" + "%" + "<" + "<=" + ">" + ">=" + "=" + "-=" + "+=" + "*=" + "/=" + "%=" + "->" + "^" + "^=" + "&=" + "|=" + "~" + ">>" + ">>>" + "<<" + "::" +] @operator + +; Types +(interface_declaration + name: (identifier) @type) + +(annotation_type_declaration + name: (identifier) @type) + +(class_declaration + name: (identifier) @type) + +(record_declaration + name: (identifier) @type) + +(enum_declaration + name: (identifier) @type) + +(constructor_declaration + name: (identifier) @type) + +(compact_constructor_declaration + name: (identifier) @type) + +(type_identifier) @type + +((type_identifier) @type.builtin + (#eq? @type.builtin "var")) + +((method_invocation + object: (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +((method_reference + . + (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +((field_access + object: (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +(scoped_identifier + (identifier) @type + (#lua-match? @type "^[A-Z]")) + +; Fields +(field_declaration + declarator: (variable_declarator + name: (identifier) @variable.member)) + +(field_access + field: (identifier) @variable.member) + +[ + (boolean_type) + (integral_type) + (floating_point_type) + (void_type) +] @type.builtin + +; Variables +((identifier) @constant + (#lua-match? @constant "^[A-Z_][A-Z%d_]+$")) + +(this) @variable.builtin + +; Annotations +(annotation + "@" @attribute + name: (identifier) @attribute) + +(marker_annotation + "@" @attribute + name: (identifier) @attribute) + +; Literals +(string_literal) @string + +(escape_sequence) @string.escape + +(character_literal) @character + +[ + (hex_integer_literal) + (decimal_integer_literal) + (octal_integer_literal) + (binary_integer_literal) +] @number + +[ + (decimal_floating_point_literal) + (hex_floating_point_literal) +] @number.float + +[ + (true) + (false) +] @boolean + +(null_literal) @constant.builtin + +; Keywords +[ + "assert" + "default" + "extends" + "implements" + "instanceof" + "@interface" + "permits" + "to" + "with" +] @keyword + +[ + "record" + "class" + "enum" + "interface" +] @keyword.type + +(synchronized_statement + "synchronized" @keyword) + +[ + "abstract" + "final" + "native" + "non-sealed" + "open" + "private" + "protected" + "public" + "sealed" + "static" + "strictfp" + "transitive" +] @keyword.modifier + +(modifiers + "synchronized" @keyword.modifier) + +[ + "transient" + "volatile" +] @keyword.modifier + +[ + "return" + "yield" +] @keyword.return + +"new" @keyword.operator + +; Conditionals +[ + "if" + "else" + "switch" + "case" + "when" +] @keyword.conditional + +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +; Loops +[ + "for" + "while" + "do" + "continue" + "break" +] @keyword.repeat + +; Includes +[ + "exports" + "import" + "module" + "opens" + "package" + "provides" + "requires" + "uses" +] @keyword.import + +(import_declaration + (asterisk + "*" @character.special)) + +; Punctuation +[ + ";" + "." + "..." + "," +] @punctuation.delimiter + +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +(type_arguments + [ + "<" + ">" + ] @punctuation.bracket) + +(type_parameters + [ + "<" + ">" + ] @punctuation.bracket) + +(string_interpolation + [ + "\\{" + "}" + ] @punctuation.special) + +; Exceptions +[ + "throw" + "throws" + "finally" + "try" + "catch" +] @keyword.exception + +; Labels +(labeled_statement + (identifier) @label) + +; Comments +[ + (line_comment) + (block_comment) +] @comment @spell + +((block_comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +((line_comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) + +((line_comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) diff --git a/runtime/queries/java/indents.scm b/runtime/queries/java/indents.scm new file mode 100644 index 000000000..9e4d0a5e1 --- /dev/null +++ b/runtime/queries/java/indents.scm @@ -0,0 +1,40 @@ +; format-ignore +[ + ; ... refers to the portion that this indent query will have effects on + (class_body) ; { ... } of `class X` + (enum_body) ; { ... } of `enum X` + (interface_body) ; { ... } of `interface X` + (constructor_body) ; { `modifier` X() {...} } inside `class X` + (annotation_type_body) ; { ... } of `@interface X` + (block) ; { ... } that's not mentioned in this scope + (switch_block) ; { ... } in `switch X` + (array_initializer) ; [1, 2] + (argument_list) ; foo(...) + (formal_parameters) ; method foo(...) + (annotation_argument_list) ; @Annotation(...) + (element_value_array_initializer) ; { a, b } inside @Annotation() +] @indent.begin + +(expression_statement + (method_invocation) @indent.begin) + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @indent.branch + +(annotation_argument_list + ")" @indent.end) ; This should be a special cased as `()` here doesn't have ending `;` + +"}" @indent.end + +(line_comment) @indent.ignore + +[ + (ERROR) + (block_comment) +] @indent.auto diff --git a/runtime/queries/java/injections.scm b/runtime/queries/java/injections.scm new file mode 100644 index 000000000..7728a0956 --- /dev/null +++ b/runtime/queries/java/injections.scm @@ -0,0 +1,31 @@ +([ + (block_comment) + (line_comment) +] @injection.content + (#set! injection.language "comment")) + +((block_comment) @injection.content + (#lua-match? @injection.content "/[*][*][%s]") + (#set! injection.language "javadoc")) + +; markdown-style javadocs https://openjdk.org/jeps/467 +((line_comment) @injection.content + (#lua-match? @injection.content "^///%s") + (#set! injection.language "javadoc")) + +((method_invocation + name: (identifier) @_method + arguments: (argument_list + . + (string_literal + . + (_) @injection.content))) + (#any-of? @_method "format" "printf") + (#set! injection.language "printf")) + +((method_invocation + object: (string_literal + (string_fragment) @injection.content) + name: (identifier) @_method) + (#eq? @_method "formatted") + (#set! injection.language "printf")) diff --git a/runtime/queries/java/locals.scm b/runtime/queries/java/locals.scm new file mode 100644 index 000000000..53e950908 --- /dev/null +++ b/runtime/queries/java/locals.scm @@ -0,0 +1,100 @@ +; SCOPES +; declarations +(program) @local.scope + +(class_declaration + body: (_) @local.scope) + +(record_declaration + body: (_) @local.scope) + +(enum_declaration + body: (_) @local.scope) + +(lambda_expression) @local.scope + +(enhanced_for_statement) @local.scope + +; block +(block) @local.scope + +; if/else +(if_statement) @local.scope ; if+else + +(if_statement + consequence: (_) @local.scope) ; if body in case there are no braces + +(if_statement + alternative: (_) @local.scope) ; else body in case there are no braces + +; try/catch +(try_statement) @local.scope ; covers try+catch, individual try and catch are covered by (block) + +(catch_clause) @local.scope ; needed because `Exception` variable + +; loops +(for_statement) @local.scope ; whole for_statement because loop iterator variable + +(for_statement + ; "for" body in case there are no braces + body: (_) @local.scope) + +(do_statement + body: (_) @local.scope) + +(while_statement + body: (_) @local.scope) + +; Functions +(constructor_declaration) @local.scope + +(method_declaration) @local.scope + +; DEFINITIONS +(package_declaration + (identifier) @local.definition.namespace) + +(class_declaration + name: (identifier) @local.definition.type) + +(record_declaration + name: (identifier) @local.definition.type) + +(enum_declaration + name: (identifier) @local.definition.enum) + +(method_declaration + name: (identifier) @local.definition.method) + +(local_variable_declaration + declarator: (variable_declarator + name: (identifier) @local.definition.var)) + +(enhanced_for_statement + ; for (var item : items) { + name: (identifier) @local.definition.var) + +(formal_parameter + name: (identifier) @local.definition.parameter) + +(catch_formal_parameter + name: (identifier) @local.definition.parameter) + +(inferred_parameters + (identifier) @local.definition.parameter) ; (x,y) -> ... + +(lambda_expression + parameters: (identifier) @local.definition.parameter) ; x -> ... + +((scoped_identifier + (identifier) @local.definition.import) + (#has-ancestor? @local.definition.import import_declaration)) + +(field_declaration + declarator: (variable_declarator + name: (identifier) @local.definition.field)) + +; REFERENCES +(identifier) @local.reference + +(type_identifier) @local.reference diff --git a/runtime/queries/javadoc/highlights.scm b/runtime/queries/javadoc/highlights.scm new file mode 100644 index 000000000..832899cb5 --- /dev/null +++ b/runtime/queries/javadoc/highlights.scm @@ -0,0 +1,86 @@ +[ + (tag_name) + "include" + "exclude" +] @nospell @keyword + +(identifier) @nospell @variable + +(fragment) @nospell @variable.member + +(parameter + name: (identifier) @variable.parameter) + +(param_tag + parameter_name: (identifier) @variable.parameter) + +[ + (boolean_type) + (integral_type) + (floating_point_type) +] @nospell @type.builtin + +(module + (identifier) @module) + +(type + (identifier) @type) + +(type_parameter + (identifier) @type) + +(method + (identifier) @function) + +(member + (identifier) @variable.member) + +[ + (string_literal) + (indexword) +] @nospell @string + +[ + (bare_format_string) + (literal_format_string) +] @nospell @string.special + +(url) @nospell @markup.link.url + +(attribute + name: (identifier) @nospell @property) + +(system_property) @nospell @property + +(unsigned_integer) @number + +(code) @nospell @markup.raw + +[ + "=" + ":" +] @operator + +[ + "/" + "." + "," + "..." + "#" + "##" +] @punctuation.delimiter + +[ + "{" + "}" + "(" + ")" + "[" + "]" +] @punctuation.bracket + +(param_tag + [ + "<" + ">" + ] @punctuation.bracket) diff --git a/runtime/queries/javadoc/indents.scm b/runtime/queries/javadoc/indents.scm new file mode 100644 index 000000000..ef30f1e76 --- /dev/null +++ b/runtime/queries/javadoc/indents.scm @@ -0,0 +1 @@ +(document) @indent.auto diff --git a/runtime/queries/javadoc/injections.scm b/runtime/queries/javadoc/injections.scm new file mode 100644 index 000000000..7668f21bc --- /dev/null +++ b/runtime/queries/javadoc/injections.scm @@ -0,0 +1,30 @@ +; @value tags without double-quotes +((bare_format_string) @injection.content + (#set! injection.language "printf")) + +; @value tags with double quotes +((literal_format_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "printf")) + +; injected code snippets +((snippet_tag + (attributes + (attribute + name: (identifier) @_attribute_key + value: (attribute_value + [ + (identifier) @injection.language + (string_literal + (quoted_value) @injection.language) + ]))) + body: (description) @injection.content) + (#eq? @_attribute_key "lang")) + +; html content +((description) @injection.content + (#set! injection.language "html")) + +; markdown content +((markdown_description) @injection.content + (#set! injection.language "markdown_inline")) diff --git a/runtime/queries/javascript/folds.scm b/runtime/queries/javascript/folds.scm new file mode 100644 index 000000000..b6d9b28bf --- /dev/null +++ b/runtime/queries/javascript/folds.scm @@ -0,0 +1 @@ +; inherits: ecma,jsx diff --git a/runtime/queries/javascript/highlights.scm b/runtime/queries/javascript/highlights.scm new file mode 100644 index 000000000..257a731ad --- /dev/null +++ b/runtime/queries/javascript/highlights.scm @@ -0,0 +1,56 @@ +; inherits: ecma,jsx + +; Parameters +(formal_parameters + (identifier) @variable.parameter) + +(formal_parameters + (rest_pattern + (identifier) @variable.parameter)) + +; ({ a }) => null +(formal_parameters + (object_pattern + (shorthand_property_identifier_pattern) @variable.parameter)) + +; ({ a = b }) => null +(formal_parameters + (object_pattern + (object_assignment_pattern + (shorthand_property_identifier_pattern) @variable.parameter))) + +; ({ a: b }) => null +(formal_parameters + (object_pattern + (pair_pattern + value: (identifier) @variable.parameter))) + +; ([ a ]) => null +(formal_parameters + (array_pattern + (identifier) @variable.parameter)) + +; ({ a } = { a }) => null +(formal_parameters + (assignment_pattern + (object_pattern + (shorthand_property_identifier_pattern) @variable.parameter))) + +; ({ a = b } = { a }) => null +(formal_parameters + (assignment_pattern + (object_pattern + (object_assignment_pattern + (shorthand_property_identifier_pattern) @variable.parameter)))) + +; a => null +(arrow_function + parameter: (identifier) @variable.parameter) + +; optional parameters +(formal_parameters + (assignment_pattern + left: (identifier) @variable.parameter)) + +; punctuation +(optional_chain) @punctuation.delimiter diff --git a/runtime/queries/javascript/indents.scm b/runtime/queries/javascript/indents.scm new file mode 100644 index 000000000..b6d9b28bf --- /dev/null +++ b/runtime/queries/javascript/indents.scm @@ -0,0 +1 @@ +; inherits: ecma,jsx diff --git a/runtime/queries/javascript/injections.scm b/runtime/queries/javascript/injections.scm new file mode 100644 index 000000000..b6d9b28bf --- /dev/null +++ b/runtime/queries/javascript/injections.scm @@ -0,0 +1 @@ +; inherits: ecma,jsx diff --git a/runtime/queries/javascript/locals.scm b/runtime/queries/javascript/locals.scm new file mode 100644 index 000000000..6d6846fc7 --- /dev/null +++ b/runtime/queries/javascript/locals.scm @@ -0,0 +1,69 @@ +; inherits: ecma,jsx + +; Both properties are matched here. +; +; class Foo { +; this.#bar = "baz"; +; this.quuz = "qux"; +; } +(field_definition + property: [ + (property_identifier) + (private_property_identifier) + ] @local.definition.var) + +; this.foo = "bar" +(assignment_expression + left: (member_expression + object: (this) + property: (property_identifier) @local.definition.var)) + +(formal_parameters + (identifier) @local.definition.parameter) + +; function(arg = []) { +(formal_parameters + (assignment_pattern + left: (identifier) @local.definition.parameter)) + +; x => x +(arrow_function + parameter: (identifier) @local.definition.parameter) + +; ({ a }) => null +(formal_parameters + (object_pattern + (shorthand_property_identifier_pattern) @local.definition.parameter)) + +; ({ a: b }) => null +(formal_parameters + (object_pattern + (pair_pattern + value: (identifier) @local.definition.parameter))) + +; ([ a ]) => null +(formal_parameters + (array_pattern + (identifier) @local.definition.parameter)) + +(formal_parameters + (rest_pattern + (identifier) @local.definition.parameter)) + +; Both methods are matched here. +; +; class Foo { +; #bar(x) { x } +; baz(y) { y } +; } +(method_definition + [ + (property_identifier) + (private_property_identifier) + ] @local.definition.function + (#set! definition.var.scope parent)) + +; this.foo() +(member_expression + object: (this) + property: (property_identifier) @local.reference) diff --git a/runtime/queries/jinja/highlights.scm b/runtime/queries/jinja/highlights.scm new file mode 100644 index 000000000..cb6f9ff41 --- /dev/null +++ b/runtime/queries/jinja/highlights.scm @@ -0,0 +1,19 @@ +; inherits: jinja_inline + +[ + "{{" + "{{-" + "{{+" + "+}}" + "-}}" + "}}" + "{%" + "{%-" + "{%+" + "+%}" + "-%}" + "%}" +] @keyword.directive + +; TODO: only match raw +(raw_start) @keyword diff --git a/runtime/queries/jinja/injections.scm b/runtime/queries/jinja/injections.scm new file mode 100644 index 000000000..162db3aee --- /dev/null +++ b/runtime/queries/jinja/injections.scm @@ -0,0 +1,5 @@ +((inline) @injection.content + (#set! injection.language "jinja_inline")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/jinja_inline/highlights.scm b/runtime/queries/jinja_inline/highlights.scm new file mode 100644 index 000000000..69dba77b3 --- /dev/null +++ b/runtime/queries/jinja_inline/highlights.scm @@ -0,0 +1,157 @@ +"#" @keyword.directive + +(string_literal) @string + +(number_literal) @number + +(float_literal) @number.float + +(boolean_literal) @boolean + +(null_literal) @constant + +"defined" @constant + +(comment) @comment @spell + +[ + "," + "." + ":" +] @punctuation.delimiter + +[ + (attribute_ignore) + (attribute_context) + "recursive" +] @attribute.builtin + +[ + "(" + ")" + "[" + "]" + "<" + ">" +] @punctuation.bracket + +(binary_operator) @operator + +[ + "block" + "with" + "filter" + "macro" + "set" + "trans" + "pluralize" + "autoescape" +] @keyword + +[ + "endtrans" + "endblock" + "endwith" + "endfilter" + "endmacro" + "endcall" + "endset" + "endtrans" + "endautoescape" +] @keyword + +(do_statement + "do" @keyword) + +[ + "include" + "import" + "from" + "extends" + "as" +] @keyword.import + +(import_statement + (identifier) @variable) + +(import_as + (identifier) @variable) + +[ + "if" + "else" + "endif" + "elif" +] @keyword.conditional + +[ + "for" + "in" + "continue" + "break" + "endfor" +] @keyword.repeat + +"call" @function.call + +(function_call + (identifier) @function.call) + +(arg + (identifier) @variable.parameter) + +(arg + (expression + (binary_expression + (unary_expression + (primary_expression + (identifier) @variable.parameter))))) + +(expression + "." + (expression)+ @variable.member) + +(assignment_expression + "." + (identifier)+ @variable.member) + +(inline_trans + "_" @function.builtin) + +"debug" @function.builtin + +(raw_end) @keyword + +(raw_body) @markup.raw.block @nospell + +(builtin_test + [ + "boolean" + "even" + "in" + "mapping" + "sequence" + "callable" + "integer" + "ne" + "string" + "defined" + "filter" + "iterable" + "none" + "test" + "divisibleby" + "float" + "le" + "number" + "eq" + "ge" + "lower" + "odd" + "undefined" + "escaped" + "gt" + "lt" + "sameas" + "upper" + ] @keyword.operator) diff --git a/runtime/queries/jinja_inline/injections.scm b/runtime/queries/jinja_inline/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/jinja_inline/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/jq/highlights.scm b/runtime/queries/jq/highlights.scm new file mode 100644 index 000000000..5d6050f4c --- /dev/null +++ b/runtime/queries/jq/highlights.scm @@ -0,0 +1,158 @@ +; Variables +(variable) @variable + +((variable) @constant.builtin + (#eq? @constant.builtin "$ENV")) + +((variable) @constant.macro + (#eq? @constant.macro "$__loc__")) + +; Properties +(index + (identifier) @property) + +; Labels +(query + label: (variable) @label) + +(query + break_statement: (variable) @label) + +; Literals +(number) @number + +(string) @string + +[ + "true" + "false" +] @boolean + +"null" @type.builtin + +; Interpolation +[ + "\\(" + ")" +] @character.special + +; Format +(format) @attribute + +; Functions +(funcdef + (identifier) @function) + +(funcdefargs + (identifier) @variable.parameter) + +[ + "reduce" + "foreach" +] @function.builtin + +((funcname) @function.call + . + "(") + +; jq -n 'builtins | map(split("/")[0]) | unique | .[]' +((funcname) @function.builtin + (#any-of? @function.builtin + "IN" "INDEX" "JOIN" "abs" "acos" "acosh" "add" "all" "any" "arrays" "ascii_downcase" + "ascii_upcase" "asin" "asinh" "atan" "atan2" "atanh" "booleans" "bsearch" "builtins" "capture" + "cbrt" "ceil" "combinations" "contains" "copysign" "cos" "cosh" "debug" "del" "delpaths" "drem" + "empty" "endswith" "env" "erf" "erfc" "error" "exp" "exp10" "exp2" "explode" "expm1" "fabs" + "fdim" "finites" "first" "flatten" "floor" "fma" "fmax" "fmin" "fmod" "format" "frexp" + "from_entries" "fromdate" "fromdateiso8601" "fromjson" "fromstream" "gamma" "get_jq_origin" + "get_prog_origin" "get_search_list" "getpath" "gmtime" "group_by" "gsub" "halt" "halt_error" + "has" "hypot" "implode" "in" "index" "indices" "infinite" "input" "input_filename" + "input_line_number" "inputs" "inside" "isempty" "isfinite" "isinfinite" "isnan" "isnormal" + "iterables" "j0" "j1" "jn" "join" "keys" "keys_unsorted" "last" "ldexp" "length" "lgamma" + "lgamma_r" "limit" "localtime" "log" "log10" "log1p" "log2" "logb" "ltrimstr" "map" "map_values" + "match" "max" "max_by" "min" "min_by" "mktime" "modf" "modulemeta" "nan" "nearbyint" "nextafter" + "nexttoward" "normals" "not" "now" "nth" "nulls" "numbers" "objects" "path" "paths" "pick" "pow" + "pow10" "range" "recurse" "remainder" "repeat" "reverse" "rindex" "rint" "round" "rtrimstr" + "scalars" "scalb" "scalbln" "scan" "select" "setpath" "significand" "sin" "sinh" "sort" + "sort_by" "split" "splits" "sqrt" "startswith" "stderr" "strflocaltime" "strftime" "strings" + "strptime" "sub" "tan" "tanh" "test" "tgamma" "to_entries" "todate" "todateiso8601" "tojson" + "tonumber" "tostream" "tostring" "transpose" "trunc" "truncate_stream" "type" "unique" + "unique_by" "until" "utf8bytelength" "values" "walk" "while" "with_entries" "y0" "y1" "yn")) + +; Keywords +[ + "def" + "as" + "label" + "module" + "break" +] @keyword + +[ + "import" + "include" +] @keyword.import + +[ + "if" + "then" + "elif" + "else" + "end" +] @keyword.conditional + +[ + "try" + "catch" +] @keyword.exception + +[ + "or" + "and" +] @keyword.operator + +; Operators +[ + "." + "==" + "!=" + ">" + ">=" + "<=" + "<" + "=" + "+" + "-" + "*" + "/" + "%" + "+=" + "-=" + "*=" + "/=" + "%=" + "//=" + "|" + "?" + "//" + "?//" + (recurse) ; ".." +] @operator + +; Punctuation +[ + ";" + "," + ":" +] @punctuation.delimiter + +[ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket + +; Comments +(comment) @comment @spell diff --git a/runtime/queries/jq/injections.scm b/runtime/queries/jq/injections.scm new file mode 100644 index 000000000..f8a7a35b0 --- /dev/null +++ b/runtime/queries/jq/injections.scm @@ -0,0 +1,23 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; test(val) +(query + ((funcname) @_function + (#any-of? @_function "test" "match" "capture" "scan" "split" "splits" "sub" "gsub")) + (args + . + (query + (string) @injection.content + (#set! injection.language "regex")))) + +; test(regex; flags) +(query + ((funcname) @_function + (#any-of? @_function "test" "match" "capture" "scan" "split" "splits" "sub" "gsub")) + (args + . + (args + (query + (string) @injection.content + (#set! injection.language "regex"))))) diff --git a/runtime/queries/jq/locals.scm b/runtime/queries/jq/locals.scm new file mode 100644 index 000000000..0b8a0997d --- /dev/null +++ b/runtime/queries/jq/locals.scm @@ -0,0 +1,10 @@ +(funcdef + (identifier) @local.definition.function) + +(funcdefargs + (identifier) @local.definition.parameter) + +(funcname) @local.reference + +(index + (identifier) @local.reference) diff --git a/runtime/queries/jsdoc/highlights.scm b/runtime/queries/jsdoc/highlights.scm new file mode 100644 index 000000000..6df73318d --- /dev/null +++ b/runtime/queries/jsdoc/highlights.scm @@ -0,0 +1,42 @@ +(tag_name) @keyword @nospell + +(type) @type @nospell + +[ + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + ":" + "." + "#" + "~" +] @punctuation.delimiter + +(path_expression + "/" @punctuation.delimiter) + +(identifier) @variable @nospell + +(tag + (tag_name) @_name + (identifier) @function + (#any-of? @_name "@callback" "@function" "@func" "@method")) + +(tag + (tag_name) @_name + (identifier) @variable.parameter + (#any-of? @_name "@param" "@arg" "@argument")) + +(tag + (tag_name) @_name + (identifier) @property + (#any-of? @_name "@prop" "@property")) + +(tag + (tag_name) @_name + (identifier) @type + (#eq? @_name "@typedef")) diff --git a/runtime/queries/json/folds.scm b/runtime/queries/json/folds.scm new file mode 100644 index 000000000..4c2b9d32e --- /dev/null +++ b/runtime/queries/json/folds.scm @@ -0,0 +1,5 @@ +[ + (pair) + (object) + (array) +] @fold diff --git a/runtime/queries/json/highlights.scm b/runtime/queries/json/highlights.scm new file mode 100644 index 000000000..85915285a --- /dev/null +++ b/runtime/queries/json/highlights.scm @@ -0,0 +1,38 @@ +[ + (true) + (false) +] @boolean + +(null) @constant.builtin + +(number) @number + +(pair + key: (string) @property) + +(pair + value: (string) @string) + +(array + (string) @string) + +[ + "," + ":" +] @punctuation.delimiter + +[ + "[" + "]" + "{" + "}" +] @punctuation.bracket + +("\"" @conceal + (#set! conceal "")) + +(escape_sequence) @string.escape + +((escape_sequence) @conceal + (#eq? @conceal "\\\"") + (#set! conceal "\"")) diff --git a/runtime/queries/json/indents.scm b/runtime/queries/json/indents.scm new file mode 100644 index 000000000..8274ee3d5 --- /dev/null +++ b/runtime/queries/json/indents.scm @@ -0,0 +1,9 @@ +[ + (object) + (array) +] @indent.begin + +[ + "}" + "]" +] @indent.branch diff --git a/runtime/queries/json/locals.scm b/runtime/queries/json/locals.scm new file mode 100644 index 000000000..aaeee38ca --- /dev/null +++ b/runtime/queries/json/locals.scm @@ -0,0 +1,4 @@ +[ + (object) + (array) +] @local.scope diff --git a/runtime/queries/json5/highlights.scm b/runtime/queries/json5/highlights.scm new file mode 100644 index 000000000..4ffe311c4 --- /dev/null +++ b/runtime/queries/json5/highlights.scm @@ -0,0 +1,15 @@ +[ + (true) + (false) +] @boolean + +(null) @constant + +(string) @string + +(number) @number + +(comment) @comment @spell + +(member + name: (_) @keyword) diff --git a/runtime/queries/json5/injections.scm b/runtime/queries/json5/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/json5/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/jsonc/folds.scm b/runtime/queries/jsonc/folds.scm new file mode 100644 index 000000000..41269219e --- /dev/null +++ b/runtime/queries/jsonc/folds.scm @@ -0,0 +1 @@ +; inherits: json diff --git a/runtime/queries/jsonc/highlights.scm b/runtime/queries/jsonc/highlights.scm new file mode 100644 index 000000000..e50112155 --- /dev/null +++ b/runtime/queries/jsonc/highlights.scm @@ -0,0 +1,3 @@ +; inherits: json + +(comment) @comment @spell diff --git a/runtime/queries/jsonc/indents.scm b/runtime/queries/jsonc/indents.scm new file mode 100644 index 000000000..3b01ca999 --- /dev/null +++ b/runtime/queries/jsonc/indents.scm @@ -0,0 +1,3 @@ +; inherits: json + +(comment) @indent.ignore diff --git a/runtime/queries/jsonc/injections.scm b/runtime/queries/jsonc/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/jsonc/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/jsonc/locals.scm b/runtime/queries/jsonc/locals.scm new file mode 100644 index 000000000..41269219e --- /dev/null +++ b/runtime/queries/jsonc/locals.scm @@ -0,0 +1 @@ +; inherits: json diff --git a/runtime/queries/jsonnet/folds.scm b/runtime/queries/jsonnet/folds.scm new file mode 100644 index 000000000..91257a790 --- /dev/null +++ b/runtime/queries/jsonnet/folds.scm @@ -0,0 +1,10 @@ +[ + (field) + (object) + (array) + (parenthesis) + (bind) + ; (params) + ; (args) + ; (conditional) +] @fold diff --git a/runtime/queries/jsonnet/highlights.scm b/runtime/queries/jsonnet/highlights.scm new file mode 100644 index 000000000..1e67baa32 --- /dev/null +++ b/runtime/queries/jsonnet/highlights.scm @@ -0,0 +1,135 @@ +(id) @variable + +(comment) @comment @spell + +; Literals +(null) @constant.builtin + +(string) @string + +(number) @number + +[ + (true) + (false) +] @boolean + +; Keywords +"for" @keyword.repeat + +"in" @keyword.operator + +"function" @keyword.function + +[ + "if" + "then" + "else" +] @keyword.conditional + +[ + (local) + (tailstrict) + "function" +] @keyword + +[ + "assert" + "error" +] @keyword.exception + +[ + (dollar) + (self) + (super) +] @variable.builtin + +((id) @variable.builtin + (#eq? @variable.builtin "std")) + +; Operators +[ + (multiplicative) + (additive) + (bitshift) + (comparison) + (equality) + (bitand) + (bitxor) + (bitor) + (and) + (or) + (unaryop) +] @operator + +; Punctuation +[ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket + +[ + "." + "," + ";" + ":" +] @punctuation.delimiter + +[ + "::" + ":::" +] @punctuation.special + +(field + (fieldname) + "+" @punctuation.special) + +; Imports +[ + (import) + (importstr) +] @keyword.import + +; Fields +(fieldname + (id) @variable.member) + +(fieldname + (string + (string_content) @variable.member)) + +; Functions +(field + function: (fieldname + (id) @function)) + +(field + function: (fieldname + (string + (string_content) @function))) + +(param + identifier: (id) @variable.parameter) + +(bind + (id) @variable) + +(bind + function: (id) @function) + +; Function call +(functioncall + (fieldaccess + last: (id) @function.call)? + (fieldaccess_super + (id) @function.call)? + (id)? @function.call + "(" + (args + (named_argument + (id) @variable.parameter))? + ")") diff --git a/runtime/queries/jsonnet/injections.scm b/runtime/queries/jsonnet/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/jsonnet/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/jsonnet/locals.scm b/runtime/queries/jsonnet/locals.scm new file mode 100644 index 000000000..778077764 --- /dev/null +++ b/runtime/queries/jsonnet/locals.scm @@ -0,0 +1,27 @@ +(parenthesis) @local.scope + +(anonymous_function) @local.scope + +(object) @local.scope + +(field) @local.scope + +(local_bind) @local.scope + +(field + function: (fieldname + (id) @local.definition.function) + (#set! definition.function.scope "parent")) + +(bind + (id) @local.definition.var) + +(bind + function: (id) @local.definition.function) + +(param + (id) @local.definition.parameter) + +(id) @local.reference + +;(fieldname (id) (#is-not? local)) ; (#is-not?) not supported yet diff --git a/runtime/queries/jsx/folds.scm b/runtime/queries/jsx/folds.scm new file mode 100644 index 000000000..93c3d9c8c --- /dev/null +++ b/runtime/queries/jsx/folds.scm @@ -0,0 +1 @@ +(jsx_element) @fold diff --git a/runtime/queries/jsx/highlights.scm b/runtime/queries/jsx/highlights.scm new file mode 100644 index 000000000..0615d253a --- /dev/null +++ b/runtime/queries/jsx/highlights.scm @@ -0,0 +1,157 @@ +(jsx_element + open_tag: (jsx_opening_element + [ + "<" + ">" + ] @tag.delimiter)) + +(jsx_element + close_tag: (jsx_closing_element + [ + "</" + ">" + ] @tag.delimiter)) + +(jsx_self_closing_element + [ + "<" + "/>" + ] @tag.delimiter) + +(jsx_attribute + (property_identifier) @tag.attribute) + +(jsx_opening_element + name: (identifier) @tag.builtin) + +(jsx_closing_element + name: (identifier) @tag.builtin) + +(jsx_self_closing_element + name: (identifier) @tag.builtin) + +(jsx_opening_element + ((identifier) @tag + (#lua-match? @tag "^[A-Z]"))) + +; Handle the dot operator effectively - <My.Component> +(jsx_opening_element + (member_expression + (identifier) @tag.builtin + (property_identifier) @tag)) + +(jsx_closing_element + ((identifier) @tag + (#lua-match? @tag "^[A-Z]"))) + +; Handle the dot operator effectively - </My.Component> +(jsx_closing_element + (member_expression + (identifier) @tag.builtin + (property_identifier) @tag)) + +(jsx_self_closing_element + ((identifier) @tag + (#lua-match? @tag "^[A-Z]"))) + +; Handle the dot operator effectively - <My.Component /> +(jsx_self_closing_element + (member_expression + (identifier) @tag.builtin + (property_identifier) @tag)) + +(html_character_reference) @tag + +(jsx_text) @none @spell + +(html_character_reference) @character.special + +((jsx_element + (jsx_opening_element + name: (identifier) @_tag) + (jsx_text) @markup.heading) + (#eq? @_tag "title")) + +((jsx_element + (jsx_opening_element + name: (identifier) @_tag) + (jsx_text) @markup.heading.1) + (#eq? @_tag "h1")) + +((jsx_element + (jsx_opening_element + name: (identifier) @_tag) + (jsx_text) @markup.heading.2) + (#eq? @_tag "h2")) + +((jsx_element + (jsx_opening_element + name: (identifier) @_tag) + (jsx_text) @markup.heading.3) + (#eq? @_tag "h3")) + +((jsx_element + (jsx_opening_element + name: (identifier) @_tag) + (jsx_text) @markup.heading.4) + (#eq? @_tag "h4")) + +((jsx_element + (jsx_opening_element + name: (identifier) @_tag) + (jsx_text) @markup.heading.5) + (#eq? @_tag "h5")) + +((jsx_element + (jsx_opening_element + name: (identifier) @_tag) + (jsx_text) @markup.heading.6) + (#eq? @_tag "h6")) + +((jsx_element + (jsx_opening_element + name: (identifier) @_tag) + (jsx_text) @markup.strong) + (#any-of? @_tag "strong" "b")) + +((jsx_element + (jsx_opening_element + name: (identifier) @_tag) + (jsx_text) @markup.italic) + (#any-of? @_tag "em" "i")) + +((jsx_element + (jsx_opening_element + name: (identifier) @_tag) + (jsx_text) @markup.strikethrough) + (#any-of? @_tag "s" "del")) + +((jsx_element + (jsx_opening_element + name: (identifier) @_tag) + (jsx_text) @markup.underline) + (#eq? @_tag "u")) + +((jsx_element + (jsx_opening_element + name: (identifier) @_tag) + (jsx_text) @markup.raw) + (#any-of? @_tag "code" "kbd")) + +((jsx_element + (jsx_opening_element + name: (identifier) @_tag) + (jsx_text) @markup.link.label) + (#eq? @_tag "a")) + +((jsx_attribute + (property_identifier) @_attr + (string + (string_fragment) @string.special.url)) + (#any-of? @_attr "href" "src")) + +((jsx_element) @_jsx_element + (#set! @_jsx_element bo.commentstring "{/* %s */}")) + +((jsx_attribute) @_jsx_attribute + (#set! @_jsx_attribute bo.commentstring "// %s")) diff --git a/runtime/queries/jsx/indents.scm b/runtime/queries/jsx/indents.scm new file mode 100644 index 000000000..812bc255d --- /dev/null +++ b/runtime/queries/jsx/indents.scm @@ -0,0 +1,21 @@ +[ + (jsx_element) + (jsx_self_closing_element) + (jsx_expression) +] @indent.begin + +(jsx_closing_element + ">" @indent.end) + +(jsx_self_closing_element + "/>" @indent.end) + +[ + (jsx_closing_element) + ">" +] @indent.branch + +; <button +; /> +(jsx_self_closing_element + "/>" @indent.branch) diff --git a/runtime/queries/jsx/injections.scm b/runtime/queries/jsx/injections.scm new file mode 100644 index 000000000..269ee3fff --- /dev/null +++ b/runtime/queries/jsx/injections.scm @@ -0,0 +1,11 @@ +; Styled Jsx <style jsx> +(jsx_element + (jsx_opening_element + (identifier) @_name + (#eq? @_name "style") + (jsx_attribute) @_attr + (#eq? @_attr "jsx")) + (jsx_expression + ((template_string) @injection.content + (#set! injection.language "css")) + (#offset! @injection.content 0 1 0 -1))) diff --git a/runtime/queries/julia/folds.scm b/runtime/queries/julia/folds.scm new file mode 100644 index 000000000..2cbdc2815 --- /dev/null +++ b/runtime/queries/julia/folds.scm @@ -0,0 +1,14 @@ +[ + (module_definition) + (struct_definition) + (macro_definition) + (function_definition) + (if_statement) + (try_statement) + (for_statement) + (while_statement) + (let_statement) + (quote_statement) + (do_clause) + (compound_statement) +] @fold diff --git a/runtime/queries/julia/highlights.scm b/runtime/queries/julia/highlights.scm new file mode 100644 index 000000000..9a82c5d41 --- /dev/null +++ b/runtime/queries/julia/highlights.scm @@ -0,0 +1,372 @@ +; Identifiers +(identifier) @variable + +(field_expression + (identifier) @variable.member .) + +; Symbols +(quote_expression + ":" @string.special.symbol + [ + (identifier) + (operator) + ] @string.special.symbol) + +; Function calls +(call_expression + (identifier) @function.call) + +(call_expression + (field_expression + (identifier) @function.call .)) + +(broadcast_call_expression + (identifier) @function.call) + +(broadcast_call_expression + (field_expression + (identifier) @function.call .)) + +(binary_expression + (_) + (operator) @_pipe + (identifier) @function.call + (#any-of? @_pipe "|>" ".|>")) + +; Macros +(macro_identifier + "@" @function.macro + (identifier) @function.macro) + +(macro_definition + (signature + (call_expression + . + (identifier) @function.macro))) + +; Built-in functions +; filter(name -> Base.eval(Core, name) isa Core.Builtin, names(Core)) +((identifier) @function.builtin + (#any-of? @function.builtin + "applicable" "fieldtype" "getfield" "getglobal" "invoke" "isa" "isdefined" "modifyfield!" + "modifyglobal!" "nfields" "replacefield!" "replaceglobal!" "setfield!" "setfieldonce!" + "setglobal!" "setglobalonce!" "swapfield!" "swapglobal!" "throw" "tuple" "typeassert" "typeof")) + +; Type definitions +(type_head + (_) @type.definition) + +; Type annotations +(parametrized_type_expression + [ + (identifier) @type + (field_expression + (identifier) @type .) + ] + (curly_expression + (_) @type)) + +(typed_expression + (identifier) @type .) + +(unary_typed_expression + (identifier) @type .) + +(where_expression + [ + (curly_expression + (_) @type) + (_) @type + ] .) + +(unary_expression + (operator) @operator + (_) @type + (#any-of? @operator "<:" ">:")) + +(binary_expression + (_) @type + (operator) @operator + (_) @type + (#any-of? @operator "<:" ">:")) + +; Built-in types +; filter(name -> typeof(Base.eval(Core, name)) in [DataType, UnionAll], names(Core)) +((identifier) @type.builtin + (#any-of? @type.builtin + "AbstractArray" "AbstractChar" "AbstractFloat" "AbstractString" "Any" "ArgumentError" "Array" + "AssertionError" "Bool" "BoundsError" "Char" "ConcurrencyViolationError" "Cvoid" "DataType" + "DenseArray" "DivideError" "DomainError" "ErrorException" "Exception" "Expr" "Float16" "Float32" + "Float64" "Function" "GlobalRef" "IO" "InexactError" "InitError" "Int" "Int128" "Int16" "Int32" + "Int64" "Int8" "Integer" "InterruptException" "LineNumberNode" "LoadError" "Method" + "MethodError" "Module" "NTuple" "NamedTuple" "Nothing" "Number" "OutOfMemoryError" + "OverflowError" "Pair" "Ptr" "QuoteNode" "ReadOnlyMemoryError" "Real" "Ref" "SegmentationFault" + "Signed" "StackOverflowError" "String" "Symbol" "Task" "Tuple" "Type" "TypeError" "TypeVar" + "UInt" "UInt128" "UInt16" "UInt32" "UInt64" "UInt8" "UndefInitializer" "UndefKeywordError" + "UndefRefError" "UndefVarError" "Union" "UnionAll" "Unsigned" "VecElement" "WeakRef")) + +; Keywords +[ + "global" + "local" +] @keyword + +(compound_statement + [ + "begin" + "end" + ] @keyword) + +(quote_statement + [ + "quote" + "end" + ] @keyword) + +(let_statement + [ + "let" + "end" + ] @keyword) + +(if_statement + [ + "if" + "end" + ] @keyword.conditional) + +(elseif_clause + "elseif" @keyword.conditional) + +(else_clause + "else" @keyword.conditional) + +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +(try_statement + [ + "try" + "end" + ] @keyword.exception) + +(catch_clause + "catch" @keyword.exception) + +(finally_clause + "finally" @keyword.exception) + +(for_statement + [ + "for" + "end" + ] @keyword.repeat) + +(for_binding + "outer" @keyword.repeat) + +; comprehensions +(for_clause + "for" @keyword.repeat) + +(if_clause + "if" @keyword.conditional) + +(while_statement + [ + "while" + "end" + ] @keyword.repeat) + +[ + (break_statement) + (continue_statement) +] @keyword.repeat + +[ + "const" + "mutable" +] @keyword.modifier + +(function_definition + [ + "function" + "end" + ] @keyword.function) + +(do_clause + [ + "do" + "end" + ] @keyword.function) + +(macro_definition + [ + "macro" + "end" + ] @keyword) + +(return_statement + "return" @keyword.return) + +(module_definition + [ + "module" + "baremodule" + "end" + ] @keyword.import) + +(export_statement + "export" @keyword.import) + +(public_statement + "public" @keyword.import) + +(import_statement + "import" @keyword.import) + +(using_statement + "using" @keyword.import) + +(import_alias + "as" @keyword.import) + +(selected_import + ":" @punctuation.delimiter) + +(struct_definition + [ + "mutable" + "struct" + "end" + ] @keyword.type) + +(abstract_definition + [ + "abstract" + "type" + "end" + ] @keyword.type) + +(primitive_definition + [ + "primitive" + "type" + "end" + ] @keyword.type) + +; Operators & Punctuation +(operator) @operator + +(adjoint_expression + "'" @operator) + +(range_expression + ":" @operator) + +(arrow_function_expression + "->" @operator) + +[ + "." + "..." +] @punctuation.special + +[ + "," + ";" + "::" +] @punctuation.delimiter + +; Treat `::` as operator in type contexts, see +; https://github.com/nvim-treesitter/nvim-treesitter/pull/7392 +(typed_expression + "::" @operator) + +(unary_typed_expression + "::" @operator) + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; Interpolation +(string_interpolation + . + "$" @punctuation.special) + +(interpolation_expression + . + "$" @punctuation.special) + +; Keyword operators +((operator) @keyword.operator + (#any-of? @keyword.operator "in" "isa")) + +(where_expression + "where" @keyword.operator) + +; Built-in constants +((identifier) @constant.builtin + (#any-of? @constant.builtin "nothing" "missing")) + +((identifier) @variable.builtin + (#any-of? @variable.builtin "begin" "end") + (#has-ancestor? @variable.builtin index_expression)) + +; Literals +(boolean_literal) @boolean + +(integer_literal) @number + +(float_literal) @number.float + +((identifier) @number.float + (#any-of? @number.float "NaN" "NaN16" "NaN32" "Inf" "Inf16" "Inf32")) + +(character_literal) @character + +(escape_sequence) @string.escape + +(string_literal) @string + +(prefixed_string_literal + prefix: (identifier) @function.macro) @string + +(command_literal) @string.special + +(prefixed_command_literal + prefix: (identifier) @function.macro) @string.special + +((string_literal) @string.documentation + . + [ + (abstract_definition) + (assignment) + (const_statement) + (function_definition) + (macro_definition) + (module_definition) + (struct_definition) + ]) + +(source_file + (string_literal) @string.documentation + . + [ + (identifier) + (call_expression) + ]) + +[ + (line_comment) + (block_comment) +] @comment @spell diff --git a/runtime/queries/julia/indents.scm b/runtime/queries/julia/indents.scm new file mode 100644 index 000000000..7b40f876e --- /dev/null +++ b/runtime/queries/julia/indents.scm @@ -0,0 +1,52 @@ +[ + (struct_definition) + (macro_definition) + (function_definition) + (compound_statement) + (if_statement) + (try_statement) + (for_statement) + (while_statement) + (let_statement) + (quote_statement) + (do_clause) + (assignment) + (for_binding) + (call_expression) + (parenthesized_expression) + (tuple_expression) + (comprehension_expression) + (matrix_expression) + (vector_expression) +] @indent.begin + +[ + "end" + ")" + "]" + "}" +] @indent.end + +[ + "end" + ")" + "]" + "}" + (else_clause) + (elseif_clause) + (catch_clause) + (finally_clause) +] @indent.branch + +[ + (line_comment) + (block_comment) +] @indent.ignore + +((argument_list) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +((curly_expression) @indent.align + (#set! indent.open_delimiter "{") + (#set! indent.close_delimiter "}")) diff --git a/runtime/queries/julia/injections.scm b/runtime/queries/julia/injections.scm new file mode 100644 index 000000000..72d181066 --- /dev/null +++ b/runtime/queries/julia/injections.scm @@ -0,0 +1,42 @@ +; Inject markdown in docstrings +((string_literal + (content) @injection.content) + . + [ + (module_definition) + (abstract_definition) + (struct_definition) + (function_definition) + (macro_definition) + (assignment) + (const_statement) + (call_expression) + (identifier) + ] + (#set! injection.language "markdown")) + +; Inject comments +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) + +; Inject regex in r"..." and r"""...""" (e.g. r"hello\bworld") +(prefixed_string_literal + prefix: (identifier) @_prefix + (content) @injection.content + (#eq? @_prefix "r") + (#set! injection.language "regex")) + +; Inject markdown in md"..." and md"""...""" (e.g. md"**Bold** and _Italics_") +(prefixed_string_literal + prefix: (identifier) @_prefix + (content) @injection.content + (#eq? @_prefix "md") + (#set! injection.language "markdown")) + +; Inject bash in `...` and ```...``` (e.g. `git add --help`) +(command_literal + (content) @injection.content + (#set! injection.language "bash")) diff --git a/runtime/queries/julia/locals.scm b/runtime/queries/julia/locals.scm new file mode 100644 index 000000000..500b7fe58 --- /dev/null +++ b/runtime/queries/julia/locals.scm @@ -0,0 +1,75 @@ +; References +(identifier) @local.reference + +; Variables +(assignment + (identifier) @local.definition.var) + +(assignment + (tuple_expression + (identifier) @local.definition.var)) + +; let/const bindings +(let_binding + (identifier) @local.definition.var) + +(let_binding + (tuple_expression + (identifier) @local.definition.var)) + +; For bindings +(for_binding + (identifier) @local.definition.var) + +(for_binding + (tuple_expression + (identifier) @local.definition.var)) + +; Types +(module_definition + (identifier) @local.definition.type) + +(struct_definition + (identifier) @local.definition.type) + +(type_head + (identifier) @local.definition.type) + +(type_head + (binary_expression + . + (identifier) @local.definition.type)) + +; Module imports +(import_statement + (identifier) @local.definition.import) + +(using_statement + (identifier) @local.definition.import) + +(selected_import + (identifier) @local.definition.import) + +; Scopes +(function_definition + (signature + (call_expression + . + (identifier) @local.definition.function))) @local.scope + +(macro_definition + (signature + (call_expression + . + (identifier) @local.definition.function))) @local.scope + +[ + (quote_statement) + (let_statement) + (for_statement) + (while_statement) + (try_statement) + (catch_clause) + (finally_clause) + (do_clause) +] @local.scope diff --git a/runtime/queries/just/folds.scm b/runtime/queries/just/folds.scm new file mode 100644 index 000000000..fea3a5058 --- /dev/null +++ b/runtime/queries/just/folds.scm @@ -0,0 +1,6 @@ +([ + (recipe) + (string) + (external_command) +] @fold + (#trim! @fold)) diff --git a/runtime/queries/just/highlights.scm b/runtime/queries/just/highlights.scm new file mode 100644 index 000000000..fbbf4eece --- /dev/null +++ b/runtime/queries/just/highlights.scm @@ -0,0 +1,149 @@ +[ + "true" + "false" +] @boolean + +[ + "if" + "else" +] @keyword.conditional + +[ + "alias" + "set" + "shell" + "mod" +] @keyword + +[ + "import" + "export" +] @keyword.import + +[ + ":=" + "?" + "==" + "!=" + "=~" + "@" + "=" + "$" + "*" + "+" + "&&" + "@-" + "-@" + "-" + "/" + ":" +] @operator + +[ + "(" + ")" + "[" + "]" + "{{" + "}}" + "{" + "}" +] @punctuation.bracket + +[ + "`" + "```" +] @punctuation.special + +"," @punctuation.delimiter + +(shebang) @keyword.directive + +(comment) @comment @spell + +[ + (string) + (external_command) +] @string + +(escape_sequence) @string.escape + +(module + (identifier) @module) + +(assignment + (identifier) @variable) + +(alias + (identifier) @variable) + +(value + (identifier) @variable) + +; Recipe definitions +(recipe_header + (identifier) @function) + +(dependency + (identifier) @function.call) + +(dependency_expression + (identifier) @function.call) + +(parameter + (identifier) @variable.parameter) + +(dependency_expression + (expression + (value + (identifier) @variable.parameter))) + +; Fallback highlighting for recipe bodies +(recipe + (recipe_body) @string + (#set! priority 90)) + +; Ref: https://just.systems/man/en/chapter_26.html +;(setting (identifier) @error) +(setting + (identifier) @constant.builtin + (#any-of? @constant.builtin + "allow-duplicate-recipes" "dotenv-filename" "dotenv-load" "dotenv-path" "export" "fallback" + "ignore-comments" "positional-arguments" "tempdir" "windows-powershell" "windows-shell")) + +(recipe + (attribute + (identifier) @attribute)) + +; https://just.systems/man/en/attributes.html +((recipe + (attribute + (identifier) @attribute.builtin)) + (#any-of? @attribute.builtin + "confirm" "doc" "extension" "group" "linux" "macos" "no-cd" "no-exit-message" "no-quiet" + "openbsd" "positional-arguments" "private" "script" "unix" "windows" "working-directory")) + +((recipe + (attribute + (identifier) @_doc + argument: (string) @string.documentation)) + (#eq? @_doc "doc")) + +((recipe + (attribute + (identifier) @_dir + argument: (string) @string.special.path)) + (#eq? @_dir "working-directory")) + +; Ref: https://just.systems/man/en/chapter_31.html +;(function_call (identifier) @error) +(function_call + (identifier) @function.call + (#any-of? @function.call + "arch" "num_cpus" "os" "os_family" "env_var" "env_var_or_default" "env" "invocation_directory" + "invocation_directory_native" "justfile" "justfile_directory" "just_executable" "quote" + "replace" "replace_regex" "trim" "trim_end" "trim_end_match" "trim_end_matches" "trim_start" + "trim_start_match" "trim_start_matches" "capitalize" "kebabcase" "lowercamelcase" "lowercase" + "shoutykebabcase" "shoutysnakecase" "snakecase" "titlecase" "uppercamelcase" "uppercase" + "absolute_path" "extension" "file_name" "file_stem" "parent_directory" "without_extension" + "clean" "join" "path_exists" "error" "sha256" "sha256_file" "uuid" "semver_matches")) diff --git a/runtime/queries/just/indents.scm b/runtime/queries/just/indents.scm new file mode 100644 index 000000000..1402a0c03 --- /dev/null +++ b/runtime/queries/just/indents.scm @@ -0,0 +1,14 @@ +; Source: https://github.com/IndianBoy42/tree-sitter-just/blob/main/queries/just/indents.scm +[ + (recipe) + (string) + (external_command) +] @indent.begin + +(string + [ + "'''" + "\"\"\"" + ] @indent.branch @indent.end) + +(comment) @indent.auto diff --git a/runtime/queries/just/injections.scm b/runtime/queries/just/injections.scm new file mode 100644 index 000000000..90db6b725 --- /dev/null +++ b/runtime/queries/just/injections.scm @@ -0,0 +1,44 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; The right side of =~ literals +(regex_literal + (_) @injection.content + (#set! injection.language "regex")) + +; Default to bash highlighting for non-shebang recipes and commands +(recipe + (recipe_body + !shebang) @injection.content + (#set! injection.include-children) + (#set! injection.language "bash")) + +(external_command + (command_body) @injection.content + (#set! injection.language "bash")) + +; For shebang recipes, use the shebang executable name as the language by default +(recipe + (recipe_body + (shebang + (language) @injection.language)) @injection.content + (#not-any-of? @injection.language "python3" "nodejs" "node") + (#set! injection.include-children)) + +; python3 -> python +(recipe + (recipe_body + (shebang + (language) @_lang)) @injection.content + (#eq? @_lang "python3") + (#set! injection.language "python") + (#set! injection.include-children)) + +; node/nodejs -> javascript +(recipe + (recipe_body + (shebang + (language) @_lang)) @injection.content + (#any-of? @_lang "node" "nodejs") + (#set! injection.language "javascript") + (#set! injection.include-children)) diff --git a/runtime/queries/just/locals.scm b/runtime/queries/just/locals.scm new file mode 100644 index 000000000..80549f35b --- /dev/null +++ b/runtime/queries/just/locals.scm @@ -0,0 +1,35 @@ +; Source: https://github.com/IndianBoy42/tree-sitter-just/blob/main/queries/just/locals.scm +; Scope +(recipe) @local.scope + +; Definitions +(alias + left: (identifier) @local.definition.var) + +(assignment + left: (identifier) @local.definition.var) + +(module + name: (identifier) @local.definition.namespace) + +(parameter + name: (identifier) @local.definition.var) + +(recipe_header + name: (identifier) @local.definition.function) + +; References +(alias + right: (identifier) @local.reference) + +(function_call + name: (identifier) @local.reference) + +(dependency + name: (identifier) @local.reference) + +(dependency_expression + name: (identifier) @local.reference) + +(value + (identifier) @local.reference) diff --git a/runtime/queries/kcl/folds.scm b/runtime/queries/kcl/folds.scm new file mode 100644 index 000000000..64e9e95d1 --- /dev/null +++ b/runtime/queries/kcl/folds.scm @@ -0,0 +1,10 @@ +[ + (protocol_stmt) + (rule_stmt) + (schema_stmt) + (check_stmt) + (if_stmt) + (lambda_expr) + (config_expr) + (string) +] @fold diff --git a/runtime/queries/kcl/highlights.scm b/runtime/queries/kcl/highlights.scm new file mode 100644 index 000000000..81b699ac2 --- /dev/null +++ b/runtime/queries/kcl/highlights.scm @@ -0,0 +1,201 @@ +(identifier) @variable + +(import_stmt + (dotted_name + (identifier) @module)) + +(import_stmt + (dotted_name + (identifier) @module) + (identifier) @module) + +(basic_type) @type.builtin + +(schema_type + (dotted_name + (identifier) @type)) + +(schema_type + (dotted_name + (identifier) @module + (identifier) @type)) + +(schema_expr + (identifier) @type) + +(protocol_stmt + (identifier) @type) + +(rule_stmt + (identifier) @type) + +(schema_stmt + (identifier) @type) + +(lambda_expr + (typed_parameter + (identifier) @variable.parameter)) + +(lambda_expr + (identifier) @variable.parameter) + +(selector_expr + (select_suffix + (identifier) @property)) + +(comment) @comment @spell + +(string) @string + +(escape_sequence) @string.escape + +(schema_stmt + body: (block + . + (string + (string_content) @string.documentation))) + +(decorator + (identifier) @attribute) + +(call_expr + function: (identifier) @function) + +(call_expr + function: (selector_expr + (select_suffix + (identifier) @function))) + +(integer) @number + +(float) @number.float + +[ + (true) + (false) +] @boolean + +[ + (none) + (undefined) +] @constant.builtin + +"for" @keyword.repeat + +[ + "elif" + "else" + "if" +] @keyword.conditional + +"lambda" @keyword.function + +(quant_op) @keyword.operator + +[ + "protocol" + "rule" + "schema" + "type" + "mixin" +] @keyword.type + +"assert" @keyword.debug + +[ + "as" + "import" +] @keyword.import + +"check" @keyword + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "," + ":" + "." + "?." + "?:" + "?" +] @punctuation.delimiter + +(interpolation + "${" @punctuation.special + "}" @punctuation.special) + +[ + "+" + "-" + "*" + "**" + "/" + "//" + "%" + "<<" + ">>" + "&" + "|" + "^" + "<" + ">" + "~" + "<=" + ">=" + "==" + "!=" + "=" + "+=" + "-=" + "*=" + "**=" + "/=" + "//=" + "%=" + "<<=" + ">>=" + "&=" + "^=" + "->" +] @operator + +"@" @attribute + +[ + "and" + "or" + "not" + "in" + "is" +] @keyword.operator + +; second argument is a regex in all regex functions with at least two arguments +(call_expr + function: (selector_expr + (identifier) @_regex) + arguments: (argument_list + (_) + . + (string + (string_content) @string.regexp)) + (#eq? @_regex "regex")) + +; first argument is a regex in 'regex.compile' function +(call_expr + function: (selector_expr + (identifier) @_regex + (select_suffix + (identifier) @_fn + (#eq? @_fn "compile"))) + arguments: (argument_list + . + (string + (string_content) @string.regexp)) + (#eq? @_regex "regex")) diff --git a/runtime/queries/kcl/injections.scm b/runtime/queries/kcl/injections.scm new file mode 100644 index 000000000..4e04e54d3 --- /dev/null +++ b/runtime/queries/kcl/injections.scm @@ -0,0 +1,26 @@ +(call_expr + function: (selector_expr + (identifier) @_regex) + arguments: (argument_list + (_) + . + (string + (string_content) @injection.content)) + (#eq? @_regex "regex") + (#set! injection.language "regex")) + +(call_expr + function: (selector_expr + (identifier) @_regex + (select_suffix + (identifier) @_fn + (#eq? @_fn "compile"))) + arguments: (argument_list + . + (string + (string_content) @injection.content)) + (#eq? @_regex "regex") + (#set! injection.language "regex")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/kconfig/folds.scm b/runtime/queries/kconfig/folds.scm new file mode 100644 index 000000000..980667dfc --- /dev/null +++ b/runtime/queries/kconfig/folds.scm @@ -0,0 +1,9 @@ +[ + (config) + (menuconfig) + (choice) + (comment_entry) + (menu) + (if) + (help_text) +] @fold diff --git a/runtime/queries/kconfig/highlights.scm b/runtime/queries/kconfig/highlights.scm new file mode 100644 index 000000000..deb88bc00 --- /dev/null +++ b/runtime/queries/kconfig/highlights.scm @@ -0,0 +1,105 @@ +"source" @keyword.import + +[ + "mainmenu" + "config" + "menuconfig" + "choice" + "endchoice" + "comment" + "menu" + "endmenu" + "prompt" + "default" + "range" + "help" + (optional) + (modules) +] @keyword + +[ + "if" + "endif" + "depends on" + "select" + "imply" + "visible if" +] @keyword.conditional + +[ + "def_bool" + "def_tristate" +] @keyword.function + +[ + "||" + "&&" + "=" + "!=" + "<" + ">" + "<=" + ">=" + "!" + ":=" + "+=" + "?=" +] @operator + +[ + "bool" + "tristate" + "int" + "hex" + "string" +] @type.builtin + +[ + "(" + ")" +] @punctuation.bracket + +"," @punctuation.delimiter + +(macro_variable + [ + "$(" + ")" + ] @punctuation.special) + +(symbol) @variable + +[ + (string) + (macro_content) + (text) +] @string + +(config + name: (name + (symbol) @constant)) + +(menuconfig + name: (name + (symbol) @constant)) + +(choice + name: (name + (symbol) @constant)) + +((symbol) @constant + (#lua-match? @constant "[A-Z0-9]+")) + +(mainmenu + name: (string) @markup.heading) + +(comment_entry + name: (string) @markup.heading) + +(menu + name: (string) @markup.heading) + +(source + (string) @string.special.url) + +(comment) @comment @spell diff --git a/runtime/queries/kconfig/indents.scm b/runtime/queries/kconfig/indents.scm new file mode 100644 index 000000000..faa83602f --- /dev/null +++ b/runtime/queries/kconfig/indents.scm @@ -0,0 +1,12 @@ +(help_text + (text) @indent.auto) + +[ + (config) + (menuconfig) + (choice) + (comment_entry) + (menu) + (if) + (help_text) +] @indent.begin diff --git a/runtime/queries/kconfig/injections.scm b/runtime/queries/kconfig/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/kconfig/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/kconfig/locals.scm b/runtime/queries/kconfig/locals.scm new file mode 100644 index 000000000..09a50fecb --- /dev/null +++ b/runtime/queries/kconfig/locals.scm @@ -0,0 +1,24 @@ +[ + (symbol) + (string) +] @local.reference + +[ + (config) + (menuconfig) + (choice) + (comment_entry) + (menu) + (if) +] @local.scope + +(type_definition + (string) @local.definition.var) + +(type_definition + (input_prompt + (string) @local.definition.var)) + +(type_definition_default + (expression + (string) @local.definition.var)) diff --git a/runtime/queries/kdl/folds.scm b/runtime/queries/kdl/folds.scm new file mode 100644 index 000000000..c96619b14 --- /dev/null +++ b/runtime/queries/kdl/folds.scm @@ -0,0 +1,7 @@ +; Folds +[ + (node) + (node_children) + (string) + (multi_line_comment) +] @fold diff --git a/runtime/queries/kdl/highlights.scm b/runtime/queries/kdl/highlights.scm new file mode 100644 index 000000000..7d200c85e --- /dev/null +++ b/runtime/queries/kdl/highlights.scm @@ -0,0 +1,71 @@ +; Types +; Variables +(identifier) @variable + +; Nodes +(node + (identifier) @tag) + +; Type annotation +(type + (identifier) @type) + +; Properties +(prop + (identifier) @property) + +; Operators +[ + "=" + "+" + "-" +] @operator + +; Literals +(string) @string + +(escape) @string.escape + +(number) @number + +(number + (decimal) @number.float) + +(number + (exponent) @number.float) + +(boolean) @boolean + +"null" @constant.builtin + +; Punctuation +[ + "{" + "}" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +";" @punctuation.delimiter + +; Comments +[ + (single_line_comment) + (multi_line_comment) +] @comment @spell + +(node + (node_comment) + (#set! priority 105)) @comment + +(node + (node_field + (node_field_comment) + (#set! priority 105)) @comment) + +(node_children + (node_children_comment) + (#set! priority 105)) @comment diff --git a/runtime/queries/kdl/indents.scm b/runtime/queries/kdl/indents.scm new file mode 100644 index 000000000..6d16efd2d --- /dev/null +++ b/runtime/queries/kdl/indents.scm @@ -0,0 +1,14 @@ +(node + (node_children) @indent.begin) + +"}" @indent.end + +[ + "{" + "}" +] @indent.branch + +[ + "(" + ")" +] @indent.branch diff --git a/runtime/queries/kdl/injections.scm b/runtime/queries/kdl/injections.scm new file mode 100644 index 000000000..81d7734cb --- /dev/null +++ b/runtime/queries/kdl/injections.scm @@ -0,0 +1,5 @@ +([ + (single_line_comment) + (multi_line_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/kdl/locals.scm b/runtime/queries/kdl/locals.scm new file mode 100644 index 000000000..14b0af23e --- /dev/null +++ b/runtime/queries/kdl/locals.scm @@ -0,0 +1,16 @@ +(document) @local.scope + +(node + (node_children) @local.scope) + +(node_children + (node) @local.scope) + +(identifier) @local.reference + +(node_field) @local.definition.field + +(node + (identifier) @local.definition.type) + +(type) @local.definition.type diff --git a/runtime/queries/kotlin/folds.scm b/runtime/queries/kotlin/folds.scm new file mode 100644 index 000000000..eb4becc5f --- /dev/null +++ b/runtime/queries/kotlin/folds.scm @@ -0,0 +1,13 @@ +[ + (import_list) + (when_expression) + (control_structure_body) + (lambda_literal) + (function_body) + (primary_constructor) + (secondary_constructor) + (anonymous_initializer) + (class_body) + (enum_class_body) + (interpolated_expression) +] @fold diff --git a/runtime/queries/kotlin/highlights.scm b/runtime/queries/kotlin/highlights.scm new file mode 100644 index 000000000..8eda6ef61 --- /dev/null +++ b/runtime/queries/kotlin/highlights.scm @@ -0,0 +1,398 @@ +; Identifiers +(simple_identifier) @variable + +; `it` keyword inside lambdas +; FIXME: This will highlight the keyword outside of lambdas since tree-sitter +; does not allow us to check for arbitrary nestation +((simple_identifier) @variable.builtin + (#eq? @variable.builtin "it")) + +; `field` keyword inside property getter/setter +; FIXME: This will highlight the keyword outside of getters and setters +; since tree-sitter does not allow us to check for arbitrary nestation +((simple_identifier) @variable.builtin + (#eq? @variable.builtin "field")) + +[ + "this" + "super" + "this@" + "super@" +] @variable.builtin + +; NOTE: for consistency with "super@" +(super_expression + "@" @variable.builtin) + +(class_parameter + (simple_identifier) @variable.member) + +; NOTE: temporary fix for treesitter bug that causes delay in file opening +;(class_body +; (property_declaration +; (variable_declaration +; (simple_identifier) @variable.member))) +; id_1.id_2.id_3: `id_2` and `id_3` are assumed as object properties +(_ + (navigation_suffix + (simple_identifier) @variable.member)) + +; SCREAMING CASE identifiers are assumed to be constants +((simple_identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z0-9_]*$")) + +(_ + (navigation_suffix + (simple_identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z0-9_]*$"))) + +(enum_entry + (simple_identifier) @constant) + +(type_identifier) @type + +; '?' operator, replacement for Java @Nullable +(nullable_type) @punctuation.special + +(type_alias + (type_identifier) @type.definition) + +((type_identifier) @type.builtin + (#any-of? @type.builtin + "Byte" "Short" "Int" "Long" "UByte" "UShort" "UInt" "ULong" "Float" "Double" "Boolean" "Char" + "String" "Array" "ByteArray" "ShortArray" "IntArray" "LongArray" "UByteArray" "UShortArray" + "UIntArray" "ULongArray" "FloatArray" "DoubleArray" "BooleanArray" "CharArray" "Map" "Set" + "List" "EmptyMap" "EmptySet" "EmptyList" "MutableMap" "MutableSet" "MutableList")) + +(package_header + "package" @keyword + . + (identifier + (simple_identifier) @module)) + +(import_header + "import" @keyword.import) + +(wildcard_import) @character.special + +; The last `simple_identifier` in a `import_header` will always either be a function +; or a type. Classes can appear anywhere in the import path, unlike functions +(import_header + (identifier + (simple_identifier) @type @_import) + (import_alias + (type_identifier) @type.definition)? + (#lua-match? @_import "^[A-Z]")) + +(import_header + (identifier + (simple_identifier) @function @_import .) + (import_alias + (type_identifier) @function)? + (#lua-match? @_import "^[a-z]")) + +(label) @label + +; Function definitions +(function_declaration + (simple_identifier) @function) + +(getter + "get" @function.builtin) + +(setter + "set" @function.builtin) + +(primary_constructor) @constructor + +(secondary_constructor + "constructor" @constructor) + +(constructor_invocation + (user_type + (type_identifier) @constructor)) + +(anonymous_initializer + "init" @constructor) + +(parameter + (simple_identifier) @variable.parameter) + +(parameter_with_optional_type + (simple_identifier) @variable.parameter) + +; lambda parameters +(lambda_literal + (lambda_parameters + (variable_declaration + (simple_identifier) @variable.parameter))) + +; Function calls +; function() +(call_expression + . + (simple_identifier) @function.call) + +; ::function +(callable_reference + . + (simple_identifier) @function.call) + +; object.function() or object.property.function() +(call_expression + (navigation_expression + (navigation_suffix + (simple_identifier) @function.call) .)) + +(call_expression + . + (simple_identifier) @function.builtin + (#any-of? @function.builtin + "arrayOf" "arrayOfNulls" "byteArrayOf" "shortArrayOf" "intArrayOf" "longArrayOf" "ubyteArrayOf" + "ushortArrayOf" "uintArrayOf" "ulongArrayOf" "floatArrayOf" "doubleArrayOf" "booleanArrayOf" + "charArrayOf" "emptyArray" "mapOf" "setOf" "listOf" "emptyMap" "emptySet" "emptyList" + "mutableMapOf" "mutableSetOf" "mutableListOf" "print" "println" "error" "TODO" "run" + "runCatching" "repeat" "lazy" "lazyOf" "enumValues" "enumValueOf" "assert" "check" + "checkNotNull" "require" "requireNotNull" "with" "suspend" "synchronized")) + +; Literals +[ + (line_comment) + (multiline_comment) +] @comment @spell + +((multiline_comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +(shebang_line) @keyword.directive + +(real_literal) @number.float + +[ + (integer_literal) + (long_literal) + (hex_literal) + (bin_literal) + (unsigned_literal) +] @number + +[ + (null_literal) + ; should be highlighted the same as booleans + (boolean_literal) +] @boolean + +(character_literal) @character + +(string_literal) @string + +; NOTE: Escapes not allowed in multi-line strings +(character_literal + (character_escape_seq) @string.escape) + +; There are 3 ways to define a regex +; - "[abc]?".toRegex() +(call_expression + (navigation_expression + (string_literal) @string.regexp + (navigation_suffix + ((simple_identifier) @_function + (#eq? @_function "toRegex"))))) + +; - Regex("[abc]?") +(call_expression + ((simple_identifier) @_function + (#eq? @_function "Regex")) + (call_suffix + (value_arguments + (value_argument + (string_literal) @string.regexp)))) + +; - Regex.fromLiteral("[abc]?") +(call_expression + (navigation_expression + ((simple_identifier) @_class + (#eq? @_class "Regex")) + (navigation_suffix + ((simple_identifier) @_function + (#eq? @_function "fromLiteral")))) + (call_suffix + (value_arguments + (value_argument + (string_literal) @string.regexp)))) + +; Keywords +(type_alias + "typealias" @keyword) + +(companion_object + "companion" @keyword) + +[ + (class_modifier) + (member_modifier) + (function_modifier) + (property_modifier) + (platform_modifier) + (variance_modifier) + (parameter_modifier) + (visibility_modifier) + (reification_modifier) + (inheritance_modifier) +] @keyword.modifier + +[ + "val" + "var" + ; "typeof" ; NOTE: It is reserved for future use +] @keyword + +[ + "enum" + "class" + "object" + "interface" +] @keyword.type + +[ + "return" + "return@" +] @keyword.return + +"suspend" @keyword.coroutine + +"fun" @keyword.function + +[ + "if" + "else" + "when" +] @keyword.conditional + +[ + "for" + "do" + "while" + "continue" + "continue@" + "break" + "break@" +] @keyword.repeat + +[ + "try" + "catch" + "throw" + "finally" +] @keyword.exception + +(annotation + "@" @attribute + (use_site_target)? @attribute) + +(annotation + (user_type + (type_identifier) @attribute)) + +(annotation + (constructor_invocation + (user_type + (type_identifier) @attribute))) + +(file_annotation + "@" @attribute + "file" @attribute + ":" @attribute) + +(file_annotation + (user_type + (type_identifier) @attribute)) + +(file_annotation + (constructor_invocation + (user_type + (type_identifier) @attribute))) + +; Operators & Punctuation +[ + "!" + "!=" + "!==" + "=" + "==" + "===" + ">" + ">=" + "<" + "<=" + "||" + "&&" + "+" + "++" + "+=" + "-" + "--" + "-=" + "*" + "*=" + "/" + "/=" + "%" + "%=" + "?." + "?:" + "!!" + "is" + "!is" + "in" + "!in" + "as" + "as?" + ".." + "->" +] @operator + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "." + "," + ";" + ":" + "::" +] @punctuation.delimiter + +(super_expression + [ + "<" + ">" + ] @punctuation.delimiter) + +(type_arguments + [ + "<" + ">" + ] @punctuation.delimiter) + +(type_parameters + [ + "<" + ">" + ] @punctuation.delimiter) + +; NOTE: `interpolated_identifier`s can be highlighted in any way +(string_literal + "$" @punctuation.special + (interpolated_identifier) @none @variable) + +(string_literal + "${" @punctuation.special + (interpolated_expression) @none + "}" @punctuation.special) diff --git a/runtime/queries/kotlin/injections.scm b/runtime/queries/kotlin/injections.scm new file mode 100644 index 000000000..b2bc233ff --- /dev/null +++ b/runtime/queries/kotlin/injections.scm @@ -0,0 +1,48 @@ +([ + (line_comment) + (multiline_comment) +] @injection.content + (#set! injection.language "comment")) + +; There are 3 ways to define a regex +; - "[abc]?".toRegex() +(call_expression + (navigation_expression + ((string_literal) @injection.content + (#set! injection.language "regex")) + (navigation_suffix + ((simple_identifier) @_function + (#eq? @_function "toRegex"))))) + +; - Regex("[abc]?") +(call_expression + ((simple_identifier) @_function + (#eq? @_function "Regex")) + (call_suffix + (value_arguments + (value_argument + (string_literal) @injection.content + (#set! injection.language "regex"))))) + +; - Regex.fromLiteral("[abc]?") +(call_expression + (navigation_expression + ((simple_identifier) @_class + (#eq? @_class "Regex")) + (navigation_suffix + ((simple_identifier) @_function + (#eq? @_function "fromLiteral")))) + (call_suffix + (value_arguments + (value_argument + (string_literal) @injection.content + (#set! injection.language "regex"))))) + +; "pi = %.2f".format(3.14159) +((call_expression + (navigation_expression + (string_literal) @injection.content + (navigation_suffix + (simple_identifier) @_method))) + (#eq? @_method "format") + (#set! injection.language "printf")) diff --git a/runtime/queries/kotlin/locals.scm b/runtime/queries/kotlin/locals.scm new file mode 100644 index 000000000..330803f1b --- /dev/null +++ b/runtime/queries/kotlin/locals.scm @@ -0,0 +1,78 @@ +; Imports +(package_header + . + (identifier) @local.definition.namespace) + +(import_header + (identifier + (simple_identifier) @local.definition.import .) + (import_alias + (type_identifier) @local.definition.import)?) + +; Functions +(function_declaration + . + (simple_identifier) @local.definition.function + (#set! definition.function.scope "parent")) + +(class_body + (function_declaration + . + (simple_identifier) @local.definition.method) + (#set! definition.method.scope "parent")) + +; Variables +(function_declaration + (function_value_parameters + (parameter + (simple_identifier) @local.definition.parameter))) + +(lambda_literal + (lambda_parameters + (variable_declaration + (simple_identifier) @local.definition.parameter))) + +; NOTE: temporary fix for treesitter bug that causes delay in file opening +;(class_body +; (property_declaration +; (variable_declaration +; (simple_identifier) @local.definition.field))) +(class_declaration + (primary_constructor + (class_parameter + (simple_identifier) @local.definition.field))) + +(enum_class_body + (enum_entry + (simple_identifier) @local.definition.field)) + +(variable_declaration + (simple_identifier) @local.definition.var) + +; Types +(class_declaration + (type_identifier) @local.definition.type + (#set! definition.type.scope "parent")) + +(type_alias + (type_identifier) @local.definition.type + (#set! definition.type.scope "parent")) + +; Scopes +[ + (if_expression) + (when_expression) + (when_entry) + (for_statement) + (while_statement) + (do_while_statement) + (lambda_literal) + (function_declaration) + (primary_constructor) + (secondary_constructor) + (anonymous_initializer) + (class_declaration) + (enum_class_body) + (enum_entry) + (interpolated_expression) +] @local.scope diff --git a/runtime/queries/koto/folds.scm b/runtime/queries/koto/folds.scm new file mode 100644 index 000000000..d20d0120b --- /dev/null +++ b/runtime/queries/koto/folds.scm @@ -0,0 +1,9 @@ +[ + (assign) + (comment) + (function) + (list) + (map) + (tuple) + (string) +] @fold diff --git a/runtime/queries/koto/highlights.scm b/runtime/queries/koto/highlights.scm new file mode 100644 index 000000000..bd6ce8d0e --- /dev/null +++ b/runtime/queries/koto/highlights.scm @@ -0,0 +1,138 @@ +[ + "=" + "+" + "-" + "*" + "/" + "%" + "+=" + "-=" + "*=" + "/=" + "%=" + "==" + "!=" + "<" + ">" + "<=" + ">=" + ".." + "..=" + "->" + (null_check) +] @operator + +"let" @keyword + +[ + "and" + "not" + "or" +] @keyword.operator + +[ + "return" + "yield" +] @keyword.return + +[ + "if" + "then" + "else" + "else if" + "match" + "switch" +] @keyword.conditional + +[ + (break) + (continue) + "for" + "in" + "loop" + "until" + "while" +] @keyword.repeat + +[ + "throw" + "try" + "catch" + "finally" +] @keyword.exception + +[ + "export" + "from" + "import" + "as" +] @keyword.import + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "|" +] @punctuation.bracket + +(identifier) @variable + +(import_module + (identifier) @module) + +(import_item + (identifier) @module) + +(export + (identifier) @module) + +(chain + lookup: (identifier) @variable.member) + +(chain + start: (identifier) @function.call) + +[ + (true) + (false) +] @boolean + +(comment) @comment @spell + +(debug) @keyword.debug + +(string) @string + +(fill_char) @punctuation.delimiter + +(alignment) @operator + +(escape) @string.escape + +(null) @constant.builtin + +(number) @number + +(meta) @keyword.directive + +(meta + name: (identifier) @variable.member) + +(entry_inline + key: (identifier) @variable.member) + +(entry_block + key: (identifier) @variable.member) + +(self) @variable.builtin + +(arg + (identifier) @variable.parameter) + +(ellipsis) @variable.parameter + +(type + _ @type) diff --git a/runtime/queries/koto/injections.scm b/runtime/queries/koto/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/koto/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/koto/locals.scm b/runtime/queries/koto/locals.scm new file mode 100644 index 000000000..c18487483 --- /dev/null +++ b/runtime/queries/koto/locals.scm @@ -0,0 +1,28 @@ +; Scopes +(function + body: (_) @local.scope) + +; Definitions +(arg + (variable) @local.definition.parameter) + +(assign + (identifier) @local.definition.var) + +(for_args + (variable) @local.definition.var) + +(match_patterns + (variable) @local.definition.var) + +(import_item + (identifier) @local.definition.import) + +(entry_block + (identifier) @local.definition.field) + +(entry_inline + (identifier) @local.definition.field) + +; References +(identifier) @local.reference diff --git a/runtime/queries/kusto/highlights.scm b/runtime/queries/kusto/highlights.scm new file mode 100644 index 000000000..5f00f751c --- /dev/null +++ b/runtime/queries/kusto/highlights.scm @@ -0,0 +1,60 @@ +(identifier) @variable + +(let_keyword) @keyword + +(function_call + (identifier) @function.call) + +[ + (type_cast_function) + (to_scalar_function) + (between_function) + (datatable_function) +] @function.call + +(typed_parameter + (identifier) @variable.parameter) + +(function_arguments + (identifier) @variable.parameter) + +[ + (binary_operator) + (compound_keywords) + (operator) + (range_operator) + (join_operator) + (sub_operator) + (to_operator) + (mv_apply_operator) + (sort_keyword) +] @keyword.operator + +(string) @string + +(number) @number + +(bool) @boolean + +(null) @constant.builtin + +(comment) @comment @spell + +(type) @type + +(join_types) @keyword.modifier + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "," + ":" + (pipe) +] @punctuation.delimiter diff --git a/runtime/queries/kusto/injections.scm b/runtime/queries/kusto/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/kusto/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/lalrpop/folds.scm b/runtime/queries/lalrpop/folds.scm new file mode 100644 index 000000000..beeed9ba5 --- /dev/null +++ b/runtime/queries/lalrpop/folds.scm @@ -0,0 +1,5 @@ +[ + (grammar_item) + (use)+ + (action) +] @fold diff --git a/runtime/queries/lalrpop/highlights.scm b/runtime/queries/lalrpop/highlights.scm new file mode 100644 index 000000000..046d39790 --- /dev/null +++ b/runtime/queries/lalrpop/highlights.scm @@ -0,0 +1,98 @@ +(comment) @comment @spell + +"grammar" @keyword + +[ + "type" + "enum" +] @keyword.type + +[ + "pub" + "extern" + (mut) +] @keyword.modifier + +[ + "match" + "else" +] @keyword.conditional + +[ + "+" + "*" + "?" + ; TODO: inaccessible node + ; => + "=>@L" + "=>@R" + "=" + "&" +] @operator + +(binding_symbol + name: (identifier) @variable.parameter) + +(annotation + "#" @punctuation.special) + +(grammar_parameter + (identifier) @variable.parameter) + +(associated_type + (identifier) @type) + +(parametrized_type + (path + (identifier) @type)) + +(bare_symbol + (macro + (macro_id) @type.definition)) + +(bare_symbol + (identifier) @type.definition) + +(nonterminal_name + (macro_id) @type.definition) + +(nonterminal_name + (identifier) @type.definition) + +(nonterminal + (type_ref) @type.builtin) + +[ + "(" + ")" + "[" + "]" + "}" + "{" + ">" + "<" +] @punctuation.bracket + +[ + ";" + ":" + "::" + "," +] @punctuation.delimiter + +(lifetime + "'" @keyword.modifier) + +(lifetime + (identifier) @attribute) + +(lifetime + (identifier) @attribute.builtin + (#any-of? @attribute.builtin "static" "_")) + +(string_literal) @string + +(regex_literal) @string + +(annotation + (id) @function.macro) diff --git a/runtime/queries/lalrpop/injections.scm b/runtime/queries/lalrpop/injections.scm new file mode 100644 index 000000000..17d0ace48 --- /dev/null +++ b/runtime/queries/lalrpop/injections.scm @@ -0,0 +1,15 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +([ + (normal_action) + (failible_action) +] @injection.content + (#set! injection.language "rust")) + +((use) @injection.content + (#set! injection.language "rust")) + +((regex_literal) @injection.content + (#set! injection.language "regex") + (#offset! @injection.content 0 2 0 -1)) diff --git a/runtime/queries/lalrpop/locals.scm b/runtime/queries/lalrpop/locals.scm new file mode 100644 index 000000000..ceeac965b --- /dev/null +++ b/runtime/queries/lalrpop/locals.scm @@ -0,0 +1,5 @@ +(nonterminal_name + (macro_id) @local.definition.function) + +(nonterminal_name + (identifier) @local.definition.function) diff --git a/runtime/queries/latex/folds.scm b/runtime/queries/latex/folds.scm new file mode 100644 index 000000000..1ee7946b8 --- /dev/null +++ b/runtime/queries/latex/folds.scm @@ -0,0 +1,14 @@ +[ + (chapter) + (part) + (section) + (subsection) + (subsubsection) + (paragraph) + (subparagraph) + (generic_environment) + (math_environment) + (comment_environment) + (block_comment) + (displayed_equation) +] @fold diff --git a/runtime/queries/latex/highlights.scm b/runtime/queries/latex/highlights.scm new file mode 100644 index 000000000..c39cd1b14 --- /dev/null +++ b/runtime/queries/latex/highlights.scm @@ -0,0 +1,342 @@ +; General syntax +(command_name) @function @nospell + +(caption + command: _ @function) + +; Turn spelling on for text +(text) @spell + +; \text, \intertext, \shortintertext, ... +(text_mode + command: _ @function @nospell + content: (curly_group + (_) @none @spell)) + +; Variables, parameters +(placeholder) @variable + +(key_value_pair + key: (_) @variable.parameter @nospell + value: (_)) + +(curly_group_spec + (text) @variable.parameter) + +(brack_group_argc) @variable.parameter + +[ + (operator) + "=" + "_" + "^" +] @operator + +"\\item" @punctuation.special + +(delimiter) @punctuation.delimiter + +(math_delimiter + left_command: _ @punctuation.delimiter + left_delimiter: _ @punctuation.delimiter + right_command: _ @punctuation.delimiter + right_delimiter: _ @punctuation.delimiter) + +[ + "[" + "]" + "{" + "}" +] @punctuation.bracket ; "(" ")" has no syntactical meaning in LaTeX + +; General environments +(begin + command: _ @module + name: (curly_group_text + (text) @label @nospell)) + +(end + command: _ @module + name: (curly_group_text + (text) @label @nospell)) + +; Definitions and references +(new_command_definition + command: _ @function.macro @nospell) + +(old_command_definition + command: _ @function.macro @nospell) + +(let_command_definition + command: _ @function.macro @nospell) + +(environment_definition + command: _ @function.macro @nospell + name: (curly_group_text + (_) @label @nospell)) + +(theorem_definition + command: _ @function.macro @nospell + name: (curly_group_text_list + (_) @label @nospell)) + +(paired_delimiter_definition + command: _ @function.macro @nospell + declaration: (curly_group_command_name + (_) @function)) + +(label_definition + command: _ @function.macro + name: (curly_group_text + (_) @markup.link @nospell)) + +(label_reference_range + command: _ @function.macro + from: (curly_group_text + (_) @markup.link) + to: (curly_group_text + (_) @markup.link)) + +(label_reference + command: _ @function.macro + names: (curly_group_text_list + (_) @markup.link)) + +(label_number + command: _ @function.macro + name: (curly_group_text + (_) @markup.link) + number: (_) @markup.link) + +(citation + command: _ @function.macro @nospell + keys: (curly_group_text_list) @markup.link @nospell) + +((hyperlink + command: _ @function @nospell + uri: (curly_group_uri + (_) @markup.link.url @nospell)) @_hyperlink + (#set! @_hyperlink url @markup.link.url)) + +(glossary_entry_definition + command: _ @function.macro @nospell + name: (curly_group_text + (_) @markup.link @nospell)) + +(glossary_entry_reference + command: _ @function.macro + name: (curly_group_text + (_) @markup.link)) + +(acronym_definition + command: _ @function.macro @nospell + name: (curly_group_text + (_) @markup.link @nospell)) + +(acronym_reference + command: _ @function.macro + name: (curly_group_text + (_) @markup.link)) + +(color_definition + command: _ @function.macro + name: (curly_group_text + (_) @markup.link)) + +(color_reference + command: _ @function.macro + name: (curly_group_text + (_) @markup.link)?) + +; Sectioning +(title_declaration + command: _ @module + options: (brack_group + (_) @markup.heading.1)? + text: (curly_group + (_) @markup.heading.1)) + +(author_declaration + command: _ @module + authors: (curly_group_author_list + (author)+ @markup.heading.1)) + +(chapter + command: _ @module + toc: (brack_group + (_) @markup.heading.2)? + text: (curly_group + (_) @markup.heading.2)) + +(part + command: _ @module + toc: (brack_group + (_) @markup.heading.2)? + text: (curly_group + (_) @markup.heading.2)) + +(section + command: _ @module + toc: (brack_group + (_) @markup.heading.3)? + text: (curly_group + (_) @markup.heading.3)) + +(subsection + command: _ @module + toc: (brack_group + (_) @markup.heading.4)? + text: (curly_group + (_) @markup.heading.4)) + +(subsubsection + command: _ @module + toc: (brack_group + (_) @markup.heading.5)? + text: (curly_group + (_) @markup.heading.5)) + +(paragraph + command: _ @module + toc: (brack_group + (_) @markup.heading.6)? + text: (curly_group + (_) @markup.heading.6)) + +(subparagraph + command: _ @module + toc: (brack_group + (_) @markup.heading.6)? + text: (curly_group + (_) @markup.heading.6)) + +; Beamer frames +(generic_environment + (begin + name: (curly_group_text + (text) @label) + (#any-of? @label "frame")) + . + (curly_group + (_) @markup.heading)) + +((generic_command + command: (command_name) @_name + arg: (curly_group + (_) @markup.heading)) + (#eq? @_name "\\frametitle")) + +((generic_command + command: (command_name) @_name + arg: (curly_group + (_) @markup.italic)) + (#any-of? @_name "\\emph" "\\textit" "\\mathit")) + +((generic_command + command: (command_name) @_name + arg: (curly_group + (_) @markup.strong)) + (#any-of? @_name "\\textbf" "\\mathbf")) + +(generic_command + (command_name) @keyword.conditional + (#lua-match? @keyword.conditional "^\\if[a-zA-Z@]+$")) + +(generic_command + (command_name) @keyword.conditional + (#any-of? @keyword.conditional "\\fi" "\\else")) + +; File inclusion commands +(class_include + command: _ @keyword.import + path: (curly_group_path) @string) + +(package_include + command: _ @keyword.import + paths: (curly_group_path_list) @string) + +(latex_include + command: _ @keyword.import + path: (curly_group_path) @string.special.path) + +(verbatim_include + command: _ @keyword.import + path: (curly_group_path) @string.special.path) + +(import_include + command: _ @keyword.import + directory: (curly_group_path) @string.special.path + file: (curly_group_path) @string.special.path) + +(bibstyle_include + command: _ @keyword.import + path: (curly_group_path) @string) + +(bibtex_include + command: _ @keyword.import + paths: (curly_group_path_list) @string.special.path) + +(biblatex_include + "\\addbibresource" @keyword.import + glob: (curly_group_glob_pattern) @string.regexp) + +(graphics_include + command: _ @keyword.import + path: (curly_group_path) @string.special.path) + +(svg_include + command: _ @keyword.import + path: (curly_group_path) @string.special.path) + +(inkscape_include + command: _ @keyword.import + path: (curly_group_path) @string.special.path) + +(tikz_library_import + command: _ @keyword.import + paths: (curly_group_path_list) @string) + +; Turn spelling off for whole nodes +[ + (label_reference) + (label_reference_range) + (label_number) + (glossary_entry_reference) + (acronym_reference) + (color_definition) + (color_reference) + (class_include) + (package_include) + (latex_include) + (verbatim_include) + (import_include) + (bibstyle_include) + (bibtex_include) + (biblatex_include) + (graphics_include) + (svg_include) + (inkscape_include) + (tikz_library_import) +] @nospell + +; Math +[ + (displayed_equation) + (inline_formula) +] @markup.math @nospell + +(math_environment + (_) @markup.math) + +; Comments +[ + (line_comment) + (block_comment) + (comment_environment) +] @comment @spell + +((line_comment) @keyword.directive @nospell + (#lua-match? @keyword.directive "^%% !TeX")) + +((line_comment) @keyword.directive @nospell + (#lua-match? @keyword.directive "^%%&")) diff --git a/runtime/queries/latex/injections.scm b/runtime/queries/latex/injections.scm new file mode 100644 index 000000000..53d808c1d --- /dev/null +++ b/runtime/queries/latex/injections.scm @@ -0,0 +1,36 @@ +([ + (line_comment) + (block_comment) + (comment_environment) +] @injection.content + (#set! injection.language "comment")) + +(pycode_environment + code: (source_code) @injection.content + (#set! injection.language "python")) + +(sagesilent_environment + code: (source_code) @injection.content + (#set! injection.language "python")) + +(sageblock_environment + code: (source_code) @injection.content + (#set! injection.language "python")) + +(luacode_environment + code: (source_code) @injection.content + (#set! injection.language "lua")) + +(asy_environment + code: (source_code) @injection.content + (#set! injection.language "c")) + +(asydef_environment + code: (source_code) @injection.content + (#set! injection.language "c")) + +(minted_environment + (begin + language: (curly_group_text + (text) @injection.language)) + (source_code) @injection.content) diff --git a/runtime/queries/ledger/folds.scm b/runtime/queries/ledger/folds.scm new file mode 100644 index 000000000..8b5736819 --- /dev/null +++ b/runtime/queries/ledger/folds.scm @@ -0,0 +1 @@ +(xact) @fold diff --git a/runtime/queries/ledger/highlights.scm b/runtime/queries/ledger/highlights.scm new file mode 100644 index 000000000..5198ad888 --- /dev/null +++ b/runtime/queries/ledger/highlights.scm @@ -0,0 +1,54 @@ +[ + (block_comment) + (comment) + (note) + (test) +] @comment @spell + +[ + (quantity) + (negative_quantity) +] @number + +[ + (date) + (effective_date) + (time) + (interval) +] @string.special + +[ + (commodity) + (option) + (option_value) + (check_in) + (check_out) +] @markup.raw + +(account) @variable.member + +"include" @keyword.import + +[ + "account" + "alias" + "assert" + "check" + "commodity" + "comment" + "def" + "default" + "end" + "eval" + "format" + "nomarket" + "note" + "payee" + "test" + "A" + "Y" + "N" + "D" + "C" + "P" +] @keyword diff --git a/runtime/queries/ledger/indents.scm b/runtime/queries/ledger/indents.scm new file mode 100644 index 000000000..9697c9cfa --- /dev/null +++ b/runtime/queries/ledger/indents.scm @@ -0,0 +1 @@ +(journal_item) @indent.begin diff --git a/runtime/queries/ledger/injections.scm b/runtime/queries/ledger/injections.scm new file mode 100644 index 000000000..35fb57eef --- /dev/null +++ b/runtime/queries/ledger/injections.scm @@ -0,0 +1,5 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((note) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/leo/highlights.scm b/runtime/queries/leo/highlights.scm new file mode 100644 index 000000000..3d4dadd3c --- /dev/null +++ b/runtime/queries/leo/highlights.scm @@ -0,0 +1,225 @@ +[ + "assert" + "assert_eq" + "assert_neq" + "block" + "console" + "const" + "let" + "mapping" + "program" + "self" + "then" +] @keyword + +[ + "record" + "struct" +] @keyword.type + +[ + "in" + "as" +] @keyword.operator + +[ + "constant" + "private" + "public" +] @keyword.modifier + +"self" @variable.builtin + +"network" @variable.builtin + +"async" @keyword.coroutine + +[ + "finalize" + "function" + "inline" + "transition" +] @keyword.function + +"import" @keyword.import + +"return" @keyword.return + +(return_arrow) @punctuation.delimiter + +"for" @keyword.repeat + +[ + "else" + "if" +] @keyword.conditional + +[ + (ternary_if) + (ternary_else) +] @keyword.conditional.ternary + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + ";" + "," + "::" +] @punctuation.delimiter + +[ + "!" + "&&" + "||" + "==" + "!=" + "<" + "<=" + ">" + ">=" + "&" + "|" + "^" + "<<" + ">>" + "+" + "-" + "*" + "/" + "%" + "**" + "=" + "+=" + "-=" + "*=" + "/=" + "%=" + "**=" + "<<=" + ">>=" + "&=" + "|=" + "^=" + "&&=" + "||=" +] @operator + +(comment) @comment @spell + +(boolean_literal) @boolean + +(constant_declaration + (identifier + (constant_identifier) @constant)) + +(variable + (constant_identifier) @constant) + +(associated_constant) @constant + +(variable) @variable + +(program_id) @string.special + +;record declaration +(record_declaration + (identifier) @type.definition) + +;struct component +(struct_component_declaration + (identifier) @variable.member) + +(struct_expression + (identifier) @type.definition) + +(struct_component_initializer + (identifier) @variable.member) + +[ + (type) + (boolean_type) + (integer_type) + (field_type) + (group_type) + (scalar_type) + (address_type) + (signature_type) + (string_type) +] @type + +[ + (block_height) + (self_address) + (self_caller) + (self_signer) + (network_id) +] @constant.builtin + +(free_function_call + (locator + (identifier) @function)) + +(associated_function_call + (named_type + (identifier + (constant_identifier) @function))) + +(associated_function_call + (identifier) @function.call) + +(record_type + (locator + (identifier) @variable.member)) + +(transition_declaration + name: (identifier) @function.builtin) + +(finalizer + name: (identifier) @function.builtin) + +(free_function_call + (identifier) @function.call) + +(function_declaration + name: (identifier) @function) + +(inline_declaration + name: (identifier) @function.macro) + +(method_call + . + (_) + . + (identifier) @function.method.call) + +(function_parameter + (identifier) @variable.parameter) + +(struct_declaration + name: (identifier) @type.definition) + +(variable_declaration + (identifier) @variable) + +[ + (address_literal) + (signature_literal) + ((affine_group_literal) + (#set! priority 101)) + (field_literal) + (product_group_literal) + (scalar_literal) + (signed_literal) + (unsigned_literal) +] @number + +(string_literal) @string + +(annotation) @attribute diff --git a/runtime/queries/leo/indents.scm b/runtime/queries/leo/indents.scm new file mode 100644 index 000000000..b2d33a59b --- /dev/null +++ b/runtime/queries/leo/indents.scm @@ -0,0 +1,61 @@ +[ + (array_expression) + (assert_statement) + (assignment_statement) + (block) + (constant_declaration) + (expression_statement) + (items_block) + (loop_statement) + (mapping_declaration) + (parenthesized_expression) + (record_declaration) + (return_statement) + (struct_declaration) + (struct_expression) + (tuple_expression) + (variable_declaration) +] @indent.begin + +((function_parameters) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +((function_arguments) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +(parenthesized_expression + ")" @indent.branch) + +(function_parameters + ")" @indent.branch) + +(function_arguments + ")" @indent.branch) + +(record_declaration + "}" @indent.branch) + +(struct_declaration + "}" @indent.branch) + +(struct_expression + "}" @indent.branch) + +(array_expression + "]" @indent.branch) + +(tuple_expression + ")" @indent.branch) + +(items_block + "}" @indent.branch) + +(block + "}" @indent.branch) + +[ + (comment) + (ERROR) +] @indent.auto diff --git a/runtime/queries/leo/injections.scm b/runtime/queries/leo/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/leo/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/linkerscript/folds.scm b/runtime/queries/linkerscript/folds.scm new file mode 100644 index 000000000..0fc77b1a7 --- /dev/null +++ b/runtime/queries/linkerscript/folds.scm @@ -0,0 +1,6 @@ +[ + (sections_command) + (output_section) + (memory_command) + (phdrs_command) +] @fold diff --git a/runtime/queries/linkerscript/highlights.scm b/runtime/queries/linkerscript/highlights.scm new file mode 100644 index 000000000..12330169e --- /dev/null +++ b/runtime/queries/linkerscript/highlights.scm @@ -0,0 +1,173 @@ +; Keywords +[ + "ENTRY" + "SECTIONS" + "AT" + "OVERLAY" + "NOCROSSREFS" + "MEMORY" + "PHDRS" + "FILEHDR" +] @keyword + +; Conditionals +(conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +; Variables +(symbol) @variable + +(filename) @string.special.path + +; Functions +(call_expression + function: (symbol) @function.call) + +((call_expression + function: (symbol) @keyword.directive) + (#eq? @keyword.directive "DEFINED")) + +((call_expression + function: (symbol) @function.builtin) + (#any-of? @function.builtin + "ABSOLUTE" "ALIAS" "ADDR" "ALIGN" "ALIGNOF" "BASE" "BLOCK" "CHIP" "DATA_SEGMENT_ALIGN" + "DATA_SEGMENT_END" "DATA_SEGMENT_RELRO_END" "END" "LENGTH" "LOADADDR" "LOG2CEIL" "MAX" "MIN" + "NEXT" "ORIGIN" "SEGMENT_START" "SIZEOF" "BYTE" "FILL" "LONG" "SHORT" "QUAD" "SQUAD" "WORD")) + +[ + "KEEP" + "PROVIDE" + "PROVIDE_HIDDEN" +] @function.builtin + +; Types +(section_type + "(" + [ + "NOLOAD" + "DSECT" + "COPY" + "INFO" + "OVERLAY" + ] @type.builtin + ")") + +; Fields +[ + "ORIGIN" + "org" + "o" + "LENGTH" + "len" + "l" +] @variable.member + +; Constants +((symbol) @constant + (#lua-match? @constant "^[%u_][%u%d_]+$")) + +; Labels +(entry_command + name: (symbol) @label) + +(output_section + name: (symbol) @label) + +(memory_command + name: (symbol) @label) + +(phdrs_command + name: (symbol) @label) + +(region + ">" + (symbol) @label) + +(lma_region + ">" + (symbol) @label) + +(phdr + ":" + (symbol) @label) + +([ + (symbol) + (filename) +] @label + (#lua-match? @label "^%.")) + +; Exceptions +"ASSERT" @keyword.exception + +[ + "/DISCARD/" + "." +] @variable.builtin + +; Operators +[ + "+" + "-" + "*" + "/" + "%" + "||" + "&&" + "|" + "&" + "==" + "!=" + ">" + ">=" + "<=" + "<" + "<<" + ">>" + "!" + "~" + "=" + "+=" + "-=" + "*=" + "/=" + "<<=" + ">>=" + "&=" + "|=" +] @operator + +; Literals +(number) @number + +(quoted_symbol) @string + +(wildcard_pattern + [ + "*" + "[" + "]" + ] @character.special) + +(attributes) @character.special + +; Punctuation +[ + "{" + "}" + "(" + ")" +] @punctuation.bracket + +[ + ":" + ";" +] @punctuation.delimiter + +">" @punctuation.special + +; Comments +(comment) @comment @spell diff --git a/runtime/queries/linkerscript/indents.scm b/runtime/queries/linkerscript/indents.scm new file mode 100644 index 000000000..a636ba109 --- /dev/null +++ b/runtime/queries/linkerscript/indents.scm @@ -0,0 +1,11 @@ +[ + (sections_command) + (output_section) + (memory_command) + (phdrs_command) +] @indent.begin + +[ + "}" + ")" +] @indent.branch @indent.end diff --git a/runtime/queries/linkerscript/injections.scm b/runtime/queries/linkerscript/injections.scm new file mode 100644 index 000000000..51e6d1f6b --- /dev/null +++ b/runtime/queries/linkerscript/injections.scm @@ -0,0 +1,2 @@ +((comment) + (#set! injection.language "comment")) diff --git a/runtime/queries/linkerscript/locals.scm b/runtime/queries/linkerscript/locals.scm new file mode 100644 index 000000000..6b7660370 --- /dev/null +++ b/runtime/queries/linkerscript/locals.scm @@ -0,0 +1,16 @@ +; References +[ + (symbol) + (filename) + (quoted_symbol) +] @local.reference + +; Definitions +(output_section + name: (symbol) @local.definition.var) + +(memory_command + name: (symbol) @local.definition.var) + +(phdrs_command + name: (symbol) @local.definition.var) diff --git a/runtime/queries/liquid/highlights.scm b/runtime/queries/liquid/highlights.scm new file mode 100644 index 000000000..38750db41 --- /dev/null +++ b/runtime/queries/liquid/highlights.scm @@ -0,0 +1,134 @@ +((comment) @comment @spell + (#set! priority 110)) + +(raw_statement + (raw_content) @spell + (#set! priority 110)) + +((identifier) @variable + (#set! priority 110)) + +((string) @string + (#set! priority 110)) + +((boolean) @boolean + (#set! priority 110)) + +((number) @number + (#set! priority 110)) + +(filter + name: (identifier) @function.call + (#set! priority 110)) + +([ + "as" + "assign" + "capture" + (custom_unpaired_statement) + "decrement" + "echo" + "endcapture" + "endform" + "endjavascript" + "endraw" + "endschema" + "endstyle" + "form" + "increment" + "javascript" + "layout" + "liquid" + "raw" + "schema" + "style" + "with" +] @keyword + (#set! priority 110)) + +([ + "case" + "else" + "elsif" + "endcase" + "endif" + "endunless" + "if" + "unless" + "when" +] @keyword.conditional + (#set! priority 110)) + +([ + (break_statement) + (continue_statement) + "by" + "cycle" + "endfor" + "endpaginate" + "endtablerow" + "for" + "paginate" + "tablerow" +] @keyword.repeat + (#set! priority 110)) + +([ + "and" + "contains" + "in" + "or" +] @keyword.operator + (#set! priority 110)) + +([ + "{{" + "}}" + "{{-" + "-}}" + "{%" + "%}" + "{%-" + "-%}" +] @tag.delimiter + (#set! priority 110)) + +[ + "include" + "include_relative" + "render" + "section" + "sections" +] @keyword.import + +[ + "|" + ":" + "=" + "+" + "-" + "*" + "/" + "%" + "^" + "==" + "<" + "<=" + "!=" + ">=" + ">" +] @operator + +[ + "]" + "[" + ")" + "(" +] @punctuation.bracket + +[ + "," + "." +] @punctuation.delimiter + +(front_matter) @keyword.directive diff --git a/runtime/queries/liquid/injections.scm b/runtime/queries/liquid/injections.scm new file mode 100644 index 000000000..ab0ced6ae --- /dev/null +++ b/runtime/queries/liquid/injections.scm @@ -0,0 +1,27 @@ +((template_content) @injection.content + (#set! injection.language "html") + (#set! injection.combined)) + +; TODO we can switch to quantifiers once neovim 0.10 becomes stable +(javascript_statement + (js_content) @injection.content + (#set! injection.language "javascript") + (#set! injection.combined)) + +(schema_statement + (json_content) @injection.content + (#set! injection.language "json") + (#set! injection.combined)) + +(style_statement + (style_content) @injection.content + (#set! injection.language "css") + (#set! injection.combined)) + +((front_matter) @injection.content + (#set! injection.language "yaml") + (#offset! @injection.content 1 0 -1 0) + (#set! injection.include-children)) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/liquidsoap/folds.scm b/runtime/queries/liquidsoap/folds.scm new file mode 100644 index 000000000..56e4ce547 --- /dev/null +++ b/runtime/queries/liquidsoap/folds.scm @@ -0,0 +1,21 @@ +[ + (let) + (binding) + (simple_fun) + (def) + (arglist) + (if) + (if_condition) + (if_then) + (elsif_condition) + (elsif_then) + (if_else) + (for) + (for_do) + (while) + (while_do) + (try) + (try_body) + (try_do) + (block) +] @fold diff --git a/runtime/queries/liquidsoap/highlights.scm b/runtime/queries/liquidsoap/highlights.scm new file mode 100644 index 000000000..c5608f897 --- /dev/null +++ b/runtime/queries/liquidsoap/highlights.scm @@ -0,0 +1,111 @@ +(var) @variable + +(op) @operator + +[ + "and" + "or" + "not" +] @keyword.operator + +[ + "def" + "fun" + "def_end" +] @keyword.function + +(let_decoration) @keyword.coroutine + +[ + "open" + "begin" + "block_end" + "let" +] @keyword + +[ + "while" + "do" + "to" + "for" + "for_end" + "while_end" +] @keyword.repeat + +[ + "if" + "then" + "elsif" + "else" + "if_end" +] @keyword.conditional + +[ + "try" + "catch" + "try_end" +] @keyword.exception + +(inline_if + [ + "?" + ":" + ] @keyword.conditional.ternary) + +[ + "%ifdef" + "%ifndef" + "%ifencoder" + "%ifnencoder" + "%ifversion" + "%else" + "%endif" + "%argsof" + "%include" +] @keyword.directive + +(encoder_name) @constant.builtin + +(anonymous_argument + (var) @variable.parameter) + +(labeled_argument + label: (var) @variable.parameter) + +"." @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(app + name: (var) @function.call) + +(method) @function.method + +(method_app) @function.method.call + +(string) @string + +(string_interpolation + [ + "#{" + "}" + ] @punctuation.special) + +(integer) @number + +(float) @number.float + +(bool) @boolean + +(comment) @comment @spell + +(regexp) @string.regexp + +(type) @type diff --git a/runtime/queries/liquidsoap/indents.scm b/runtime/queries/liquidsoap/indents.scm new file mode 100644 index 000000000..7cb5935fb --- /dev/null +++ b/runtime/queries/liquidsoap/indents.scm @@ -0,0 +1,66 @@ +[ + "%ifdef" + "%ifndef" + "%ifencoder" + "%ifnencoder" + "%ifversion" + "%else" + "%endif" + "%argsof" + "%include" +] @indent.zero + +[ + "if" + "def" + "let" + "for" + "while" + "try" + "{" + "[" + "(" +] @indent.begin + +(ERROR + "def") @indent.begin + +(def + "def_end" @indent.end) + +(if + "if_end" @indent.end) + +(block + "block_end" @indent.end) + +(for + "for_end" @indent.end) + +(while + "while_end" @indent.end) + +(try + "try_end" @indent.end) + +[ + "then" + "do" + "else" + "elsif" + "catch" +] @indent.branch + +[ + "def_end" + "if_end" + "block_end" + "for_end" + "while_end" + "try_end" + "}" + "]" + ")" +] @indent.branch @indent.end + +(comment) @indent.auto diff --git a/runtime/queries/liquidsoap/injections.scm b/runtime/queries/liquidsoap/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/liquidsoap/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/liquidsoap/locals.scm b/runtime/queries/liquidsoap/locals.scm new file mode 100644 index 000000000..995294c03 --- /dev/null +++ b/runtime/queries/liquidsoap/locals.scm @@ -0,0 +1,35 @@ +[ + (anonymous_function) + (binding) + (def) + (let) +] @local.scope + +(anonymous_argument + (var) @local.definition.parameter) + +(labeled_argument + label: (var) @local.definition.parameter) + +(binding + defined: (var) @local.definition.var) + +(def + defined: (var) @local.definition.var) + +(let + defined: (var) @local.definition.var) + +(meth_pattern + (var) @local.definition.var) + +(list_pattern + (var) @local.definition.var) + +(tuple_pattern + (var) @local.definition.var) + +(spread + (var) @local.definition.var) + +(var) @local.reference diff --git a/runtime/queries/llvm/highlights.scm b/runtime/queries/llvm/highlights.scm new file mode 100644 index 000000000..ea48272f5 --- /dev/null +++ b/runtime/queries/llvm/highlights.scm @@ -0,0 +1,180 @@ +[ + (local_var) + (global_var) +] @variable + +(type) @type + +(type_keyword) @type.builtin + +(type + [ + (local_var) + (global_var) + ] @type) + +(global_type + (local_var) @type.definition) + +(argument) @variable.parameter + +(_ + inst_name: _ @keyword.operator) + +[ + "catch" + "filter" +] @keyword.operator + +[ + "to" + "nuw" + "nsw" + "exact" + "unwind" + "from" + "cleanup" + "swifterror" + "volatile" + "inbounds" + "inrange" +] @keyword + +(icmp_cond) @keyword + +(fcmp_cond) @keyword + +(fast_math) @keyword + +(_ + callee: _ @function) + +(function_header + name: _ @function) + +[ + "declare" + "define" +] @keyword.function + +(calling_conv) @keyword.function + +[ + "target" + "triple" + "datalayout" + "source_filename" + "addrspace" + "blockaddress" + "align" + "syncscope" + "within" + "uselistorder" + "uselistorder_bb" + "module" + "asm" + "sideeffect" + "alignstack" + "inteldialect" + "unwind" + "type" + "global" + "constant" + "externally_initialized" + "alias" + "ifunc" + "section" + "comdat" + "any" + "exactmatch" + "largest" + "nodeduplicate" + "samesize" + "distinct" + "attributes" + "vscale" +] @keyword + +[ + "no_cfi" + (dso_local) + (linkage_aux) + (visibility) +] @keyword.modifier + +[ + "thread_local" + "localdynamic" + "initialexec" + "localexec" + (unnamed_addr) + (dll_storage_class) +] @keyword.modifier + +(attribute_name) @attribute + +(function_header + [ + (linkage) + (calling_conv) + (unnamed_addr) + ] @keyword.function) + +(number) @number + +(comment) @comment @spell + +(string) @string + +(cstring) @string + +(label) @label + +(_ + inst_name: "ret" @keyword.return) + +(float) @number.float + +[ + (struct_value) + (array_value) + (vector_value) +] @constructor + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" + "<{" + "}>" +] @punctuation.bracket + +[ + "," + ":" +] @punctuation.delimiter + +[ + "=" + "|" + "x" + "..." +] @operator + +[ + "true" + "false" +] @boolean + +[ + "undef" + "poison" + "null" + "none" + "zeroinitializer" +] @constant.builtin diff --git a/runtime/queries/llvm/injections.scm b/runtime/queries/llvm/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/llvm/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/lua/folds.scm b/runtime/queries/lua/folds.scm new file mode 100644 index 000000000..9dfac3abc --- /dev/null +++ b/runtime/queries/lua/folds.scm @@ -0,0 +1,12 @@ +[ + (do_statement) + (while_statement) + (repeat_statement) + (if_statement) + (for_statement) + (function_declaration) + (function_definition) + (parameters) + (arguments) + (table_constructor) +] @fold diff --git a/runtime/queries/lua/highlights.scm b/runtime/queries/lua/highlights.scm new file mode 100644 index 000000000..79ab165aa --- /dev/null +++ b/runtime/queries/lua/highlights.scm @@ -0,0 +1,265 @@ +; Keywords +"return" @keyword.return + +[ + "goto" + "in" + "local" +] @keyword + +(break_statement) @keyword + +(do_statement + [ + "do" + "end" + ] @keyword) + +(while_statement + [ + "while" + "do" + "end" + ] @keyword.repeat) + +(repeat_statement + [ + "repeat" + "until" + ] @keyword.repeat) + +(if_statement + [ + "if" + "elseif" + "else" + "then" + "end" + ] @keyword.conditional) + +(elseif_statement + [ + "elseif" + "then" + "end" + ] @keyword.conditional) + +(else_statement + [ + "else" + "end" + ] @keyword.conditional) + +(for_statement + [ + "for" + "do" + "end" + ] @keyword.repeat) + +(function_declaration + [ + "function" + "end" + ] @keyword.function) + +(function_definition + [ + "function" + "end" + ] @keyword.function) + +; Operators +[ + "and" + "not" + "or" +] @keyword.operator + +[ + "+" + "-" + "*" + "/" + "%" + "^" + "#" + "==" + "~=" + "<=" + ">=" + "<" + ">" + "=" + "&" + "~" + "|" + "<<" + ">>" + "//" + ".." +] @operator + +; Punctuations +[ + ";" + ":" + "::" + "," + "." +] @punctuation.delimiter + +; Brackets +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; Variables +(identifier) @variable + +((identifier) @constant.builtin + (#eq? @constant.builtin "_VERSION")) + +((identifier) @variable.builtin + (#eq? @variable.builtin "self")) + +((identifier) @module.builtin + (#any-of? @module.builtin "_G" "debug" "io" "jit" "math" "os" "package" "string" "table" "utf8")) + +((identifier) @keyword.coroutine + (#eq? @keyword.coroutine "coroutine")) + +(variable_list + (attribute + "<" @punctuation.bracket + (identifier) @attribute + ">" @punctuation.bracket)) + +; Labels +(label_statement + (identifier) @label) + +(goto_statement + (identifier) @label) + +; Constants +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + +(nil) @constant.builtin + +[ + (false) + (true) +] @boolean + +; Tables +(field + name: (identifier) @property) + +(dot_index_expression + field: (identifier) @variable.member) + +(table_constructor + [ + "{" + "}" + ] @constructor) + +; Functions +(parameters + (identifier) @variable.parameter) + +(vararg_expression) @variable.parameter.builtin + +(function_declaration + name: [ + (identifier) @function + (dot_index_expression + field: (identifier) @function) + ]) + +(function_declaration + name: (method_index_expression + method: (identifier) @function.method)) + +(assignment_statement + (variable_list + . + name: [ + (identifier) @function + (dot_index_expression + field: (identifier) @function) + ]) + (expression_list + . + value: (function_definition))) + +(table_constructor + (field + name: (identifier) @function + value: (function_definition))) + +(function_call + name: [ + (identifier) @function.call + (dot_index_expression + field: (identifier) @function.call) + (method_index_expression + method: (identifier) @function.method.call) + ]) + +(function_call + (identifier) @function.builtin + (#any-of? @function.builtin + ; built-in functions in Lua 5.1 + "assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" "load" "loadfile" + "loadstring" "module" "next" "pairs" "pcall" "print" "rawequal" "rawget" "rawlen" "rawset" + "require" "select" "setfenv" "setmetatable" "tonumber" "tostring" "type" "unpack" "xpcall" + "__add" "__band" "__bnot" "__bor" "__bxor" "__call" "__concat" "__div" "__eq" "__gc" "__idiv" + "__index" "__le" "__len" "__lt" "__metatable" "__mod" "__mul" "__name" "__newindex" "__pairs" + "__pow" "__shl" "__shr" "__sub" "__tostring" "__unm")) + +; Others +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[-][-][-]")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[-][-](%s?)@")) + +(hash_bang_line) @keyword.directive + +(number) @number + +(string) @string + +(escape_sequence) @string.escape + +; string.match("123", "%d+") +(function_call + (dot_index_expression + field: (identifier) @_method + (#any-of? @_method "find" "match" "gmatch" "gsub")) + arguments: (arguments + . + (_) + . + (string + content: (string_content) @string.regexp))) + +;("123"):match("%d+") +(function_call + (method_index_expression + method: (identifier) @_method + (#any-of? @_method "find" "match" "gmatch" "gsub")) + arguments: (arguments + . + (string + content: (string_content) @string.regexp))) diff --git a/runtime/queries/lua/indents.scm b/runtime/queries/lua/indents.scm new file mode 100644 index 000000000..84303b8ab --- /dev/null +++ b/runtime/queries/lua/indents.scm @@ -0,0 +1,47 @@ +[ + (function_definition) + (function_declaration) + (field) + (do_statement) + (method_index_expression) + (while_statement) + (repeat_statement) + (if_statement) + "then" + (for_statement) + (return_statement) + (table_constructor) + (arguments) +] @indent.begin + +[ + "end" + "}" + "]]" +] @indent.end + +(")" @indent.end + (#not-has-parent? @indent.end parameters)) + +(return_statement + (expression_list + (function_call))) @indent.dedent + +[ + "end" + "then" + "until" + "}" + ")" + "elseif" + (elseif_statement) + "else" + (else_statement) +] @indent.branch + +(comment) @indent.auto + +(string) @indent.auto + +(ERROR + "function") @indent.begin diff --git a/runtime/queries/lua/injections.scm b/runtime/queries/lua/injections.scm new file mode 100644 index 000000000..e76745f4f --- /dev/null +++ b/runtime/queries/lua/injections.scm @@ -0,0 +1,202 @@ +((function_call + name: [ + (identifier) @_cdef_identifier + (_ + _ + (identifier) @_cdef_identifier) + ] + arguments: (arguments + (string + content: _ @injection.content))) + (#set! injection.language "c") + (#eq? @_cdef_identifier "cdef")) + +((function_call + name: (_) @_vimcmd_identifier + arguments: (arguments + (string + content: _ @injection.content))) + (#set! injection.language "vim") + (#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec2")) + +((function_call + name: (_) @_vimcmd_identifier + arguments: (arguments + (string + content: _ @injection.content) .)) + (#set! injection.language "query") + (#any-of? @_vimcmd_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse")) + +((function_call + name: (_) @_vimcmd_identifier + arguments: (arguments + . + (_) + . + (string + content: _ @_method) + . + (string + content: _ @injection.content))) + (#any-of? @_vimcmd_identifier "vim.rpcrequest" "vim.rpcnotify") + (#eq? @_method "nvim_exec_lua") + (#set! injection.language "lua")) + +; exec_lua [[ ... ]] in functionaltests +((function_call + name: (identifier) @_function + arguments: (arguments + (string + content: (string_content) @injection.content))) + (#eq? @_function "exec_lua") + (#set! injection.language "lua")) + +; vim.api.nvim_create_autocmd("FileType", { command = "injected here" }) +(function_call + name: (_) @_vimcmd_identifier + arguments: (arguments + . + (_) + . + (table_constructor + (field + name: (identifier) @_command + value: (string + content: (_) @injection.content))) .) + ; limit so only 2-argument functions gets matched before pred handle + (#eq? @_vimcmd_identifier "vim.api.nvim_create_autocmd") + (#eq? @_command "command") + (#set! injection.language "vim")) + +(function_call + name: (_) @_user_cmd + arguments: (arguments + . + (_) + . + (string + content: (_) @injection.content) + . + (_) .) + (#eq? @_user_cmd "vim.api.nvim_create_user_command") + (#set! injection.language "vim")) + +(function_call + name: (_) @_user_cmd + arguments: (arguments + . + (_) + . + (_) + . + (string + content: (_) @injection.content) + . + (_) .) + ; Limiting predicate handling to only functions with 4 arguments + (#eq? @_user_cmd "vim.api.nvim_buf_create_user_command") + (#set! injection.language "vim")) + +; rhs highlighting for vim.keymap.set/vim.api.nvim_set_keymap/vim.api.nvim_buf_set_keymap +; (function_call +; name: (_) @_map +; arguments: +; (arguments +; . (_) +; . (_) +; . +; (string +; content: (_) @injection.content)) +; (#any-of? @_map "vim.api.nvim_set_keymap" "vim.keymap.set") +; (#set! injection.language "vim")) +; +; (function_call +; name: (_) @_map +; arguments: +; (arguments +; . (_) +; . (_) +; . (_) +; . +; (string +; content: (_) @injection.content) +; . (_) .) +; (#eq? @_map "vim.api.nvim_buf_set_keymap") +; (#set! injection.language "vim")) +; highlight string as query if starts with `;; query` +(string + content: _ @injection.content + (#lua-match? @injection.content "^%s*;+%s?query") + (#set! injection.language "query")) + +(comment + content: (_) @injection.content + (#lua-match? @injection.content "^[-][%s]*[@|]") + (#set! injection.language "luadoc") + (#offset! @injection.content 0 1 0 0)) + +; string.match("123", "%d+") +(function_call + (dot_index_expression + field: (identifier) @_method + (#any-of? @_method "find" "match" "gmatch" "gsub")) + arguments: (arguments + . + (_) + . + (string + content: (string_content) @injection.content + (#set! injection.language "luap") + (#set! injection.include-children)))) + +;("123"):match("%d+") +(function_call + (method_index_expression + method: (identifier) @_method + (#any-of? @_method "find" "match" "gmatch" "gsub")) + arguments: (arguments + . + (string + content: (string_content) @injection.content + (#set! injection.language "luap") + (#set! injection.include-children)))) + +; string.format("pi = %.2f", 3.14159) +((function_call + (dot_index_expression + field: (identifier) @_method) + arguments: (arguments + . + (string + (string_content) @injection.content))) + (#eq? @_method "format") + (#set! injection.language "printf")) + +; ("pi = %.2f"):format(3.14159) +((function_call + (method_index_expression + table: (_ + (string + (string_content) @injection.content)) + method: (identifier) @_method)) + (#eq? @_method "format") + (#set! injection.language "printf")) + +(comment + content: (_) @injection.content + (#set! injection.language "comment")) + +; vim.filetype.add({ pattern = { ["some lua pattern here"] = "filetype" } }) +((function_call + name: (_) @_filetypeadd_identifier + arguments: (arguments + (table_constructor + (field + name: (_) @_pattern_key + value: (table_constructor + (field + name: (string + content: _ @injection.content))))))) + (#set! injection.language "luap") + (#eq? @_filetypeadd_identifier "vim.filetype.add") + (#eq? @_pattern_key "pattern")) diff --git a/runtime/queries/lua/locals.scm b/runtime/queries/lua/locals.scm new file mode 100644 index 000000000..c4f36e8d4 --- /dev/null +++ b/runtime/queries/lua/locals.scm @@ -0,0 +1,54 @@ +; Scopes +[ + (chunk) + (do_statement) + (while_statement) + (repeat_statement) + (if_statement) + (for_statement) + (function_declaration) + (function_definition) +] @local.scope + +; Definitions +(assignment_statement + (variable_list + (identifier) @local.definition.var)) + +(assignment_statement + (variable_list + (dot_index_expression + . + (_) @local.definition.associated + (identifier) @local.definition.var))) + +((function_declaration + name: (identifier) @local.definition.function) + (#set! definition.function.scope "parent")) + +((function_declaration + name: (dot_index_expression + . + (_) @local.definition.associated + (identifier) @local.definition.function)) + (#set! definition.method.scope "parent")) + +((function_declaration + name: (method_index_expression + . + (_) @local.definition.associated + (identifier) @local.definition.method)) + (#set! definition.method.scope "parent")) + +(for_generic_clause + (variable_list + (identifier) @local.definition.var)) + +(for_numeric_clause + name: (identifier) @local.definition.var) + +(parameters + (identifier) @local.definition.parameter) + +; References +(identifier) @local.reference diff --git a/runtime/queries/luadoc/highlights.scm b/runtime/queries/luadoc/highlights.scm new file mode 100644 index 000000000..1649e5d9b --- /dev/null +++ b/runtime/queries/luadoc/highlights.scm @@ -0,0 +1,198 @@ +; Keywords +[ + "@module" + "@package" +] @keyword.import @nospell + +[ + "@class" + "@type" + "@param" + "@alias" + "@field" + "@generic" + "@vararg" + "@diagnostic" + "@cast" + "@deprecated" + "@meta" + "@source" + "@version" + "@operator" + "@nodiscard" + "@cast" + "@overload" + "@enum" + "@language" + "@see" + "@as" + "extends" + (diagnostic_identifier) +] @keyword @nospell + +"@async" @keyword.coroutine @nospell + +(language_injection + "@language" + (identifier) @keyword @nospell) + +(function_type + [ + "fun" + "function" + ] @keyword.function @nospell) + +(source_annotation + filename: (identifier) @string.special.path @nospell + extension: (identifier) @string.special.path @nospell) + +(version_annotation + version: _ @constant.builtin @nospell) + +"@return" @keyword.return @nospell + +; Qualifiers +[ + "public" + "protected" + "private" + "package" + "@public" + "@protected" + "@private" + "(exact)" + "(key)" +] @keyword.modifier @nospell + +; Variables +(identifier) @variable @nospell + +[ + "..." + "self" +] @variable.builtin @nospell + +; Macros +(alias_annotation + (identifier) @function.macro @nospell) + +; Parameters +(param_annotation + (identifier) @variable.parameter @nospell) + +(parameter + (identifier) @variable.parameter @nospell) + +; Fields +(field_annotation + (identifier) @variable.member @nospell) + +(table_literal_type + field: (identifier) @variable.member @nospell) + +(member_type + [ + "#" + "." + ] + . + (identifier) @variable.member @nospell) + +(member_type + (identifier) @module @nospell) + +(member_type + (identifier) @type @nospell .) + +; Types +(table_type + "table" @type.builtin @nospell) + +(builtin_type) @type.builtin @nospell + +(class_annotation + (identifier) @type @nospell) + +(enum_annotation + (identifier) @type @nospell) + +((array_type + [ + "[" + "]" + ] @type) + (#set! priority 105)) + +(type) @type + +; Operators +[ + "|" + "+" + "-" +] @operator + +; Literals +[ + (string) + (literal_type) + "`" +] @string + +(module_annotation + (string) @module @nospell) + +[ + (number) + (numeric_literal_type) +] @number + +; Punctuation +[ + "[" + "]" + "[[" + "]]" + "[=[" + "]=]" +] @punctuation.bracket + +[ + "{" + "}" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "<" + ">" +] @punctuation.bracket + +[ + "," + "." + "#" + ":" +] @punctuation.delimiter + +[ + "@" + "?" +] @punctuation.special + +; Comments +(comment) @comment @spell + +(at_comment + (identifier) @type @nospell + (_) @comment @spell) + +(class_at_comment + (identifier) @type @nospell + ("extends"? + (identifier)? @type @nospell) + (_) @comment @spell) diff --git a/runtime/queries/luap/highlights.scm b/runtime/queries/luap/highlights.scm new file mode 100644 index 000000000..40d2bd37b --- /dev/null +++ b/runtime/queries/luap/highlights.scm @@ -0,0 +1,45 @@ +[ + (anchor_begin) + (anchor_end) +] @punctuation.delimiter + +(pattern + (character + "." @variable.builtin)) + +[ + "[" + "]" + "(" + ")" +] @punctuation.bracket + +[ + (zero_or_more) + (shortest_zero_or_more) + (one_or_more) + (zero_or_one) +] @operator + +(range + from: (character) @constant + "-" @operator + to: (character) @constant) + +(set + (character) @constant) + +(negated_set + (character) @constant) + +(class) @string.escape + +(class + "%" @string.regexp + (escape_char) @string.regexp) + +(negated_set + "^" @operator) + +(balanced_match + (character) @variable.parameter) diff --git a/runtime/queries/luau/folds.scm b/runtime/queries/luau/folds.scm new file mode 100644 index 000000000..8ddaf9476 --- /dev/null +++ b/runtime/queries/luau/folds.scm @@ -0,0 +1,3 @@ +; inherits: lua + +(object_type) @fold diff --git a/runtime/queries/luau/highlights.scm b/runtime/queries/luau/highlights.scm new file mode 100644 index 000000000..f6f64b30c --- /dev/null +++ b/runtime/queries/luau/highlights.scm @@ -0,0 +1,305 @@ +; Preproc +(hash_bang_line) @keyword.directive + +; Keywords +"return" @keyword.return + +"local" @keyword + +"type" @keyword.type + +"export" @keyword.import + +(do_statement + [ + "do" + "end" + ] @keyword) + +(while_statement + [ + "while" + "do" + "end" + ] @keyword.repeat) + +(repeat_statement + [ + "repeat" + "until" + ] @keyword.repeat) + +[ + (break_statement) + (continue_statement) +] @keyword.repeat + +(if_statement + [ + "if" + "elseif" + "else" + "then" + "end" + ] @keyword.conditional) + +(if_expression + [ + "if" + "then" + ] @keyword.conditional) + +(elseif_statement + [ + "elseif" + "then" + "end" + ] @keyword.conditional) + +(elseif_clause + [ + "elseif" + "then" + ] @keyword.conditional) + +(else_statement + [ + "else" + "end" + ] @keyword.conditional) + +(else_clause + "else" @keyword.conditional) + +(for_statement + [ + "for" + "do" + "end" + ] @keyword.repeat) + +(function_declaration + [ + "function" + "end" + ] @keyword.function) + +(function_definition + [ + "function" + "end" + ] @keyword.function) + +; Operators +[ + "and" + "not" + "or" + "in" + "typeof" +] @keyword.operator + +[ + "+" + "-" + "*" + "/" + "%" + "^" + "#" + "==" + "~=" + "<=" + ">=" + "<" + ">" + "=" + "&" + "|" + "?" + "//" + ".." + "+=" + "-=" + "*=" + "/=" + "%=" + "^=" + "..=" +] @operator + +; Variables +(identifier) @variable + +; Types +(type/identifier) @type + +(generic_type + (identifier) @type) + +(builtin_type) @type.builtin + +((identifier) @type + (#lua-match? @type "^[A-Z]")) + +; Typedefs +(type_definition + "type" + . + (type) @type.definition + "=") + +; Constants +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]+$")) + +; Builtins +((identifier) @constant.builtin + (#eq? @constant.builtin "_VERSION")) + +((identifier) @variable.builtin + (#eq? @variable.builtin "self")) + +"..." @variable.builtin + +((identifier) @module.builtin + (#any-of? @module.builtin "_G" "debug" "io" "jit" "math" "os" "package" "string" "table" "utf8")) + +((identifier) @keyword.coroutine + (#eq? @keyword.coroutine "coroutine")) + +; Tables +(field + name: (identifier) @variable.member) + +(dot_index_expression + field: (identifier) @variable.member) + +(object_type + (identifier) @variable.member) + +(table_constructor + [ + "{" + "}" + ] @constructor) + +; Functions +(parameter + . + (identifier) @variable.parameter) + +(function_type + (identifier) @variable.parameter) + +(function_call + name: (identifier) @function.call) + +(function_declaration + name: (identifier) @function) + +(function_call + name: (dot_index_expression + field: (identifier) @function.call)) + +(function_declaration + name: (dot_index_expression + field: (identifier) @function)) + +(method_index_expression + method: (identifier) @function.method.call) + +(function_call + (identifier) @function.builtin + (#any-of? @function.builtin + ; built-in functions in Lua 5.1 + "assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" "load" "loadfile" + "loadstring" "module" "next" "pairs" "pcall" "print" "rawequal" "rawget" "rawlen" "rawset" + "require" "select" "setfenv" "setmetatable" "tonumber" "tostring" "type" "unpack" "xpcall" + "typeof" "__add" "__band" "__bnot" "__bor" "__bxor" "__call" "__concat" "__div" "__eq" "__gc" + "__idiv" "__index" "__le" "__len" "__lt" "__metatable" "__mod" "__mul" "__name" "__newindex" + "__pairs" "__pow" "__shl" "__shr" "__sub" "__tostring" "__unm")) + +; Literals +(number) @number + +(string) @string + +(nil) @constant.builtin + +(vararg_expression) @variable.builtin + +[ + (false) + (true) +] @boolean + +; Punctuations +[ + ";" + ":" + "::" + "," + "." + "->" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(variable_list + attribute: (attribute + ([ + "<" + ">" + ] @punctuation.bracket + (identifier) @attribute))) + +(generic_type + [ + "<" + ">" + ] @punctuation.bracket) + +(generic_type_list + [ + "<" + ">" + ] @punctuation.bracket) + +; Comments +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[-][-][-]")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[-][-](%s?)@")) + +; string.match("123", "%d+") +(function_call + (dot_index_expression + field: (identifier) @_method + (#any-of? @_method "find" "format" "match" "gmatch" "gsub")) + arguments: (arguments + . + (_) + . + (string + content: _ @string.regexp))) + +; ("123"):match("%d+") +(function_call + (method_index_expression + method: (identifier) @_method + (#any-of? @_method "find" "format" "match" "gmatch" "gsub")) + arguments: (arguments + . + (string + content: _ @string.regexp))) diff --git a/runtime/queries/luau/indents.scm b/runtime/queries/luau/indents.scm new file mode 100644 index 000000000..f0af4dd33 --- /dev/null +++ b/runtime/queries/luau/indents.scm @@ -0,0 +1,3 @@ +; inherits: lua + +(object_type) @indent.begin diff --git a/runtime/queries/luau/injections.scm b/runtime/queries/luau/injections.scm new file mode 100644 index 000000000..558791520 --- /dev/null +++ b/runtime/queries/luau/injections.scm @@ -0,0 +1,44 @@ +((function_call + name: [ + (identifier) @_cdef_identifier + (_ + _ + (identifier) @_cdef_identifier) + ] + arguments: (arguments + (string + content: _ @injection.content))) + (#eq? @_cdef_identifier "cdef") + (#set! injection.language "c")) + +((comment) @injection.content + (#lua-match? @injection.content "[-][-][-][%s]*@") + (#offset! @injection.content 0 3 0 0) + (#set! injection.language "luadoc")) + +; string.match("123", "%d+") +(function_call + (dot_index_expression + field: (identifier) @_method + (#any-of? @_method "find" "format" "match" "gmatch" "gsub")) + arguments: (arguments + . + (_) + . + (string + content: _ @injection.content)) + (#set! injection.language "luap")) + +; ("123"):match("%d+") +(function_call + (method_index_expression + method: (identifier) @_method + (#any-of? @_method "find" "format" "match" "gmatch" "gsub")) + arguments: (arguments + . + (string + content: _ @injection.content)) + (#set! injection.language "luap")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/luau/locals.scm b/runtime/queries/luau/locals.scm new file mode 100644 index 000000000..d5420b4c8 --- /dev/null +++ b/runtime/queries/luau/locals.scm @@ -0,0 +1,54 @@ +; Scopes +[ + (chunk) + (do_statement) + (while_statement) + (repeat_statement) + (if_statement) + (for_statement) + (function_declaration) + (function_definition) +] @local.scope + +; References +(identifier) @local.reference + +; Definitions +(assignment_statement + (variable_list + (identifier) @local.definition.var)) + +(assignment_statement + (variable_list + (dot_index_expression + . + (_) @local.definition.associated + (identifier) @local.definition.var))) + +((function_declaration + name: (identifier) @local.definition.function) + (#set! definition.function.scope "parent")) + +((function_declaration + name: (dot_index_expression + . + (_) @local.definition.associated + (identifier) @local.definition.function)) + (#set! definition.method.scope "parent")) + +((function_declaration + name: (method_index_expression + . + (_) @local.definition.associated + (identifier) @local.definition.method)) + (#set! definition.method.scope "parent")) + +(for_generic_clause + (variable_list + (identifier) @local.definition.var)) + +(for_numeric_clause + name: (identifier) @local.definition.var) + +(parameter + (identifier) @local.definition.parameter) diff --git a/runtime/queries/m68k/folds.scm b/runtime/queries/m68k/folds.scm new file mode 100644 index 000000000..1dd8eaf11 --- /dev/null +++ b/runtime/queries/m68k/folds.scm @@ -0,0 +1 @@ +(element_list) @fold diff --git a/runtime/queries/m68k/highlights.scm b/runtime/queries/m68k/highlights.scm new file mode 100644 index 000000000..72a5504d6 --- /dev/null +++ b/runtime/queries/m68k/highlights.scm @@ -0,0 +1,81 @@ +(symbol) @variable + +(label + name: (symbol) @label) + +[ + (instruction_mnemonic) + (directive_mnemonic) +] @function.builtin + +(include + (directive_mnemonic) @keyword.import) + +(include_bin + (directive_mnemonic) @keyword.import) + +(include_dir + (directive_mnemonic) @keyword.import) + +(size) @attribute + +(macro_definition + name: (symbol) @function.macro) + +(macro_call + name: (symbol) @function.macro) + +(string_literal) @string + +(path) @string.special.path + +[ + (decimal_literal) + (hexadecimal_literal) + (octal_literal) + (binary_literal) +] @number + +[ + (reptn) + (carg) + (narg) + (macro_arg) +] @variable.builtin + +[ + (control_mnemonic) + (address_register) + (data_register) + (float_register) + (named_register) +] @keyword + +(repeat + (control_mnemonic) @keyword.repeat) + +(conditional + (control_mnemonic) @keyword.conditional) + +(comment) @comment @spell + +[ + (operator) + "=" + "#" +] @operator + +[ + "." + "," + "/" + "-" +] @punctuation.delimiter + +[ + "(" + ")" + ")+" +] @punctuation.bracket + +(section) @module diff --git a/runtime/queries/m68k/injections.scm b/runtime/queries/m68k/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/m68k/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/m68k/locals.scm b/runtime/queries/m68k/locals.scm new file mode 100644 index 000000000..54e948a4b --- /dev/null +++ b/runtime/queries/m68k/locals.scm @@ -0,0 +1,26 @@ +(macro_definition + name: (symbol) @local.definition.macro) + +(symbol_assignment + name: (symbol) @local.definition.var) + +(label + name: (symbol) @local.definition.constant) + +(symbol_definition + name: (symbol) @local.definition.constant) + +(offset_definition + name: (symbol) @local.definition.constant) + +(register_definition + name: (symbol) @local.definition.constant) + +(register_list_definition + name: (symbol) @local.definition.constant) + +(external_reference + symbols: (symbol_list + (symbol) @local.definition.import)) + +(symbol) @local.reference diff --git a/runtime/queries/make/folds.scm b/runtime/queries/make/folds.scm new file mode 100644 index 000000000..c7f87ac16 --- /dev/null +++ b/runtime/queries/make/folds.scm @@ -0,0 +1,6 @@ +([ + (conditional) + (rule) + (define_directive) +] @fold + (#trim! @fold)) diff --git a/runtime/queries/make/highlights.scm b/runtime/queries/make/highlights.scm new file mode 100644 index 000000000..afdfbe336 --- /dev/null +++ b/runtime/queries/make/highlights.scm @@ -0,0 +1,170 @@ +(comment) @comment @spell + +(conditional + (_ + [ + "ifeq" + "else" + "ifneq" + "ifdef" + "ifndef" + ] @keyword.conditional) + "endif" @keyword.conditional) + +(rule + (targets + (word) @function)) + +(rule + (targets) @_target + (prerequisites + (word) @function + (#eq? @_target ".PHONY"))) + +(rule + (targets + (word) @function.builtin + (#any-of? @function.builtin + ".DEFAULT" ".SUFFIXES" ".DELETE_ON_ERROR" ".EXPORT_ALL_VARIABLES" ".IGNORE" ".INTERMEDIATE" + ".LOW_RESOLUTION_TIME" ".NOTPARALLEL" ".ONESHELL" ".PHONY" ".POSIX" ".PRECIOUS" ".SECONDARY" + ".SECONDEXPANSION" ".SILENT" ".SUFFIXES"))) + +(rule + [ + "&:" + ":" + "::" + "|" + ] @operator) + +[ + "export" + "unexport" +] @keyword.import + +(override_directive + "override" @keyword) + +(include_directive + [ + "include" + "-include" + ] @keyword.import + filenames: (list + (word) @string.special.path)) + +(variable_assignment + name: (word) @string.special.symbol + [ + "?=" + ":=" + "::=" + ; ":::=" + "+=" + "=" + ] @operator) + +(shell_assignment + name: (word) @string.special.symbol + "!=" @operator) + +(define_directive + "define" @keyword + name: (word) @string.special.symbol + [ + "=" + ":=" + "::=" + ; ":::=" + "?=" + "!=" + ]? @operator + "endef" @keyword) + +(variable_assignment + (word) @variable.builtin + (#any-of? @variable.builtin + ".DEFAULT_GOAL" ".EXTRA_PREREQS" ".FEATURES" ".INCLUDE_DIRS" ".RECIPEPREFIX" ".SHELLFLAGS" + ".VARIABLES" "MAKEARGS" "MAKEFILE_LIST" "MAKEFLAGS" "MAKE_RESTARTS" "MAKE_TERMERR" + "MAKE_TERMOUT" "SHELL")) + +; Use string to match bash +(variable_reference + (word) @string) @operator + +(shell_function + [ + "$" + "(" + ")" + ] @operator + "shell" @function.builtin) + +(function_call + [ + "$" + "(" + ")" + ] @operator) + +(substitution_reference + [ + "$" + "(" + ")" + ] @operator) + +(automatic_variable + "$" + _ @character.special + (#set! priority 105)) + +(automatic_variable + [ + "$" + "(" + ")" + ] @operator + (#set! priority 105)) + +(recipe_line + "@" @character.special) + +(function_call + [ + "subst" + "patsubst" + "strip" + "findstring" + "filter" + "filter-out" + "sort" + "word" + "words" + "wordlist" + "firstword" + "lastword" + "dir" + "notdir" + "suffix" + "basename" + "addsuffix" + "addprefix" + "join" + "wildcard" + "realpath" + "abspath" + "error" + "warning" + "info" + "origin" + "flavor" + "foreach" + "if" + "or" + "and" + "call" + "eval" + "file" + "value" + ] @function.builtin) diff --git a/runtime/queries/make/injections.scm b/runtime/queries/make/injections.scm new file mode 100644 index 000000000..c9c09be5d --- /dev/null +++ b/runtime/queries/make/injections.scm @@ -0,0 +1,8 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((shell_text) @injection.content + (#set! injection.language "bash")) + +((shell_command) @injection.content + (#set! injection.language "bash")) diff --git a/runtime/queries/markdown/folds.scm b/runtime/queries/markdown/folds.scm new file mode 100644 index 000000000..2bcfd442d --- /dev/null +++ b/runtime/queries/markdown/folds.scm @@ -0,0 +1,12 @@ +([ + (fenced_code_block) + (indented_code_block) + (list_item + (list)) + (section) +] @fold + (#trim! @fold)) + +(section + (list) @fold + (#trim! @fold)) diff --git a/runtime/queries/markdown/highlights.scm b/runtime/queries/markdown/highlights.scm new file mode 100644 index 000000000..2a6ad1968 --- /dev/null +++ b/runtime/queries/markdown/highlights.scm @@ -0,0 +1,123 @@ +;From MDeiml/tree-sitter-markdown & Helix +(setext_heading + (paragraph) @markup.heading.1 + (setext_h1_underline) @markup.heading.1) + +(setext_heading + (paragraph) @markup.heading.2 + (setext_h2_underline) @markup.heading.2) + +(atx_heading + (atx_h1_marker)) @markup.heading.1 + +(atx_heading + (atx_h2_marker)) @markup.heading.2 + +(atx_heading + (atx_h3_marker)) @markup.heading.3 + +(atx_heading + (atx_h4_marker)) @markup.heading.4 + +(atx_heading + (atx_h5_marker)) @markup.heading.5 + +(atx_heading + (atx_h6_marker)) @markup.heading.6 + +(info_string) @label + +(pipe_table_header + (pipe_table_cell) @markup.heading) + +(pipe_table_header + "|" @punctuation.special) + +(pipe_table_row + "|" @punctuation.special) + +(pipe_table_delimiter_row + "|" @punctuation.special) + +(pipe_table_delimiter_cell) @punctuation.special + +; Code blocks (conceal backticks and language annotation) +(indented_code_block) @markup.raw.block + +((fenced_code_block) @markup.raw.block + (#set! priority 90)) + +(fenced_code_block + (fenced_code_block_delimiter) @markup.raw.block + (#set! conceal "") + (#set! conceal_lines "")) + +(fenced_code_block + (info_string + (language) @label + (#set! conceal "") + (#set! conceal_lines ""))) + +(link_destination) @markup.link.url + +[ + (link_title) + (link_label) +] @markup.link.label + +((link_label) + . + ":" @punctuation.delimiter) + +[ + (list_marker_plus) + (list_marker_minus) + (list_marker_star) + (list_marker_dot) + (list_marker_parenthesis) +] @markup.list + +; NOTE: The following has been commented out due to issues with spaces in the +; list marker nodes generated by the parser. If those spaces ever get captured +; by a different node (e.g. block_continuation) we can safely re-add these +; conceals. +; ;; Conceal bullet points +; ([(list_marker_plus) (list_marker_star)] +; @punctuation.special +; (#offset! @punctuation.special 0 0 0 -1) +; (#set! conceal "•")) +; ([(list_marker_plus) (list_marker_star)] +; @punctuation.special +; (#any-of? @punctuation.special "+" "*") +; (#set! conceal "•")) +; ((list_marker_minus) +; @punctuation.special +; (#offset! @punctuation.special 0 0 0 -1) +; (#set! conceal "—")) +; ((list_marker_minus) +; @punctuation.special +; (#eq? @punctuation.special "-") +; (#set! conceal "—")) +(thematic_break) @punctuation.special + +(task_list_marker_unchecked) @markup.list.unchecked + +(task_list_marker_checked) @markup.list.checked + +((block_quote) @markup.quote + (#set! priority 90)) + +([ + (plus_metadata) + (minus_metadata) +] @keyword.directive + (#set! priority 90)) + +[ + (block_continuation) + (block_quote_marker) +] @punctuation.special + +(backslash_escape) @string.escape + +(inline) @spell diff --git a/runtime/queries/markdown/indents.scm b/runtime/queries/markdown/indents.scm new file mode 100644 index 000000000..90c52d3d0 --- /dev/null +++ b/runtime/queries/markdown/indents.scm @@ -0,0 +1 @@ +(list_item) @indent.auto diff --git a/runtime/queries/markdown/injections.scm b/runtime/queries/markdown/injections.scm new file mode 100644 index 000000000..8ed205296 --- /dev/null +++ b/runtime/queries/markdown/injections.scm @@ -0,0 +1,26 @@ +(fenced_code_block + (info_string + (language) @_lang) + (code_fence_content) @injection.content + (#set-lang-from-info-string! @_lang)) + +((html_block) @injection.content + (#set! injection.language "html") + (#set! injection.combined) + (#set! injection.include-children)) + +((minus_metadata) @injection.content + (#set! injection.language "yaml") + (#offset! @injection.content 1 0 -1 0) + (#set! injection.include-children)) + +((plus_metadata) @injection.content + (#set! injection.language "toml") + (#offset! @injection.content 1 0 -1 0) + (#set! injection.include-children)) + +([ + (inline) + (pipe_table_cell) +] @injection.content + (#set! injection.language "markdown_inline")) diff --git a/runtime/queries/markdown_inline/highlights.scm b/runtime/queries/markdown_inline/highlights.scm new file mode 100644 index 000000000..5fb9e911d --- /dev/null +++ b/runtime/queries/markdown_inline/highlights.scm @@ -0,0 +1,123 @@ +; From MDeiml/tree-sitter-markdown +(code_span) @markup.raw @nospell + +(emphasis) @markup.italic + +(strong_emphasis) @markup.strong + +(strikethrough) @markup.strikethrough + +(shortcut_link + (link_text) @nospell) + +[ + (backslash_escape) + (hard_line_break) +] @string.escape + +; Conceal codeblock and text style markers +([ + (code_span_delimiter) + (emphasis_delimiter) +] @conceal + (#set! conceal "")) + +; Conceal inline links +(inline_link + [ + "[" + "]" + "(" + (link_destination) + ")" + ] @markup.link + (#set! conceal "")) + +[ + (link_label) + (link_text) + (link_title) + (image_description) +] @markup.link.label + +((inline_link + (link_destination) @_url) @_label + (#set! @_label url @_url)) + +((image + (link_destination) @_url) @_label + (#set! @_label url @_url)) + +; Conceal image links +(image + [ + "!" + "[" + "]" + "(" + (link_destination) + ")" + ] @markup.link + (#set! conceal "")) + +; Conceal full reference links +(full_reference_link + [ + "[" + "]" + (link_label) + ] @markup.link + (#set! conceal "")) + +; Conceal collapsed reference links +(collapsed_reference_link + [ + "[" + "]" + ] @markup.link + (#set! conceal "")) + +; Conceal shortcut links +(shortcut_link + [ + "[" + "]" + ] @markup.link + (#set! conceal "")) + +[ + (link_destination) + (uri_autolink) + (email_autolink) +] @markup.link.url @nospell + +((uri_autolink) @_url + (#offset! @_url 0 1 0 -1) + (#set! @_url url @_url)) + +(entity_reference) @nospell + +; Replace common HTML entities. +((entity_reference) @character.special + (#eq? @character.special " ") + (#set! conceal " ")) + +((entity_reference) @character.special + (#eq? @character.special "<") + (#set! conceal "<")) + +((entity_reference) @character.special + (#eq? @character.special ">") + (#set! conceal ">")) + +((entity_reference) @character.special + (#eq? @character.special "&") + (#set! conceal "&")) + +((entity_reference) @character.special + (#eq? @character.special """) + (#set! conceal "\"")) + +((entity_reference) @character.special + (#any-of? @character.special " " " ") + (#set! conceal " ")) diff --git a/runtime/queries/markdown_inline/injections.scm b/runtime/queries/markdown_inline/injections.scm new file mode 100644 index 000000000..6448b77c1 --- /dev/null +++ b/runtime/queries/markdown_inline/injections.scm @@ -0,0 +1,7 @@ +((html_tag) @injection.content + (#set! injection.language "html") + (#set! injection.combined)) + +((latex_block) @injection.content + (#set! injection.language "latex") + (#set! injection.include-children)) diff --git a/runtime/queries/matlab/folds.scm b/runtime/queries/matlab/folds.scm new file mode 100644 index 000000000..83008b3d7 --- /dev/null +++ b/runtime/queries/matlab/folds.scm @@ -0,0 +1,13 @@ +[ + (if_statement) + (for_statement) + (while_statement) + (switch_statement) + (try_statement) + (function_definition) + (class_definition) + (enumeration) + (events) + (methods) + (properties) +] @fold diff --git a/runtime/queries/matlab/highlights.scm b/runtime/queries/matlab/highlights.scm new file mode 100644 index 000000000..d2ab6053e --- /dev/null +++ b/runtime/queries/matlab/highlights.scm @@ -0,0 +1,216 @@ +; Includes +((command_name) @keyword.import + (#eq? @keyword.import "import")) + +; Keywords +[ + "arguments" + "end" + "events" + "global" + "methods" + "persistent" + "properties" +] @keyword + +"enumeration" @keyword.type + +(class_definition + [ + "classdef" + "end" + ] @keyword.type) + +; Conditionals +(if_statement + [ + "if" + "end" + ] @keyword.conditional) + +(elseif_clause + "elseif" @keyword.conditional) + +(else_clause + "else" @keyword.conditional) + +(switch_statement + [ + "switch" + "end" + ] @keyword.conditional) + +(case_clause + "case" @keyword.conditional) + +(otherwise_clause + "otherwise" @keyword.conditional) + +(break_statement) @keyword.conditional + +; Repeats +(for_statement + [ + "for" + "parfor" + "end" + ] @keyword.repeat) + +(while_statement + [ + "while" + "end" + ] @keyword.repeat) + +(continue_statement) @keyword.repeat + +; Exceptions +(try_statement + [ + "try" + "end" + ] @keyword.exception) + +(catch_clause + "catch" @keyword.exception) + +; Variables +(identifier) @variable + +; Constants +(events + (identifier) @constant) + +(attribute + (identifier) @constant) + +"~" @constant.builtin + +; Fields/Properties +(field_expression + field: (identifier) @variable.member) + +(superclass + "." + (identifier) @variable.member) + +(property_name + "." + (identifier) @variable.member) + +(property + name: (identifier) @variable.member) + +; Types +(class_definition + name: (identifier) @type) + +(attributes + (identifier) @constant) + +(enum + . + (identifier) @type) + +((identifier) @type + (#lua-match? @type "^_*[A-Z][a-zA-Z0-9_]+$")) + +; Functions +(function_definition + "function" @keyword.function + name: (identifier) @function + [ + "end" + "endfunction" + ]? @keyword.function) + +(function_signature + name: (identifier) @function) + +(function_call + name: (identifier) @function.call) + +(handle_operator + (identifier) @function) + +(validation_functions + (identifier) @function) + +(command + (command_name) @function.call) + +(command_argument) @variable.parameter + +(return_statement) @keyword.return + +; Parameters +(function_arguments + (identifier) @variable.parameter) + +; Punctuation +[ + ";" + "," + "." +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; Operators +[ + "+" + ".+" + "-" + ".*" + "*" + ".*" + "/" + "./" + "\\" + ".\\" + "^" + ".^" + "'" + ".'" + "|" + "&" + "?" + "@" + "<" + "<=" + ">" + ">=" + "==" + "~=" + "=" + "&&" + "||" + ":" +] @operator + +; Literals +(string) @string + +(escape_sequence) @string.escape + +(formatting_sequence) @string.special + +(number) @number + +(boolean) @boolean + +; Comments +[ + (comment) + (line_continuation) +] @comment @spell + +((comment) @keyword.directive + (#lua-match? @keyword.directive "^%%%% ")) diff --git a/runtime/queries/matlab/indents.scm b/runtime/queries/matlab/indents.scm new file mode 100644 index 000000000..d446f45df --- /dev/null +++ b/runtime/queries/matlab/indents.scm @@ -0,0 +1,40 @@ +"end" @indent.end @indent.branch + +[ + (arguments_statement) + (if_statement) + (for_statement) + (while_statement) + (switch_statement) + (try_statement) + (function_definition) + (class_definition) + (enumeration) + (events) + (methods) + (properties) +] @indent.begin + +[ + "elseif" + "else" + "case" + "otherwise" + "catch" +] @indent.branch + +((matrix + (row) @indent.align) + (#set! indent.open_delimiter "[") + (#set! indent.close_delimiter "]")) + +((cell + (row) @indent.align) + (#set! indent.open_delimiter "{") + (#set! indent.close_delimiter "}")) + +((parenthesis) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +(comment) @indent.auto diff --git a/runtime/queries/matlab/injections.scm b/runtime/queries/matlab/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/matlab/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/matlab/locals.scm b/runtime/queries/matlab/locals.scm new file mode 100644 index 000000000..366c82027 --- /dev/null +++ b/runtime/queries/matlab/locals.scm @@ -0,0 +1,33 @@ +; References +(identifier) @local.reference + +; Definitions +(function_definition + name: (identifier) @local.definition.function + (function_arguments + (identifier)* @local.definition.parameter + ("," + (identifier) @local.definition.parameter)*)?) @local.scope + +(assignment + left: (identifier) @local.definition.var) + +(multioutput_variable + (identifier) @local.definition.var) + +(iterator + . + (identifier) @local.definition.var) + +(lambda + (arguments + (identifier) @local.definition.parameter)) + +(global_operator + (identifier) @local.definition.var) + +(persistent_operator + (identifier) @local.definition.var) + +(catch_clause + (identifier) @local.definition) diff --git a/runtime/queries/menhir/highlights.scm b/runtime/queries/menhir/highlights.scm new file mode 100644 index 000000000..022fda82e --- /dev/null +++ b/runtime/queries/menhir/highlights.scm @@ -0,0 +1,73 @@ +[ + "%parameter" + "%token" + "%type" + "%start" + "%attribute" + "%left" + "%right" + "%nonassoc" + "%public" + "%inline" + "%prec" +] @keyword + +"%on_error_reduce" @keyword.exception + +"let" @keyword.function + +[ + (equality_symbol) + ":" + "|" + ";" + "," +] @punctuation.delimiter + +[ + "=" + "~" +] @operator + +(modifier) @operator + +"_" @character.special + +[ + "<" + ">" + "{" + "}" + "%{" + "%}" + "%%" +] @punctuation.special + +[ + "(" + ")" +] @punctuation.bracket + +(old_rule + (symbol) @function) + +(new_rule + (lid) @function) + +(precedence + (symbol) @variable.parameter) + +(funcall) @function.call + +; Not very accurant but does a decent job +(uid) @constant + +(ocaml_type) @type + +(ocaml) @none + +[ + (comment) + (line_comment) + (ocaml_comment) +] @comment @spell diff --git a/runtime/queries/menhir/injections.scm b/runtime/queries/menhir/injections.scm new file mode 100644 index 000000000..16a3f8157 --- /dev/null +++ b/runtime/queries/menhir/injections.scm @@ -0,0 +1,9 @@ +([ + (comment) + (line_comment) + (ocaml_comment) +] @injection.content + (#set! injection.language "comment")) + +((ocaml) @injection.content + (#set! injection.language "ocaml")) diff --git a/runtime/queries/mermaid/folds.scm b/runtime/queries/mermaid/folds.scm new file mode 100644 index 000000000..5f28abf5b --- /dev/null +++ b/runtime/queries/mermaid/folds.scm @@ -0,0 +1,10 @@ +[ + (diagram_sequence) + (diagram_class) + (diagram_state) + (diagram_gantt) + (diagram_pie) + (diagram_er) + (diagram_flow) + (flow_stmt_subgraph) +] @fold diff --git a/runtime/queries/mermaid/highlights.scm b/runtime/queries/mermaid/highlights.scm new file mode 100644 index 000000000..2b7b56374 --- /dev/null +++ b/runtime/queries/mermaid/highlights.scm @@ -0,0 +1,249 @@ +; adapted from https://github.com/monaqa/tree-sitter-mermaid +[ + "sequenceDiagram" + "classDiagram" + "classDiagram-v2" + "stateDiagram" + "stateDiagram-v2" + "gantt" + "pie" + "flowchart" + "erdiagram" + "participant" + "as" + "activate" + "deactivate" + "note " + "over" + "link" + "links" + ; "left of" + ; "right of" + "properties" + "details" + "title" + "loop" + "rect" + "opt" + "alt" + "else" + "par" + "and" + "end" + (sequence_stmt_autonumber) + (note_placement_left) + (note_placement_right) + "class" + "state " + "dateformat" + "inclusiveenddates" + "topaxis" + "axisformat" + "includes" + "excludes" + "todaymarker" + "title" + "section" + "direction" + "subgraph" +] @keyword + +(comment) @comment @spell + +[ + ":" + (sequence_signal_plus_sign) + (sequence_signal_minus_sign) + (class_visibility_public) + (class_visibility_private) + (class_visibility_protected) + (class_visibility_internal) + (state_division) +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" +] @punctuation.bracket + +[ + "-->" + (solid_arrow) + (dotted_arrow) + (solid_open_arrow) + (dotted_open_arrow) + (solid_cross) + (dotted_cross) + (solid_point) + (dotted_point) +] @operator + +[ + (class_reltype_aggregation) + (class_reltype_extension) + (class_reltype_composition) + (class_reltype_dependency) + (class_linetype_solid) + (class_linetype_dotted) + "&" +] @operator + +(sequence_actor) @variable.member + +(class_name) @variable.member + +(state_name) @variable.member + +(gantt_task_text) @variable.member + +[ + (class_annotation_line) + (class_stmt_annotation) + (class_generics) + (state_annotation_fork) + (state_annotation_join) + (state_annotation_choice) +] @attribute + +(directive) @keyword.import + +(pie_label) @string + +(pie_value) @number.float + +[ + (flowchart_direction_lr) + (flowchart_direction_rl) + (flowchart_direction_tb) + (flowchart_direction_bt) +] @constant + +(flow_vertex_id) @variable.member + +[ + (flow_link_arrow) + (flow_link_arrow_start) +] @operator + +(flow_link_arrowtext + "|" @punctuation.bracket) + +(flow_vertex_square + [ + "[" + "]" + ] @punctuation.bracket) + +(flow_vertex_circle + [ + "((" + "))" + ] @punctuation.bracket) + +(flow_vertex_ellipse + [ + "(-" + "-)" + ] @punctuation.bracket) + +(flow_vertex_stadium + [ + "([" + "])" + ] @punctuation.bracket) + +(flow_vertex_subroutine + [ + "[[" + "]]" + ] @punctuation.bracket) + +(flow_vertex_rect + [ + "[|" + "|]" + ] @punctuation.bracket) + +(flow_vertex_cylinder + [ + "[(" + ")]" + ] @punctuation.bracket) + +(flow_vertex_round + [ + "(" + ")" + ] @punctuation.bracket) + +(flow_vertex_diamond + [ + "{" + "}" + ] @punctuation.bracket) + +(flow_vertex_hexagon + [ + "{{" + "}}" + ] @punctuation.bracket) + +(flow_vertex_odd + [ + ">" + "]" + ] @punctuation.bracket) + +(flow_vertex_trapezoid + [ + "[/" + "\\]" + ] @punctuation.bracket) + +(flow_vertex_inv_trapezoid + [ + "[\\" + "/]" + ] @punctuation.bracket) + +(flow_vertex_leanright + [ + "[/" + "/]" + ] @punctuation.bracket) + +(flow_vertex_leanleft + [ + "[\\" + "\\]" + ] @punctuation.bracket) + +(flow_stmt_subgraph + [ + "[" + "]" + ] @punctuation.bracket) + +[ + (er_cardinarity_zero_or_one) + (er_cardinarity_zero_or_more) + (er_cardinarity_one_or_more) + (er_cardinarity_only_one) + (er_reltype_non_identifying) + (er_reltype_identifying) +] @operator + +(er_entity_name) @variable.member + +(er_attribute_type) @type + +(er_attribute_name) @variable.member + +[ + (er_attribute_key_type_pk) + (er_attribute_key_type_fk) +] @keyword.modifier + +(er_attribute_comment) @string @spell diff --git a/runtime/queries/mermaid/indents.scm b/runtime/queries/mermaid/indents.scm new file mode 100644 index 000000000..fb95bd8de --- /dev/null +++ b/runtime/queries/mermaid/indents.scm @@ -0,0 +1,18 @@ +([ + (diagram_sequence) + (diagram_class) + (diagram_state) + (diagram_gantt) + (diagram_pie) + (diagram_er) + (diagram_flow) + (flow_stmt_subgraph) +] @indent.begin + (#set! indent.immediate 1)) + +"end" @indent.branch + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/runtime/queries/mermaid/injections.scm b/runtime/queries/mermaid/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/mermaid/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/meson/folds.scm b/runtime/queries/meson/folds.scm new file mode 100644 index 000000000..386d4d306 --- /dev/null +++ b/runtime/queries/meson/folds.scm @@ -0,0 +1,9 @@ +[ + (normal_command) + (if_condition) + (if_command) + (else_command) + (elseif_command) + (foreach_command) + (list) +] @fold diff --git a/runtime/queries/meson/highlights.scm b/runtime/queries/meson/highlights.scm new file mode 100644 index 000000000..b00c3399b --- /dev/null +++ b/runtime/queries/meson/highlights.scm @@ -0,0 +1,77 @@ +(comment) @comment @spell + +(number) @number + +(bool) @boolean + +(identifier) @variable + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + ":" + "," + "." +] @punctuation.delimiter + +[ + "and" + "not" + "or" + "in" +] @keyword.operator + +[ + "=" + "==" + "!=" + "+" + "/" + "/=" + "+=" + "-=" + ">" + ">=" +] @operator + +(ternaryoperator + [ + "?" + ":" + ] @keyword.conditional.ternary) + +[ + "if" + "elif" + "else" + "endif" +] @keyword.conditional + +[ + "foreach" + "endforeach" + (keyword_break) + (keyword_continue) +] @keyword.repeat + +(string) @string + +"@" @punctuation.special + +(normal_command + command: (identifier) @function) + +(pair + key: (identifier) @property) + +(escape_sequence) @string.escape + +((identifier) @variable.builtin + (#any-of? @variable.builtin "meson" "host_machine" "build_machine" "target_machine")) diff --git a/runtime/queries/meson/indents.scm b/runtime/queries/meson/indents.scm new file mode 100644 index 000000000..3e27d9200 --- /dev/null +++ b/runtime/queries/meson/indents.scm @@ -0,0 +1,25 @@ +[ + (list) + (dictionaries) + (normal_command) + (if_condition) + (foreach_command) + (ternaryoperator) + (ERROR + "?") ; support partial ternary +] @indent.begin + +[ + ")" + "]" + "}" + (elseif_command) + (else_command) + "endif" + "endforeach" +] @indent.branch @indent.end + +(expression_statement + object: (_)) @indent.begin + +(comment) @indent.auto diff --git a/runtime/queries/meson/injections.scm b/runtime/queries/meson/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/meson/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/mlir/highlights.scm b/runtime/queries/mlir/highlights.scm new file mode 100644 index 000000000..97a0b0d0b --- /dev/null +++ b/runtime/queries/mlir/highlights.scm @@ -0,0 +1,348 @@ +[ + "ins" + "outs" + "else" + "do" + "loc" + "attributes" + "into" + "to" + "from" + "step" + "low" + "high" + "iter_args" + "padding_value" + "inner_tiles" + "gather_dims" + "scatter_dims" + "outer_dims_perm" + "inner_dims_pos" + "shared_outs" + "default" + (arith_cmp_predicate) +] @keyword + +; format-ignore +[ + "module" + "unrealized_conversion_cast" + + "func.call" + "call" + "func.call_indirect" + "call_indirect" + "func.constant" + "constant" + "func.func" + "func.return" + "return" + + "llvm.func" + "llvm.return" + + "cf.assert" + "cf.br" + "cf.cond_br" + "cf.switch" + + "scf.condition" + "scf.execute_region" + "scf.if" + "scf.index_switch" + "scf.for" + "scf.forall" + "scf.forall.in_parallel" + "scf.parallel" + "scf.reduce" + "scf.reduce.return" + "scf.while" + "scf.yield" + + "arith.constant" + "arith.addi" + "arith.subi" + "arith.divsi" + "arith.divui" + "arith.ceildivsi" + "arith.ceildivui" + "arith.floordivsi" + "arith.remsi" + "arith.remui" + "arith.muli" + "arith.mulsi_extended" + "arith.mului_extended" + "arith.andi" + "arith.ori" + "arith.xori" + "arith.maxsi" + "arith.maxui" + "arith.minsi" + "arith.minui" + "arith.shli" + "arith.shrsi" + "arith.shrui" + "arith.addui_extended" + "arith.addf" + "arith.divf" + "arith.maximumf" + "arith.minimumf" + "arith.mulf" + "arith.remf" + "arith.subf" + "arith.negf" + "arith.cmpi" + "arith.cmpf" + "arith.extf" + "arith.extsi" + "arith.extui" + "arith.fptosi" + "arith.fptoui" + "arith.index_cast" + "arith.index_castui" + "arith.sitofp" + "arith.uitofp" + "arith.bitcast" + "arith.truncf" + "arith.select" + + "math.absf" + "math.atan" + "math.cbrt" + "math.ceil" + "math.cos" + "math.erf" + "math.exp" + "math.exp2" + "math.expm1" + "math.floor" + "math.log" + "math.log10" + "math.log1p" + "math.log2" + "math.round" + "math.roundeven" + "math.rsqrt" + "math.sin" + "math.sqrt" + "math.tan" + "math.tanh" + "math.trunc" + "math.absi" + "math.ctlz" + "math.cttz" + "math.ctpop" + "math.atan2" + "math.copysign" + "math.fpowi" + "math.powf" + "math.ipowi" + "math.fma" + + "memref.alloc" + "memref.cast" + "memref.copy" + "memref.collapse_shape" + "memref.expand_shape" + "memref.prefetch" + "memref.rank" + "memref.realloc" + "memref.view" + + "vector.bitcast" + "vector.broadcast" + "vector.shape_cast" + "vector.type_cast" + "vector.constant_mask" + "vector.create_mask" + "vector.extract" + "vector.load" + "vector.scalable.extract" + "vector.fma" + "vector.flat_transpose" + "vector.insert" + "vector.scalable.insert" + "vector.shuffle" + "vector.store" + "vector.insert_strided_slice" + "vector.matrix_multiply" + "vector.print" + "vector.splat" + "vector.transfer_read" + "vector.transfer_write" + "vector.yield" + + "tensor.empty" + "tensor.cast" + "tensor.dim" + "tensor.collapse_shape" + "tensor.expand_shape" + "tensor.extract" + "tensor.insert" + "tensor.extract_slice" + "tensor.insert_slice" + "tensor.parallel_insert_slice" + "tensor.from_elements" + "tensor.gather" + "tensor.scatter" + "tensor.pad" + "tensor.reshape" + "tensor.splat" + "tensor.pack" + "tensor.unpack" + "tensor.generate" + "tensor.rank" + "tensor.yield" + + "bufferization.alloc_tensor" + "bufferization.to_memref" + "bufferization.to_tensor" + + "linalg.batch_matmul" + "linalg.batch_matmul_transpose_b" + "linalg.batch_matvec" + "linalg.batch_reduce_matmul" + "linalg.broadcast" + "linalg.conv_1d_ncw_fcw" + "linalg.conv_1d_nwc_wcf" + "linalg.conv_1d" + "linalg.conv_2d_nchw_fchw" + "linalg.conv_2d_ngchw_fgchw" + "linalg.conv_2d_nhwc_fhwc" + "linalg.conv_2d_nhwc_hwcf" + "linalg.conv_2d_nhwc_hwcf_q" + "linalg.conv_2d" + "linalg.conv_3d_ndhwc_dhwcf" + "linalg.conv_3d_ndhwc_dhwcf_q" + "linalg.conv_3d" + "linalg.copy" + "linalg.depthwise_conv_1d_nwc_wcm" + "linalg.depthwise_conv_2d_nchw_chw" + "linalg.depthwise_conv_2d_nhwc_hwc" + "linalg.depthwise_conv_2d_nhwc_hwc_q" + "linalg.depthwise_conv_2d_nhwc_hwcm" + "linalg.depthwise_conv_2d_nhwc_hwcm_q" + "linalg.depthwise_conv_3d_ndhwc_dhwc" + "linalg.depthwise_conv_3d_ndhwc_dhwcm" + "linalg.dot" + "linalg.elemwise_binary" + "linalg.elemwise_unary" + "linalg.fill" + "linalg.fill_rng_2d" + "linalg.matmul" + "linalg.matmul_transpose_b" + "linalg.matmul_unsigned" + "linalg.matvec" + "linalg.mmt4d" + "linalg.pooling_nchw_max" + "linalg.pooling_nchw_sum" + "linalg.pooling_ncw_max" + "linalg.pooling_ncw_sum" + "linalg.pooling_ndhwc_max" + "linalg.pooling_ndhwc_min" + "linalg.pooling_ndhwc_sum" + "linalg.pooling_nhwc_max" + "linalg.pooling_nhwc_max_unsigned" + "linalg.pooling_nhwc_min" + "linalg.pooling_nhwc_min_unsigned" + "linalg.pooling_nhwc_sum" + "linalg.pooling_nwc_max" + "linalg.pooling_nwc_max_unsigned" + "linalg.pooling_nwc_min" + "linalg.pooling_nwc_min_unsigned" + "linalg.pooling_nwc_sum" + "linalg.quantized_batch_matmul" + "linalg.quantized_matmul" + "linalg.vecmat" + "linalg.generic" + "linalg.index" + "linalg.map" + "linalg.yield" +] @function.builtin + +(generic_operation) @function + +(builtin_type) @type.builtin + +[ + (type_alias) + (dialect_type) + (type_alias_def) +] @type + +[ + (integer_literal) + (complex_literal) +] @number + +(float_literal) @number.float + +(bool_literal) @boolean + +[ + (tensor_literal) + (array_literal) + (unit_literal) +] @constant.builtin + +(string_literal) @string + +[ + (attribute_alias_def) + (attribute_alias) + (bare_attribute_entry) + (attribute) + (fastmath_attr) + (scatter_dims_attr) + (gather_dims_attr) + (outer_dims_perm_attr) + (inner_dims_pos_attr) + (inner_tiles_attr) + (unique_attr) + (nofold_attr) + (isWrite_attr) + (localityHint_attr) + (isDataCache_attr) + (restrict_attr) + (writable_attr) +] @attribute + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + ":" + "," +] @punctuation.delimiter + +[ + "=" + "->" +] @operator + +(builtin_dialect + name: (symbol_ref_id) @function) + +(func_dialect + name: (symbol_ref_id) @function) + +(llvm_dialect + name: (symbol_ref_id) @function) + +(func_arg_list + (value_use) @variable.parameter) + +(block_arg_list + (value_use) @variable.parameter) + +(caret_id) @string.special + +(value_use) @variable + +(comment) @comment @spell diff --git a/runtime/queries/mlir/injections.scm b/runtime/queries/mlir/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/mlir/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/mlir/locals.scm b/runtime/queries/mlir/locals.scm new file mode 100644 index 000000000..d29351d48 --- /dev/null +++ b/runtime/queries/mlir/locals.scm @@ -0,0 +1,12 @@ +(region) @local.scope + +(func_arg_list + (value_use) @local.definition.var) + +(block_arg_list + (value_use) @local.definition.var) + +(op_result + (value_use) @local.definition.var) + +(value_use) @local.reference diff --git a/runtime/queries/muttrc/highlights.scm b/runtime/queries/muttrc/highlights.scm new file mode 100644 index 000000000..27754cc53 --- /dev/null +++ b/runtime/queries/muttrc/highlights.scm @@ -0,0 +1,55 @@ +; Comments +(comment) @comment @spell + +; General +(int) @number + +(string) @string + +[ + (map) + (object) + (composeobject) + (color) + (attribute) +] @string.special + +(quadoption) @boolean + +(path) @string.special.path + +(regex) @string.regexp + +(option) @variable + +(command_line_option) @variable.builtin + +((option) @variable.builtin + (#not-lua-match? @variable.builtin "^my_")) + +(command) @keyword + +(source_directive + (command) @keyword.import) + +(uri) @string.special.url + +(key_name) @constant.builtin + +(escape) @string.escape + +(function) @function.call + +; Literals +[ + "<" + ">" +] @punctuation.bracket + +"," @punctuation.delimiter + +[ + "&" + "?" + "*" +] @character.special diff --git a/runtime/queries/muttrc/injections.scm b/runtime/queries/muttrc/injections.scm new file mode 100644 index 000000000..9c16ad15a --- /dev/null +++ b/runtime/queries/muttrc/injections.scm @@ -0,0 +1,8 @@ +((regex) @injection.content + (#set! injection.language "regex")) + +((shell) @injection.content + (#set! injection.language "bash")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/nasm/highlights.scm b/runtime/queries/nasm/highlights.scm new file mode 100644 index 000000000..02506de8b --- /dev/null +++ b/runtime/queries/nasm/highlights.scm @@ -0,0 +1,162 @@ +; adapted from https://github.com/naclsn/tree-sitter-nasm/blob/main/queries/highlights.scm +(word) @variable + +((word) @constant + (#lua-match? @constant "^[A-Z_][?A-Z_0-9]+$")) + +((word) @constant.builtin + (#lua-match? @constant.builtin "^__%?[A-Z_a-z0-9]+%?__$")) + +[ + (line_here_token) + (section_here_token) +] @variable.builtin + +(label + (word) @label) + +(assembl_directive_symbols + (word) @label) + +(assembl_directive_sections + (word) @label) + +(unary_expression + operator: _ @operator) + +(binary_expression + operator: _ @operator) + +"?" @constant.builtin + +(conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +[ + ":" + "," +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(instruction_prefix) @keyword + +(actual_instruction + instruction: (word) @function.builtin) + +(call_syntax_expression + base: (word) @function.call) + +(size_hint) @type + +(struc_declaration + name: (word) @type) + +(struc_instance + name: (word) @type) + +(effective_address + hint: _ @type) + +(effective_address + segment: _ @constant.builtin) + +(register) @variable.builtin + +(string_literal) @string + +(float_literal) @number.float + +[ + (packed_bcd_literal) + (number_literal) +] @number + +[ + (preproc_alias) + (preproc_multiline_macro) + (preproc_multiline_unmacro) + (preproc_rotate) + (preproc_pathsearch) + (preproc_depend) + (preproc_use) + (preproc_push) + (preproc_pop) + (preproc_repl) + (preproc_arg) + (preproc_stacksize) + (preproc_local) + (preproc_reporting) + (preproc_pragma) + (preproc_line) + (preproc_clear) +] @keyword.directive + +(preproc_include) @keyword.import + +(preproc_rep_loop) @keyword.repeat + +(preproc_if) @keyword.conditional + +[ + (preproc_def) + (preproc_undef) +] @keyword.directive.define + +(preproc_function_def) @keyword.function + +[ + (preproc_expression) + (preproc_arg) +] @constant.macro + +(preproc_multiline_macro + name: (word) @function) + +[ + (pseudo_instruction_dx) + (pseudo_instruction_resx) + (pseudo_instruction_incbin_command) + (pseudo_instruction_equ_command) + (pseudo_instruction_times_prefix) + (pseudo_instruction_alignx_macro) +] @function + +[ + (assembl_directive_target) + (assembl_directive_defaults) + (assembl_directive_sections) + (assembl_directive_absolute) + (assembl_directive_symbols) + (assembl_directive_common) + (assembl_directive_symbolfixes) + (assembl_directive_cpu) + (assembl_directive_floathandling) + (assembl_directive_org) + (assembl_directive_sectalign) + (assembl_directive_primitive_target) + (assembl_directive_primitive_defaults) + (assembl_directive_primitive_sections) + (assembl_directive_primitive_absolute) + (assembl_directive_primitive_symbols) + (assembl_directive_primitive_common) + (assembl_directive_primitive_symbolfixes) + (assembl_directive_primitive_cpu) + (assembl_directive_primitive_floathandling) + (assembl_directive_primitive_org) + (assembl_directive_primitive_sectalign) + (assembl_directive_primitive_warning) + (assembl_directive_primitive_map) +] @keyword + +(comment) @comment @spell diff --git a/runtime/queries/nasm/injections.scm b/runtime/queries/nasm/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/nasm/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/nginx/folds.scm b/runtime/queries/nginx/folds.scm new file mode 100644 index 000000000..fd7d23999 --- /dev/null +++ b/runtime/queries/nginx/folds.scm @@ -0,0 +1 @@ +(block) @fold diff --git a/runtime/queries/nginx/highlights.scm b/runtime/queries/nginx/highlights.scm new file mode 100644 index 000000000..58fcc0b14 --- /dev/null +++ b/runtime/queries/nginx/highlights.scm @@ -0,0 +1,59 @@ +(comment) @comment @spell + +(value) @variable + +[ + (location_modifier) + "=" +] @operator + +[ + (keyword) + "location" +] @keyword + +[ + "if" + "map" +] @keyword.conditional + +(boolean) @boolean + +[ + (auto) + (constant) + (level) + (connection_method) + (var) + (condition) +] @variable.builtin + +[ + (file) + (mask) +] @string.special.path + +[ + (string_literal) + (quoted_string_literal) +] @string + +(directive + (variable + (keyword) @variable.parameter)) + +(location_route) @string.special + +";" @punctuation.delimiter + +[ + (numeric_literal) + (time) + (size) + (cpumask) +] @number + +[ + "{" + "}" +] @punctuation.bracket diff --git a/runtime/queries/nginx/injections.scm b/runtime/queries/nginx/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/nginx/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/nickel/highlights.scm b/runtime/queries/nickel/highlights.scm new file mode 100644 index 000000000..07673d797 --- /dev/null +++ b/runtime/queries/nickel/highlights.scm @@ -0,0 +1,74 @@ +(comment) @comment @spell + +[ + "forall" + "in" + "let" + "default" + "doc" + "rec" +] @keyword + +"fun" @keyword.function + +"import" @keyword.import + +[ + "if" + "then" + "else" +] @keyword.conditional + +"match" @keyword.conditional + +(types) @type + +"Array" @type.builtin + +; BUILTIN Constants +(bool) @boolean + +"null" @constant.builtin + +(num_literal) @number + +(infix_op) @operator + +(type_atom) @type + +(enum_tag) @variable + +(chunk_literal_single) @string + +(chunk_literal_multi) @string + +(str_esc_char) @string.escape + +[ + "{" + "}" + "(" + ")" + "[|" + "|]" +] @punctuation.bracket + +(multstr_start) @punctuation.bracket + +(multstr_end) @punctuation.bracket + +(interpolation_start) @punctuation.bracket + +(interpolation_end) @punctuation.bracket + +(record_field) @variable.member + +(builtin) @function.builtin + +(fun_expr + pats: (pattern_fun + (ident) @variable.parameter)) + +(applicative + t1: (applicative + (record_operand) @function)) diff --git a/runtime/queries/nickel/indents.scm b/runtime/queries/nickel/indents.scm new file mode 100644 index 000000000..8c6f740d9 --- /dev/null +++ b/runtime/queries/nickel/indents.scm @@ -0,0 +1,13 @@ +[ + (atom + (uni_record)) ; for {...} + (atom + terms: (term)) ; for [...] +] @indent.begin + +[ + "]" + "}" +] @indent.end @indent.branch + +(comment) @indent.auto diff --git a/runtime/queries/nickel/injections.scm b/runtime/queries/nickel/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/nickel/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/nim/folds.scm b/runtime/queries/nim/folds.scm new file mode 100644 index 000000000..fa0581a72 --- /dev/null +++ b/runtime/queries/nim/folds.scm @@ -0,0 +1,41 @@ +[ + (const_section) + (var_section) + (let_section) + (type_section) + (using_section) + (object_declaration) + (tuple_type) + (enum_declaration) + (case) + (if) + (when) + (conditional_declaration) + (variant_declaration) + (of_branch) + (elif_branch) + (else_branch) + (for) + (while) + (block) + (static_statement) + (pragma_statement) + (try) + (except_branch) + (finally_branch) + (do_block) + (call + (argument_list + (statement_list))) + (proc_declaration) + (func_declaration) + (method_declaration) + (iterator_declaration) + (converter_declaration) + (template_declaration) + (macro_declaration) + (proc_expression) + (func_expression) + (iterator_expression) + (concept_declaration) +] @fold diff --git a/runtime/queries/nim/highlights.scm b/runtime/queries/nim/highlights.scm new file mode 100644 index 000000000..722c0abdf --- /dev/null +++ b/runtime/queries/nim/highlights.scm @@ -0,0 +1,926 @@ +; SPDX-FileCopyrightText: 2023 Leorize <leorize+oss@disroot.org>, aMOPel <> +; SPDX-License-Identifier: MPL-2.0 +; SPDX-License-Identifier: Apache-2.0 +; ============================================================================= +; catch all rules +((identifier) @variable + (#set! priority 99)) + +; NOTE: we need priority, since (identifier) is most specific and we have to +; capture nodes containing (identifier) as a whole, while overruling the +; @variable capture. +(type_expression) @type + +; NOTE: has to be after +; ((identifier) @variable (#set! priority 99)) +; overrule identifiers in pragmas in (proc_type)s and (pragma_expression)s +(proc_type + pragmas: (pragma_list) @variable) + +(iterator_type + pragmas: (pragma_list) @variable) + +(type_expression + (pragma_expression + right: (pragma_list) @variable)) + +; NOTE: has to be after +; (type_expression) @type +; and before @keyword.directive and all literals +; constants/enums in array construction +(array_construction + (colon_expression + left: (_) @constant)) + +; NOTE: has to be before literals and punctuation etc. +; identifiers in "case" "of" branches have to be enums +(case + alternative: (of_branch + values: (expression_list + (_) @constant))) + +; NOTE: has to be before literals and punctuation etc. +; in variant objects with "case" "of" +(variant_declaration + alternative: (of_branch + values: (expression_list + (_) @constant))) + +; NOTE: has to be before literals and punctuation etc. +; ============================================================================= +; @comment ; line and block comments +[ + (comment) + (block_comment) +] @comment + +; ============================================================================= +; @comment.documentation ; comments documenting code +(documentation_comment + "##" @comment.documentation) + +(block_documentation_comment + "##[" @comment.documentation + "]##" @comment.documentation) + +; NOTE: leaving content uncaptured so markdown can be injected +; ============================================================================= +; @punctuation.delimiter ; delimiters (e.g. `;` / `.` / `,`) +[ + "." + ";" + "," + ":" + "=" +] @punctuation.delimiter + +; ============================================================================= +; @operator ; symbolic operators (e.g. `+` / `*`) +(operator) @operator + +(assignment + "=" @operator) + +; ============================================================================= +; @punctuation.bracket ; brackets (e.g. `()` / `{}` / `[]`) +[ + "(" + ")" + "[" + "[:" + "]" + "{" + "}" +] @punctuation.bracket + +; ============================================================================= +; @keyword.directive ; various preprocessor directives & shebangs +[ + "macro" + "template" +] @keyword.directive + +(pragma_list + [ + "{." + "}" + ".}" + ] @keyword.directive) + +; NOTE: has to come after @punctuation.bracket +; ============================================================================= +; @punctuation.special ; special symbols (e.g. `{}` in string interpolation) +(accent_quoted + "`" @punctuation.special) + +(exported_symbol + "*" @punctuation.special) + +; dereference operator +(bracket_expression + !right + "[" @punctuation.special + . + "]" @punctuation.special) + +; ============================================================================= +; @string ; string literals +[ + (interpreted_string_literal) + (long_string_literal) + (raw_string_literal) + (generalized_string) +] @string + +; injections in generalized_strings +(generalized_string + (string_content) @none) + +; format string injection in normal strings with & prefix +(prefix_expression + operator: (operator) @_string_prefix + . + (_ + (string_content) @none) + (#eq? @_string_prefix "&")) + +; emit pragma injection +(pragma_statement + (pragma_list + (colon_expression + left: (identifier) @_emit_keyword + (#eq? @_emit_keyword "emit") + right: (_ + (string_content) @none)))) + +; ============================================================================= +; @string.escape ; escape sequences +(escape_sequence) @string.escape + +; ============================================================================= +; @character ; character literals +(char_literal) @character + +; ============================================================================= +; @boolean ; boolean literals +((identifier) @boolean + (#any-of? @boolean "true" "false" "on" "off")) + +; ============================================================================= +; @number ; numeric literals +(integer_literal) @number + +(custom_numeric_literal) @number + +; ============================================================================= +; @number.float ; floating-point number literals +(float_literal) @number.float + +; ============================================================================= +; @function ; function definitions +(proc_declaration + name: [ + (identifier) @function + (accent_quoted + (identifier) @function) + (exported_symbol + (identifier) @function) + (exported_symbol + (accent_quoted + (identifier) @function)) + ]) + +(func_declaration + name: [ + (identifier) @function + (accent_quoted + (identifier) @function) + (exported_symbol + (identifier) @function) + (exported_symbol + (accent_quoted + (identifier) @function)) + ]) + +(iterator_declaration + name: [ + (identifier) @function + (accent_quoted + (identifier) @function) + (exported_symbol + (identifier) @function) + (exported_symbol + (accent_quoted + (identifier) @function)) + ]) + +(converter_declaration + name: [ + (identifier) @function + (accent_quoted + (identifier) @function) + (exported_symbol + (identifier) @function) + (exported_symbol + (accent_quoted + (identifier) @function)) + ]) + +; ============================================================================= +; @function.call ; function calls +(call + function: [ + (identifier) @function.call + (accent_quoted + (identifier) @function.call) + ; generic types + (bracket_expression + left: (identifier) @function.call) + (bracket_expression + left: (accent_quoted + (identifier) @function.call)) + ; dot accessor + (dot_expression + right: (identifier) @function.call) + (dot_expression + right: (accent_quoted + (identifier) @function.call)) + ; both + (bracket_expression + left: (dot_expression + right: (identifier) @function.call)) + (bracket_expression + left: (dot_expression + right: (accent_quoted + (identifier) @function.call))) + ]) + +(dot_generic_call + function: [ + (identifier) @function.call + (accent_quoted + (identifier) @function.call) + ]) + +; generalized_string is a function call +; `identifier"string literal"` +; is short for +; `identifier(r"string literal")` +(generalized_string + function: [ + (identifier) @function.call + (accent_quoted + (identifier) @function.call) + ]) + +; call with leading literal +(dot_expression + left: [ + (nil_literal) + (integer_literal) + (float_literal) + (custom_numeric_literal) + (char_literal) + (interpreted_string_literal) + (long_string_literal) + (raw_string_literal) + (generalized_string) + (array_construction) + ; for sequences + (prefix_expression + operator: (operator) @_at + (array_construction) + (#eq? @_at "@")) + (tuple_construction) + (curly_construction) + ] + right: [ + (identifier) @function.call + (accent_quoted + (identifier) @function.call) + ]) + +; NOTE: will double capture as @function.call if it also has argument_list +; function.calls in `varargs[type, routine]` +(bracket_expression + left: (identifier) @_varargs + right: (argument_list + . + (_) + . + [ + (identifier) @function.call + (accent_quoted + (identifier) @function.call) + (dot_expression + right: (identifier) @function.call) + (dot_expression + right: (accent_quoted + (identifier) @function.call)) + ]) + (#eq? @_varargs "varargs")) + +; ============================================================================= +; @function.macro ; preprocessor macros +(template_declaration + name: [ + (identifier) @function.macro + (accent_quoted + (identifier) @function.macro) + (exported_symbol + (identifier) @function.macro) + (exported_symbol + (accent_quoted + (identifier) @function.macro)) + ]) + +(macro_declaration + name: [ + (identifier) @function.macro + (accent_quoted + (identifier) @function.macro) + (exported_symbol + (identifier) @function.macro) + (exported_symbol + (accent_quoted + (identifier) @function.macro)) + ]) + +; ============================================================================= +; @function.method ; method definitions +(method_declaration + name: [ + (identifier) @function.method + (accent_quoted + (identifier) @function.method) + (exported_symbol + (identifier) @function.method) + (exported_symbol + (accent_quoted + (identifier) @function.method)) + ]) + +; ============================================================================= +; @constructor ; constructor calls and definitions +(call + function: [ + (identifier) @constructor + (accent_quoted + (identifier) @constructor) + ; generic types + (bracket_expression + left: (identifier) @constructor) + (bracket_expression + left: (accent_quoted + (identifier) @constructor)) + ; dot accessor + (dot_expression + right: (identifier) @constructor) + (dot_expression + right: (accent_quoted + (identifier) @constructor)) + ; both + (bracket_expression + left: (dot_expression + right: (identifier) @constructor)) + (bracket_expression + left: (dot_expression + right: (accent_quoted + (identifier) @constructor))) + ] + (argument_list + (colon_expression)+)) + +; NOTE: this cannot detect constructors with 0 arguments +; those will be matched as @function.call instead +; ============================================================================= +; @keyword ; various keywords +; unhandled but reserved keywords +; end +; interface +; static expression +; addr operator +((call + function: (identifier) @keyword) + (#any-of? @keyword "static" "addr")) + +[ + "const" + "let" + "var" + "concept" + "asm" + "bind" + "defer" + "do" + "mixin" + "static" + "tuple" + "block" + "using" + "discard" +] @keyword + +[ + "enum" + "object" + "type" +] @keyword.type + +; ============================================================================= +; @keyword.function ; keywords that define a function (e.g. `func` in Go, `def` in Python) +[ + "proc" + "func" + "method" + "converter" + "iterator" +] @keyword.function + +; ============================================================================= +; @keyword.operator ; operators that are English words (e.g. `and` / `or`) +[ + "and" + "or" + "xor" + "not" + "div" + "mod" + "shl" + "shr" + "from" + "as" + "of" + "in" + "notin" + "is" + "isnot" + "cast" +] @keyword.operator + +; ============================================================================= +; @keyword.return ; keywords like `return` and `yield` +[ + "return" + "yield" +] @keyword.return + +; ============================================================================= +; @keyword.conditional ; keywords related to conditionals (e.g. `if` / `else`) +[ + "if" + "when" + "case" + "elif" + "else" +] @keyword.conditional + +(of_branch + "of" @keyword.conditional) + +; ============================================================================= +; @keyword.repeat ; keywords related to loops (e.g. `for` / `while`) +[ + "for" + "while" + "continue" + "break" +] @keyword.repeat + +(for + "in" @keyword.repeat) + +; ============================================================================= +; @label ; GOTO and other labels (e.g. `label:` in C) +(block + label: [ + (identifier) @label + (accent_quoted + (identifier) @label) + ]) + +; ============================================================================= +; @keyword.import ; keywords for including modules (e.g. `import` / `from` in Python) +[ + "import" + "include" + "export" +] @keyword.import + +(import_from_statement + "from" @keyword.import) + +(except_clause + "except" @keyword.import) + +; ============================================================================= +; @keyword.exception ; keywords related to exceptions (e.g. `throw` / `catch`) +[ + "try" + "except" + "finally" + "raise" +] @keyword.exception + +; ============================================================================= +; @type ; type or class definitions and annotations +; generic types when calling +(call + function: (bracket_expression + right: (argument_list) @type)) + +; NOTE: this also falsely matches +; when accessing and directly call elements from an array of routines +; eg `array_of_routines[index](arguments), but that is an uncommon case +; dot_generic_call `v.call[:type, type]() +(dot_generic_call + generic_arguments: (_) @type) + +; right side of `is` operator is always type +(infix_expression + operator: [ + "is" + "isnot" + ] + right: (_) @type) + +; except branch always contains types of errors +; Eg: `except module.exception[gen_type]:` +(except_branch + values: (expression_list) @type) + +; overrule special case in (except_branch) with "as" operator +; `except module.exception[gen_type] as variable:` +(except_branch + values: (expression_list + (infix_expression + operator: "as" + right: [ + (identifier) @variable + (accent_quoted + (identifier) @variable) + ]))) + +; for inline tuple types +; `type a = tuple[a: int]` +(tuple_type + "tuple" @type + (field_declaration_list)) + +; NOTE: this is consistent with other generic types like `seq[int]` +; but inconsistent with multiline tuple declaration, +; where `tuple` is captured as @keyword +; ============================================================================= +; @variable.parameter ; parameters of a function +; named parameters when calling +; call(parameter_name=arg) +(argument_list + (equal_expression + left: [ + (identifier) @variable.parameter + (accent_quoted + (identifier) @variable.parameter) + ])) + +; parameters in function declaration +(parameter_declaration_list + (parameter_declaration + (symbol_declaration_list + (symbol_declaration + name: [ + (identifier) @variable.parameter + (accent_quoted + (identifier) @variable.parameter) + ])))) + +; NOTE: needs to be after @type +; generic types when declaring +(generic_parameter_list + (parameter_declaration + (symbol_declaration_list + (symbol_declaration + name: [ + (identifier) @variable.parameter + (accent_quoted + (identifier) @variable.parameter) + ])))) + +; for loop variables +(for + left: (symbol_declaration_list + (symbol_declaration + name: [ + (identifier) @variable.parameter + (accent_quoted + (identifier) @variable.parameter) + ]))) + +((tuple_deconstruct_declaration + (symbol_declaration + name: [ + (identifier) @variable.parameter + (accent_quoted + (identifier) @variable.parameter) + ])) @_tuple_decons + (#has-ancestor? @_tuple_decons for)) + +(concept_declaration + parameters: (parameter_list + [ + (identifier) @variable.parameter + (accent_quoted + (identifier) @variable.parameter) + ])) + +(var_parameter + [ + (identifier) @variable.parameter + (accent_quoted + (identifier) @variable.parameter) + ]) + +(type_parameter + [ + (identifier) @variable.parameter + (accent_quoted + (identifier) @variable.parameter) + ]) + +(static_parameter + [ + (identifier) @variable.parameter + (accent_quoted + (identifier) @variable.parameter) + ]) + +(ref_parameter + [ + (identifier) @variable.parameter + (accent_quoted + (identifier) @variable.parameter) + ]) + +(pointer_parameter + [ + (identifier) @variable.parameter + (accent_quoted + (identifier) @variable.parameter) + ]) + +; ============================================================================= +; @type.definition ; type definitions (e.g. `typedef` in C) +(type_section + (type_declaration + (type_symbol_declaration + name: [ + (identifier) @type.definition + (accent_quoted + (identifier) @type.definition) + (exported_symbol + (identifier) @type.definition) + (exported_symbol + (accent_quoted + (identifier) @type.definition)) + ]))) + +; ============================================================================= +; @keyword.modifier ; type qualifier keywords (e.g. `const`) +(var_type + "var" @keyword.modifier) + +(out_type + "out" @keyword.modifier) + +(distinct_type + "distinct" @keyword.modifier) + +(ref_type + "ref" @keyword.modifier) + +(pointer_type + "ptr" @keyword.modifier) + +(var_parameter + "var" @keyword.modifier) + +(type_parameter + "type" @keyword.modifier) + +(static_parameter + "static" @keyword.modifier) + +(ref_parameter + "ref" @keyword.modifier) + +(pointer_parameter + "ptr" @keyword.modifier) + +; ============================================================================= +; @variable.member ; object and struct fields +; fields in object/tuple declaration +(field_declaration + (symbol_declaration_list + (symbol_declaration + name: [ + (identifier) @variable.member + (accent_quoted + (identifier) @variable.member) + (exported_symbol + (identifier) @variable.member) + (exported_symbol + (accent_quoted + (identifier) @variable.member)) + ]))) + +; fields in object construction +(call + (argument_list + (colon_expression + left: [ + (identifier) @variable.member + (accent_quoted + (identifier) @variable.member) + ]))) + +; fields in tuple construction +(tuple_construction + (colon_expression + left: [ + (identifier) @variable.member + (accent_quoted + (identifier) @variable.member) + ])) + +(variant_declaration + (variant_discriminator_declaration + (symbol_declaration_list + (symbol_declaration + name: [ + (identifier) @variable.member + (accent_quoted + (identifier) @variable.member) + (exported_symbol + (identifier) @variable.member) + (exported_symbol + (accent_quoted + (identifier) @variable.member)) + ])))) + +; ============================================================================= +; @variable.builtin ; built-in variable names (e.g. `this`) +(blank_identifier) @variable.builtin + +((identifier) @variable.builtin + (#eq? @variable.builtin "result")) + +; NOTE: technically needs `has-ancestor some routine declaration` but it's +; not worth it +; ============================================================================= +; @constant ; constant identifiers +; enum declaration +(enum_field_declaration + (symbol_declaration + name: [ + (identifier) @constant + (accent_quoted + (identifier) @constant) + ])) + +; constant declaration +(const_section + (variable_declaration + (symbol_declaration_list + (symbol_declaration + name: [ + (identifier) @constant + (accent_quoted + (identifier) @constant) + (exported_symbol + (identifier) @constant) + (exported_symbol + (accent_quoted + (identifier) @constant)) + ])))) + +((tuple_deconstruct_declaration + (symbol_declaration + name: [ + (identifier) @constant + (accent_quoted + (identifier) @constant) + (exported_symbol + (identifier) @constant) + (exported_symbol + (accent_quoted + (identifier) @constant)) + ])) @_tuple_decons + (#has-ancestor? @_tuple_decons const_section)) + +; constants x and y in `array[x..y, type]` +(bracket_expression + left: (identifier) @_array + right: (argument_list + . + (infix_expression + right: [ + (identifier) @constant + (accent_quoted + (identifier) @constant) + (dot_expression + right: (identifier) @constant) + (dot_expression + right: (accent_quoted + (identifier) @constant)) + ])) + (#any-of? @_array "array" "range")) + +(bracket_expression + left: (identifier) @_array + right: (argument_list + . + (infix_expression + left: [ + (identifier) @constant + (accent_quoted + (identifier) @constant) + (dot_expression + right: (identifier) @constant) + (dot_expression + right: (accent_quoted + (identifier) @constant)) + ])) + (#any-of? @_array "array" "range")) + +; NOTE: can only do this for (infix_expression)s, since standalone identifiers +; could be ordinal types and constants +; ============================================================================= +; @constant.builtin ; built-in constant values +(nil_literal) @constant.builtin + +; ============================================================================= +; @module ; modules or namespaces +(import_statement + (expression_list + (identifier) @module)) + +(import_statement + (expression_list + (infix_expression + operator: "as" + right: (identifier) @module))) + +(import_statement + (expression_list + (infix_expression + operator: (operator) @_operator + right: [ + (identifier) @module + (array_construction + (identifier) @module) + ])) + (#eq? @_operator "/")) + +(import_from_statement + module: (infix_expression + operator: (operator) @_operator + right: (identifier) @module) + (#eq? @_operator "/")) + +(export_statement + (expression_list + (identifier) @module)) + +; ============================================================================= +; overrule things +; left identifier in dot_expression +(dot_expression + left: [ + (identifier) @none + (accent_quoted + (identifier) @none) + ]) + +; NOTE: we can't know what the left identifier is, so better leave it alone +; for consistency +; discard literals is like a comment +(discard_statement + "discard" @comment + [ + (nil_literal) + (integer_literal) + (float_literal) + (custom_numeric_literal) + (char_literal) + (interpreted_string_literal) + (long_string_literal) + (raw_string_literal) + (generalized_string) + (array_construction) + ; for sequences + (prefix_expression + operator: (operator) @_at + (array_construction) + (#eq? @_at "@")) + (tuple_construction) + (curly_construction) + ] @comment) diff --git a/runtime/queries/nim/injections.scm b/runtime/queries/nim/injections.scm new file mode 100644 index 000000000..da15fd84c --- /dev/null +++ b/runtime/queries/nim/injections.scm @@ -0,0 +1,79 @@ +; ============================================================================= +; generalized_strings +; regex in generalized_strings +(generalized_string + function: (identifier) @_string_prefix + . + (string_content) @injection.content + (#set! injection.language "regex") + (#any-of? @_string_prefix "re" "rex")) + +; format string in generalized_strings +(generalized_string + function: (identifier) @_string_prefix + . + (string_content) @injection.content + (#set! injection.language "nim_format_string") + (#eq? @_string_prefix "fmt")) + +; format string in normal strings with & prefix +(prefix_expression + operator: (operator) @_string_prefix + . + (_ + (string_content) @injection.content) + (#set! injection.language "nim_format_string") + (#eq? @_string_prefix "&")) + +; sql in generalized_strings +; and anything you like as long as the function name is the same as the injected language's parser +(generalized_string + function: (identifier) @injection.language + (string_content) @injection.content + (#not-any-of? @injection.language "re" "rex" "fmt")) + +; ============================================================================= +; emit pragma +; C / CPP / OBJC / JAVASCRIPT +; a `#<no whitespace><language name>` +; has to directly precede the {.emit: "<language code>".} pragma +; eg.: +; #objc +; {.emit: "<objc code>".} +; OR +; #javascript +; {.emit: "<javascript code>".} +; normal strings +((comment + (comment_content) @injection.language) + . + (pragma_statement + (pragma_list + (colon_expression + left: (identifier) @_emit_keyword + (#eq? @_emit_keyword "emit") + right: (_ + (string_content) @injection.content))))) + +; ============================================================================= +; asm statement +; works same as emit pragma, needs preceding comment with language name +((comment + (comment_content) @injection.language) + . + (assembly_statement + (_ + (string_content) @injection.content))) + +; ============================================================================= +; comments +; NOTE: ts "comment" parser heavily impacts performance +; markdown parser in documentation_comment +(documentation_comment + (comment_content) @injection.content + (#set! injection.language "markdown_inline")) + +; markdown parser in block_documentation_comment +(block_documentation_comment + (comment_content) @injection.content + (#set! injection.language "markdown")) diff --git a/runtime/queries/nim/locals.scm b/runtime/queries/nim/locals.scm new file mode 100644 index 000000000..d79fe728e --- /dev/null +++ b/runtime/queries/nim/locals.scm @@ -0,0 +1,328 @@ +; ============================================================================== +; @local.definition ; various definitions +(block + label: [ + (identifier) @local.definition + (accent_quoted) @local.definition + ]) + +; ============================================================================== +; @local.definition.constant ; constants +(const_section + (variable_declaration + (symbol_declaration_list + (symbol_declaration + name: [ + (identifier) @local.definition.constant + (accent_quoted) @local.definition.constant + (exported_symbol + (identifier) @local.definition.constant) + (exported_symbol + (accent_quoted) @local.definition.constant) + ])) + type: (type_expression)? @local.definition.associated)) + +; ============================================================================== +; @local.definition.function ; functions +(proc_declaration + name: [ + (identifier) @local.definition.function + (accent_quoted) @local.definition.function + (exported_symbol + (identifier) @local.definition.function) + (exported_symbol + (accent_quoted) @local.definition.function) + ] + (#set! definition.function.scope "parent")) + +(func_declaration + name: [ + (identifier) @local.definition.function + (accent_quoted) @local.definition.function + (exported_symbol + (identifier) @local.definition.function) + (exported_symbol + (accent_quoted) @local.definition.function) + ] + (#set! definition.function.scope "parent")) + +(iterator_declaration + name: [ + (identifier) @local.definition.function + (accent_quoted) @local.definition.function + (exported_symbol + (identifier) @local.definition.function) + (exported_symbol + (accent_quoted) @local.definition.function) + ] + (#set! definition.function.scope "parent")) + +(converter_declaration + name: [ + (identifier) @local.definition.function + (accent_quoted) @local.definition.function + (exported_symbol + (identifier) @local.definition.function) + (exported_symbol + (accent_quoted) @local.definition.function) + ] + (#set! definition.function.scope "parent")) + +; ============================================================================== +; @local.definition.method ; methods +(method_declaration + name: [ + (identifier) @local.definition.method + (accent_quoted) @local.definition.method + (exported_symbol + (identifier) @local.definition.method) + (exported_symbol + (accent_quoted) @local.definition.method) + ] + (#set! definition.method.scope "parent")) + +; ============================================================================== +; @local.definition.var ; variables +(var_section + (variable_declaration + (symbol_declaration_list + (symbol_declaration + name: [ + (identifier) @local.definition.var + (accent_quoted) @local.definition.var + (exported_symbol + (identifier) @local.definition.var) + (exported_symbol + (accent_quoted) @local.definition.var) + ])) + type: (type_expression)? @local.definition.associated)) + +(let_section + (variable_declaration + (symbol_declaration_list + (symbol_declaration + name: [ + (identifier) @local.definition.var + (accent_quoted) @local.definition.var + (exported_symbol + (identifier) @local.definition.var) + (exported_symbol + (accent_quoted) @local.definition.var) + ])) + type: (type_expression)? @local.definition.associated)) + +(for + (symbol_declaration_list + (symbol_declaration + name: [ + (identifier) @local.definition.var + (accent_quoted) @local.definition.var + ]))) + +(try + (except_branch + values: (expression_list + (infix_expression + right: [ + (identifier) @local.definition.var + (accent_quoted) @local.definition.var + ])))) + +; ============================================================================== +; @local.definition.parameter ; parameters +(parameter_declaration + (symbol_declaration_list + (symbol_declaration + name: [ + (identifier) @local.definition.parameter + (accent_quoted) @local.definition.parameter + ])) + type: (type_expression)? @local.definition.associated) + +(concept_declaration + parameters: (parameter_list + [ + (identifier) @local.definition.parameter + (accent_quoted + (identifier) @local.definition.parameter) + ])) + +(var_parameter + [ + (identifier) @local.definition.parameter + (accent_quoted + (identifier) @local.definition.parameter) + ]) + +(type_parameter + [ + (identifier) @local.definition.parameter + (accent_quoted + (identifier) @local.definition.parameter) + ]) + +(static_parameter + [ + (identifier) @local.definition.parameter + (accent_quoted + (identifier) @local.definition.parameter) + ]) + +(ref_parameter + [ + (identifier) @local.definition.parameter + (accent_quoted + (identifier) @local.definition.parameter) + ]) + +(pointer_parameter + [ + (identifier) @local.definition.parameter + (accent_quoted + (identifier) @local.definition.parameter) + ]) + +; ============================================================================== +; @local.definition.macro ; preprocessor macros +(template_declaration + name: [ + (identifier) @local.definition.macro + (accent_quoted) @local.definition.macro + (exported_symbol + (identifier) @local.definition.macro) + (exported_symbol + (accent_quoted) @local.definition.macro) + ] + (#set! definition.macro.scope "parent")) + +(macro_declaration + name: [ + (identifier) @local.definition.macro + (accent_quoted) @local.definition.macro + (exported_symbol + (identifier) @local.definition.macro) + (exported_symbol + (accent_quoted) @local.definition.macro) + ] + (#set! definition.macro.scope "parent")) + +; ============================================================================== +; @local.definition.type ; types or classes +(type_declaration + (type_symbol_declaration + name: [ + (identifier) @local.definition.type + (accent_quoted) @local.definition.type + (exported_symbol + (identifier) @local.definition.type) + (exported_symbol + (accent_quoted) @local.definition.type) + ])) + +; ============================================================================== +; @local.definition.field ; fields or properties +; object_declaration +; variant_declaration +; conditional_declaration +; tuple_type inline +; tuple_type multiline +(field_declaration + (symbol_declaration_list + (symbol_declaration + name: [ + (identifier) @local.definition.field + (accent_quoted) @local.definition.field + (exported_symbol + (identifier) @local.definition.field) + (exported_symbol + (accent_quoted) @local.definition.field) + ])) + type: (type_expression)? @local.definition.associated) + +; ============================================================================== +; @local.definition.enum ; enumerations +(enum_declaration + (enum_field_declaration + (symbol_declaration + name: [ + (identifier) @local.definition.enum + (accent_quoted) @local.definition.enum + ]))) + +; ============================================================================== +; @local.definition.namespace ; modules or namespaces +; @local.definition.import ; imported names +(import_statement + (expression_list + (identifier) @local.definition.namespace)) + +(import_statement + (expression_list + (infix_expression + operator: "as" + right: (identifier) @local.definition.namespace))) + +(import_statement + (expression_list + (infix_expression + operator: (operator) @_operator + right: [ + (identifier) @local.definition.namespace + (array_construction + (identifier) @local.definition.namespace) + ])) + (#eq? @_operator "/")) + +(import_from_statement + module: (infix_expression + operator: (operator) @_operator + right: (identifier) @local.definition.namespace) + (expression_list + [ + (identifier) @local.definition.import + (accent_quoted) @local.definition.import + ]) + (#eq? @_operator "/")) + +; ============================================================================== +; @local.scope ; scope block +; (when) +; NOTE: `when` does actually not create a scope +(if + consequence: (statement_list) @local.scope + alternative: (elif_branch)* @local.scope + alternative: (else_branch)? @local.scope) + +(case + alternative: (of_branch)* @local.scope + alternative: (elif_branch)* @local.scope + alternative: (else_branch)? @local.scope) + +(try + body: (statement_list) @local.scope + (except_branch) @local.scope + (finally_branch)? @local.scope) + +[ + (for) + (while) + (block) + (static_statement) + (proc_declaration) + (func_declaration) + (method_declaration) + (iterator_declaration) + (converter_declaration) + (template_declaration) + (macro_declaration) + (proc_expression) + (func_expression) + (iterator_expression) + (concept_declaration) +] @local.scope + +; ============================================================================== +; @local.reference ; identifier reference +(identifier) @local.reference + +(accent_quoted) @local.reference diff --git a/runtime/queries/nim_format_string/highlights.scm b/runtime/queries/nim_format_string/highlights.scm new file mode 100644 index 000000000..fde9e4ba0 --- /dev/null +++ b/runtime/queries/nim_format_string/highlights.scm @@ -0,0 +1,20 @@ +(string_literal) + +(matching_curlies + opening_curly: (opening_curly) @punctuation.special + equals: (equals)? @punctuation.special + closing_curly: (closing_curly) @punctuation.special) + +(format_specifiers + colon: (colon) @punctuation.delimiter + fill_align: (fill_align)? @keyword.conditional.ternary + sign: (sign)? @operator + hash: (hash)? @punctuation.special + zero: (zero)? @variable.member + min_width: (min_width)? @number + precision: (precision)? @number + type: (type)? @type) + +(matching_curlies + nim_expression: (nim_expression + escaped_curly: (escaped_curly)+ @string.escape) @none) diff --git a/runtime/queries/nim_format_string/injections.scm b/runtime/queries/nim_format_string/injections.scm new file mode 100644 index 000000000..3efbfb854 --- /dev/null +++ b/runtime/queries/nim_format_string/injections.scm @@ -0,0 +1,4 @@ +((matching_curlies + (nim_expression + !escaped_curly) @injection.content) + (#set! injection.language "nim")) diff --git a/runtime/queries/ninja/folds.scm b/runtime/queries/ninja/folds.scm new file mode 100644 index 000000000..341a8b8c1 --- /dev/null +++ b/runtime/queries/ninja/folds.scm @@ -0,0 +1 @@ +(body) @fold diff --git a/runtime/queries/ninja/highlights.scm b/runtime/queries/ninja/highlights.scm new file mode 100644 index 000000000..8323ee9e9 --- /dev/null +++ b/runtime/queries/ninja/highlights.scm @@ -0,0 +1,101 @@ +[ + "default" + "pool" + "rule" + "build" +] @keyword + +[ + "include" + "subninja" +] @keyword.import + +":" @punctuation.delimiter + +[ + "=" + "|" + "||" + "|@" +] @operator + +[ + "$" + "{" + "}" +] @punctuation.special + +; +; Names +; ===== +(pool + name: (identifier) @type) + +(rule + name: (identifier) @function) + +(let + name: (identifier) @constant) + +(expansion + (identifier) @constant) + +(build + rule: (identifier) @function) + +; +; Paths and Text +; ============== +(path) @string.special.path + +(text) @string + +; +; Builtins +; ======== +(pool + name: (identifier) @type.builtin + (#any-of? @type.builtin "console")) + +(build + rule: (identifier) @function.builtin + (#any-of? @function.builtin "phony" "dyndep")) + +; Top level bindings +; ------------------ +(manifest + (let + name: ((identifier) @constant.builtin + (#any-of? @constant.builtin "builddir" "ninja_required_version")))) + +; Rules bindings +; ----------------- +(rule + (body + (let + name: (identifier) @constant.builtin + (#not-any-of? @constant.builtin + "command" "depfile" "deps" "msvc_deps_prefix" "description" "dyndep" "generator" "in" + "in_newline" "out" "restat" "rspfile" "rspfile_content" "pool")))) + +; +; Expansion +; --------- +(expansion + (identifier) @constant.macro + (#any-of? @constant.macro "in" "out")) + +; +; Escape sequences +; ================ +(quote) @string.escape + +; +; Others +; ====== +[ + (split) + (comment) +] @comment + +(comment) @spell diff --git a/runtime/queries/ninja/indents.scm b/runtime/queries/ninja/indents.scm new file mode 100644 index 000000000..80344cdfb --- /dev/null +++ b/runtime/queries/ninja/indents.scm @@ -0,0 +1,5 @@ +[ + (pool) + (rule) + (build) +] @indent.begin diff --git a/runtime/queries/ninja/injections.scm b/runtime/queries/ninja/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/ninja/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/nix/folds.scm b/runtime/queries/nix/folds.scm new file mode 100644 index 000000000..a89a5b24b --- /dev/null +++ b/runtime/queries/nix/folds.scm @@ -0,0 +1,11 @@ +; Nix doesn't really have blocks, so just guess what people might want folds for +[ + (if_expression) + (with_expression) + (let_expression) + (function_expression) + (attrset_expression) + (rec_attrset_expression) + (list_expression) + (indented_string_expression) +] @fold diff --git a/runtime/queries/nix/highlights.scm b/runtime/queries/nix/highlights.scm new file mode 100644 index 000000000..24e685a32 --- /dev/null +++ b/runtime/queries/nix/highlights.scm @@ -0,0 +1,210 @@ +; basic keywords +[ + "assert" + "in" + "inherit" + "let" + "rec" + "with" +] @keyword + +; if/then/else +[ + "if" + "then" + "else" +] @keyword.conditional + +; field access default (`a.b or c`) +"or" @keyword.operator + +; comments +(comment) @comment @spell + +; strings +(string_fragment) @string + +(string_expression + "\"" @string) + +(indented_string_expression + "''" @string) + +; paths and URLs +[ + (path_expression) + (hpath_expression) + (spath_expression) +] @string.special.path + +(uri_expression) @string.special.url + +; escape sequences +(escape_sequence) @string.escape + +; delimiters +[ + "." + ";" + ":" + "," +] @punctuation.delimiter + +; brackets +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; `?` in `{ x ? y }:`, used to set defaults for named function arguments +(formal + name: (identifier) @variable.parameter + "?"? @operator) + +; `...` in `{ ... }`, used to ignore unknown named function arguments (see above) +(ellipses) @variable.parameter.builtin + +; universal is the parameter of the function expression +; `:` in `x: y`, used to separate function argument from body (see above) +(function_expression + universal: (identifier) @variable.parameter + ":" @punctuation.special) + +; function calls +(apply_expression + function: (variable_expression + name: (identifier) @function.call)) + +; basic identifiers +(variable_expression) @variable + +(variable_expression + name: (identifier) @keyword.import + (#eq? @keyword.import "import")) + +(variable_expression + name: (identifier) @boolean + (#any-of? @boolean "true" "false")) + +; string interpolation (this was very annoying to get working properly) +(interpolation + "${" @punctuation.special + (_) + "}" @punctuation.special) @none + +(select_expression + expression: (_) @_expr + attrpath: (attrpath + attr: (identifier) @variable.member) + (#not-eq? @_expr "builtins")) + +(attrset_expression + (binding_set + (binding + . + (attrpath + (identifier) @variable.member)))) + +(rec_attrset_expression + (binding_set + (binding + . + (attrpath + (identifier) @variable.member)))) + +function: (select_expression + attrpath: (attrpath + attr: (identifier) @function.call .)) + +; builtin functions (with builtins prefix) +(select_expression + expression: (variable_expression + name: (identifier) @_id) + attrpath: (attrpath + attr: (identifier) @function.builtin) + (#eq? @_id "builtins")) + +; builtin functions (without builtins prefix) +(variable_expression + name: (identifier) @function.builtin + (#any-of? @function.builtin + ; nix eval --impure --expr 'with builtins; filter (x: !(elem x [ "abort" "import" "throw" ]) && isFunction builtins.${x}) (attrNames builtins)' + "add" "addErrorContext" "all" "any" "appendContext" "attrNames" "attrValues" "baseNameOf" + "bitAnd" "bitOr" "bitXor" "break" "catAttrs" "ceil" "compareVersions" "concatLists" "concatMap" + "concatStringsSep" "deepSeq" "derivation" "derivationStrict" "dirOf" "div" "elem" "elemAt" + "fetchGit" "fetchMercurial" "fetchTarball" "fetchTree" "fetchurl" "filter" "filterSource" + "findFile" "floor" "foldl'" "fromJSON" "fromTOML" "functionArgs" "genList" "genericClosure" + "getAttr" "getContext" "getEnv" "getFlake" "groupBy" "hasAttr" "hasContext" "hashFile" + "hashString" "head" "intersectAttrs" "isAttrs" "isBool" "isFloat" "isFunction" "isInt" "isList" + "isNull" "isPath" "isString" "length" "lessThan" "listToAttrs" "map" "mapAttrs" "match" "mul" + "parseDrvName" "partition" "path" "pathExists" "placeholder" "readDir" "readFile" "removeAttrs" + "replaceStrings" "scopedImport" "seq" "sort" "split" "splitVersion" "storePath" "stringLength" + "sub" "substring" "tail" "toFile" "toJSON" "toPath" "toString" "toXML" "trace" "traceVerbose" + "tryEval" "typeOf" "unsafeDiscardOutputDependency" "unsafeDiscardStringContext" + "unsafeGetAttrPos" "zipAttrsWith" + ; primops, `__<tab>` in `nix repl` + "__add" "__filter" "__isFunction" "__split" "__addErrorContext" "__filterSource" "__isInt" + "__splitVersion" "__all" "__findFile" "__isList" "__storeDir" "__any" "__floor" "__isPath" + "__storePath" "__appendContext" "__foldl'" "__isString" "__stringLength" "__attrNames" + "__fromJSON" "__langVersion" "__sub" "__attrValues" "__functionArgs" "__length" "__substring" + "__bitAnd" "__genList" "__lessThan" "__tail" "__bitOr" "__genericClosure" "__listToAttrs" + "__toFile" "__bitXor" "__getAttr" "__mapAttrs" "__toJSON" "__catAttrs" "__getContext" "__match" + "__toPath" "__ceil" "__getEnv" "__mul" "__toXML" "__compareVersions" "__getFlake" "__nixPath" + "__trace" "__concatLists" "__groupBy" "__nixVersion" "__traceVerbose" "__concatMap" "__hasAttr" + "__parseDrvName" "__tryEval" "__concatStringsSep" "__hasContext" "__partition" "__typeOf" + "__currentSystem" "__hashFile" "__path" "__unsafeDiscardOutputDependency" "__currentTime" + "__hashString" "__pathExists" "__unsafeDiscardStringContext" "__deepSeq" "__head" "__readDir" + "__unsafeGetAttrPos" "__div" "__intersectAttrs" "__readFile" "__zipAttrsWith" "__elem" + "__isAttrs" "__replaceStrings" "__elemAt" "__isBool" "__seq" "__fetchurl" "__isFloat" "__sort")) + +; constants +(variable_expression + name: (identifier) @constant.builtin + (#any-of? @constant.builtin + ; nix eval --impure --expr 'with builtins; filter (x: !(isFunction builtins.${x} || isBool builtins.${x})) (attrNames builtins)' + "builtins" "currentSystem" "currentTime" "langVersion" "nixPath" "nixVersion" "null" "storeDir")) + +; function definition +(binding + attrpath: (attrpath + attr: (identifier) @function) + expression: (function_expression)) + +; unary operators +(unary_expression + operator: _ @operator) + +; binary operators +(binary_expression + operator: _ @operator) + +[ + "=" + "@" + "?" +] @operator + +; integers, also highlight a unary - +[ + (unary_expression + "-" + (integer_expression)) + (integer_expression) +] @number + +; floats, also highlight a unary - +[ + (unary_expression + "-" + (float_expression)) + (float_expression) +] @number.float + +; exceptions +(variable_expression + name: (identifier) @keyword.exception + (#any-of? @keyword.exception "abort" "throw")) diff --git a/runtime/queries/nix/indents.scm b/runtime/queries/nix/indents.scm new file mode 100644 index 000000000..757511b6b --- /dev/null +++ b/runtime/queries/nix/indents.scm @@ -0,0 +1,75 @@ +[ + (list_expression) + (indented_string_expression) + (let_expression) + (if_expression) + (binding) + (parenthesized_expression) +] @indent.begin + +((attrset_expression) @indent.begin + (#not-has-parent? @indent.begin if_expression)) + +((rec_attrset_expression) @indent.begin + (#not-has-parent? @indent.begin if_expression)) + +((binding + "=" @indent.begin) + (#set! indent.immediate 1)) + +(binding + ";" @indent.end) + +(parenthesized_expression + ")" @indent.branch @indent.end) + +(attrset_expression + "}" @indent.branch @indent.end) + +(rec_attrset_expression + "}" @indent.branch @indent.end) + +(list_expression + "]" @indent.branch @indent.dedent) + +(indented_string_expression + "''" @indent.branch @indent.end .) + +[ + "else" + "in" +] @indent.branch + +(let_expression + body: (_) @indent.end @indent.dedent) + +(string_fragment) @indent.ignore @indent.auto + +(if_expression + condition: (_) @indent.auto) + +alternative: (if_expression) @indent.dedent + +(interpolation) @indent.begin @indent.dedent + +(interpolation + "}" @indent.end @indent.branch) + +(ERROR + "then" @indent.begin) + +(ERROR + "then" + . + (formals) @indent.begin) + +(ERROR + "then" + . + (formals + "}" @indent.branch @indent.end)) + +(ERROR + "let") @indent.begin + +(comment) @indent.ignore diff --git a/runtime/queries/nix/injections.scm b/runtime/queries/nix/injections.scm new file mode 100644 index 000000000..26ba6e2da --- /dev/null +++ b/runtime/queries/nix/injections.scm @@ -0,0 +1,219 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((comment) @injection.language + . ; this is to make sure only adjacent comments are accounted for the injections + [ + (string_expression + (string_fragment) @injection.content) + (indented_string_expression + (string_fragment) @injection.content) + ] + (#gsub! @injection.language "/%*%s*([%w%p]+)%s*%*/" "%1") + (#set! injection.combined)) + +; #-style Comments +((comment) @injection.language + . ; this is to make sure only adjacent comments are accounted for the injections + [ + (string_expression + (string_fragment) @injection.content) + (indented_string_expression + (string_fragment) @injection.content) + ] + (#gsub! @injection.language "#%s*([%w%p]+)%s*" "%1") + (#set! injection.combined)) + +(apply_expression + function: (_) @_func + argument: [ + (string_expression + ((string_fragment) @injection.content + (#set! injection.language "regex"))) + (indented_string_expression + ((string_fragment) @injection.content + (#set! injection.language "regex"))) + ] + (#match? @_func "(^|\\.)match$") + (#set! injection.combined)) + +(binding + attrpath: (attrpath + (identifier) @_path) + expression: [ + (string_expression + ((string_fragment) @injection.content + (#set! injection.language "bash"))) + (indented_string_expression + ((string_fragment) @injection.content + (#set! injection.language "bash"))) + ] + (#match? @_path "(^\\w+(Phase|Hook|Check)|(pre|post)[A-Z]\\w+|script)$")) + +(apply_expression + function: (_) @_func + argument: (_ + (_)* + (_ + (_)* + (binding + attrpath: (attrpath + (identifier) @_path) + expression: [ + (string_expression + ((string_fragment) @injection.content + (#set! injection.language "bash"))) + (indented_string_expression + ((string_fragment) @injection.content + (#set! injection.language "bash"))) + ]))) + (#match? @_func "(^|\\.)writeShellApplication$") + (#match? @_path "^text$") + (#set! injection.combined)) + +(apply_expression + function: (apply_expression + function: (apply_expression + function: (_) @_func)) + argument: [ + (string_expression + ((string_fragment) @injection.content + (#set! injection.language "bash"))) + (indented_string_expression + ((string_fragment) @injection.content + (#set! injection.language "bash"))) + ] + (#match? @_func "(^|\\.)runCommand((No)?CC)?(Local)?$") + (#set! injection.combined)) + +((apply_expression + function: (apply_expression + function: (_) @_func) + argument: [ + (string_expression + ((string_fragment) @injection.content + (#set! injection.language "bash"))) + (indented_string_expression + ((string_fragment) @injection.content + (#set! injection.language "bash"))) + ]) + (#match? @_func "(^|\\.)write(Bash|Dash|ShellScript)(Bin)?$") + (#set! injection.combined)) + +((apply_expression + function: (apply_expression + function: (_) @_func) + argument: [ + (string_expression + ((string_fragment) @injection.content + (#set! injection.language "fish"))) + (indented_string_expression + ((string_fragment) @injection.content + (#set! injection.language "fish"))) + ]) + (#match? @_func "(^|\\.)writeFish(Bin)?$") + (#set! injection.combined)) + +((apply_expression + function: (apply_expression + function: (apply_expression + function: (_) @_func)) + argument: [ + (string_expression + ((string_fragment) @injection.content + (#set! injection.language "haskell"))) + (indented_string_expression + ((string_fragment) @injection.content + (#set! injection.language "haskell"))) + ]) + (#match? @_func "(^|\\.)writeHaskell(Bin)?$") + (#set! injection.combined)) + +((apply_expression + function: (apply_expression + function: (apply_expression + function: (_) @_func)) + argument: [ + (string_expression + ((string_fragment) @injection.content + (#set! injection.language "javascript"))) + (indented_string_expression + ((string_fragment) @injection.content + (#set! injection.language "javascript"))) + ]) + (#match? @_func "(^|\\.)writeJS(Bin)?$") + (#set! injection.combined)) + +((apply_expression + function: (apply_expression + function: (apply_expression + function: (_) @_func)) + argument: [ + (string_expression + ((string_fragment) @injection.content + (#set! injection.language "perl"))) + (indented_string_expression + ((string_fragment) @injection.content + (#set! injection.language "perl"))) + ]) + (#match? @_func "(^|\\.)writePerl(Bin)?$") + (#set! injection.combined)) + +((apply_expression + function: (apply_expression + function: (apply_expression + function: (_) @_func)) + argument: [ + (string_expression + ((string_fragment) @injection.content + (#set! injection.language "python"))) + (indented_string_expression + ((string_fragment) @injection.content + (#set! injection.language "python"))) + ]) + (#match? @_func "(^|\\.)write(PyPy|Python)[23](Bin)?$") + (#set! injection.combined)) + +((apply_expression + function: (apply_expression + function: (apply_expression + function: (_) @_func)) + argument: [ + (string_expression + ((string_fragment) @injection.content + (#set! injection.language "rust"))) + (indented_string_expression + ((string_fragment) @injection.content + (#set! injection.language "rust"))) + ]) + (#match? @_func "(^|\\.)writeRust(Bin)?$") + (#set! injection.combined)) + +; (nixosTest) testScript +((binding + attrpath: (attrpath) @_attr_name + (#eq? @_attr_name "nodes")) + (binding + attrpath: (attrpath) @_func_name + (#eq? @_func_name "testScript") + (_ + (string_fragment) @injection.content + (#set! injection.language "python"))) + (#set! injection.combined)) + +; home-manager Neovim plugin config +(attrset_expression + (binding_set + (binding + attrpath: (attrpath) @_ty_attr + (_ + (string_fragment) @_ty) + (#eq? @_ty_attr "type") + (#eq? @_ty "lua")) + (binding + attrpath: (attrpath) @_cfg_attr + (_ + (string_fragment) @injection.content + (#set! injection.language "lua")) + (#eq? @_cfg_attr "config"))) + (#set! injection.combined)) diff --git a/runtime/queries/nix/locals.scm b/runtime/queries/nix/locals.scm new file mode 100644 index 000000000..61cab2309 --- /dev/null +++ b/runtime/queries/nix/locals.scm @@ -0,0 +1,34 @@ +; let bindings +(let_expression + (binding_set + (binding + . + (attrpath) @local.definition.var))) @local.scope + +; rec attrsets +(rec_attrset_expression + (binding_set + (binding + . + (attrpath) @local.definition.field))) @local.scope + +; functions and parameters +(function_expression + . + [ + (identifier) @local.definition.parameter + (formals + (formal + . + (identifier) @local.definition.parameter)) + ]) @local.scope + +((formals) + "@" + (identifier) @local.definition.parameter) ; I couldn't get this to work properly inside the (function) + +(variable_expression + (identifier) @local.reference) + +(inherited_attrs + attr: (identifier) @local.reference) diff --git a/runtime/queries/nqc/folds.scm b/runtime/queries/nqc/folds.scm new file mode 100644 index 000000000..a5a5208ca --- /dev/null +++ b/runtime/queries/nqc/folds.scm @@ -0,0 +1 @@ +; inherits: c diff --git a/runtime/queries/nqc/highlights.scm b/runtime/queries/nqc/highlights.scm new file mode 100644 index 000000000..0d0b770a8 --- /dev/null +++ b/runtime/queries/nqc/highlights.scm @@ -0,0 +1,13 @@ +; inherits: c + +"task" @keyword.function + +"until" @keyword.repeat + +[ + "acquire" + "monitor" + "catch" + "start" + "stop" +] @keyword.coroutine diff --git a/runtime/queries/nqc/indents.scm b/runtime/queries/nqc/indents.scm new file mode 100644 index 000000000..a5a5208ca --- /dev/null +++ b/runtime/queries/nqc/indents.scm @@ -0,0 +1 @@ +; inherits: c diff --git a/runtime/queries/nqc/injections.scm b/runtime/queries/nqc/injections.scm new file mode 100644 index 000000000..a5a5208ca --- /dev/null +++ b/runtime/queries/nqc/injections.scm @@ -0,0 +1 @@ +; inherits: c diff --git a/runtime/queries/nqc/locals.scm b/runtime/queries/nqc/locals.scm new file mode 100644 index 000000000..a5a5208ca --- /dev/null +++ b/runtime/queries/nqc/locals.scm @@ -0,0 +1 @@ +; inherits: c diff --git a/runtime/queries/nu/folds.scm b/runtime/queries/nu/folds.scm new file mode 100644 index 000000000..abb538050 --- /dev/null +++ b/runtime/queries/nu/folds.scm @@ -0,0 +1,11 @@ +[ + (attribute_list) + (block) + (command_list) + (ctrl_match) + (parameter_bracks) + (record_body) + (val_list) + (val_table) + (val_closure) +] @fold diff --git a/runtime/queries/nu/highlights.scm b/runtime/queries/nu/highlights.scm new file mode 100644 index 000000000..f8342fab4 --- /dev/null +++ b/runtime/queries/nu/highlights.scm @@ -0,0 +1,377 @@ +; --- +; keywords +[ + "let" + "let-env" + "mut" + "const" + "hide-env" + "source" + "source-env" + "overlay" +] @keyword + +[ + "if" + "else" + "match" +] @keyword.conditional + +[ + "loop" + "while" + "break" + "continue" +] @keyword.repeat + +[ + "def" + "do" +] @keyword.function + +"return" @keyword.return + +[ + "try" + "catch" + "error" +] @keyword.exception + +[ + "module" + "use" +] @keyword.import + +[ + "alias" + "export-env" + "export" + "extern" +] @keyword.modifier + +(hide_mod + "hide" @keyword) + +(decl_use + module: (unquoted) @module) + +(ctrl_for + "for" @keyword + "in" @keyword) + +(overlay_list + "list" @keyword.import) + +(overlay_hide + "hide" @keyword.import) + +(overlay_new + "new" @keyword.import) + +(overlay_use + "as" @keyword) + +(ctrl_error + "make" @keyword.import) + +; --- +; literals +(val_number) @number + +(val_duration + unit: _ @variable.parameter) + +(val_filesize + unit: _ @variable.parameter) + +(val_binary + [ + "0b" + "0o" + "0x" + ] @number + digit: [ + "," @punctuation.delimiter + (hex_digit) @number + ]) @number + +(val_bool) @constant.builtin + +(val_nothing) @constant.builtin + +(val_string) @string + +arg_str: (val_string) @variable.parameter + +file_path: (val_string) @variable.parameter + +(val_date) @number + +(inter_escape_sequence) @string.escape + +(escape_sequence) @string.escape + +(val_interpolated + [ + "$\"" + "$'" + "\"" + "'" + ] @string) + +(unescaped_interpolated_content) @string + +(escaped_interpolated_content) @string + +(expr_interpolated + [ + "(" + ")" + ] @variable.parameter) + +; --- +; operators +[ + "+" + "-" + "*" + "/" + "//" + "++" + "**" + "==" + "!=" + "<" + "<=" + ">" + ">=" + "=~" + "!~" + "=" + "+=" + "-=" + "*=" + "/=" + "++=" + "-" + ".." + "..=" + "..<" + "=>" + "=" + "|" + "o>" + "out>" + "e>" + "err>" + "e+o>" + "err+out>" + "o+e>" + "out+err>" + "o>>" + "out>>" + "e>>" + "err>>" + "e+o>>" + "err+out>>" + "o+e>>" + "out+err>>" + "e>|" + "err>|" + "e+o>|" + "err+out>|" + "o+e>|" + "out+err>|" +] @operator + +[ + "mod" + "and" + "or" + "xor" + "bit-or" + "bit-xor" + "bit-and" + "bit-shl" + "bit-shr" + "in" + "not-in" + "has" + "not-has" + "starts-with" + "ends-with" + "not" +] @keyword.operator + +; --- +; punctuation +[ + "," + ";" + ":" +] @punctuation.delimiter + +(param_long_flag + "--" @punctuation.delimiter) + +(long_flag + "--" @punctuation.delimiter) + +(long_flag + "=" @punctuation.delimiter) + +(short_flag + "-" @punctuation.delimiter) + +(short_flag + "=" @punctuation.delimiter) + +(param_short_flag + "-" @punctuation.delimiter) + +(param_rest + "..." @punctuation.delimiter) + +(param_value + "=" @punctuation.delimiter) + +(param_cmd + "@" @punctuation.delimiter) + +(param_opt + "?" @punctuation.delimiter) + +(returns + "->" @punctuation.delimiter) + +[ + "(" + ")" + "{" + "}" + "[" + "]" + "...[" + "...(" + "...{" +] @punctuation.bracket + +(parameter_pipes + "|" @punctuation.bracket) + +key: (identifier) @property + +; --- +; identifiers +(param_rest + name: (_) @variable.parameter) + +(param_opt + name: (_) @variable.parameter) + +(parameter + param_name: (_) @variable.parameter) + +(param_cmd + (cmd_identifier) @string) + +(attribute + "@" @attribute) + +[ + (attribute_identifier) + (long_flag_identifier) + (param_short_flag_identifier) + (short_flag_identifier) +] @attribute + +(scope_pattern + (wild_card) @function) + +(cmd_identifier) @function + +; generated with Nu 0.93.0 +; > help commands +; | filter { $in.command_type == builtin and $in.category != core } +; | each {$'"($in.name | split row " " | $in.0)"'} +; | uniq +; | str join ' ' +(command + head: [ + (cmd_identifier) @function.builtin + (#any-of? @function.builtin + "all" "ansi" "any" "append" "ast" "bits" "bytes" "cal" "cd" "char" "clear" "collect" "columns" + "compact" "complete" "config" "cp" "date" "debug" "decode" "default" "detect" "dfr" "drop" + "du" "each" "encode" "enumerate" "every" "exec" "exit" "explain" "explore" "export-env" "fill" + "filter" "find" "first" "flatten" "fmt" "format" "from" "generate" "get" "glob" "grid" "group" + "group-by" "hash" "headers" "histogram" "history" "http" "input" "insert" "inspect" + "interleave" "into" "is-empty" "is-not-empty" "is-terminal" "items" "join" "keybindings" + "kill" "last" "length" "let-env" "lines" "load-env" "ls" "math" "merge" "metadata" "mkdir" + "mktemp" "move" "mv" "nu-check" "nu-highlight" "open" "panic" "par-each" "parse" "path" + "plugin" "port" "prepend" "print" "ps" "query" "random" "range" "reduce" "reject" "rename" + "reverse" "rm" "roll" "rotate" "run-external" "save" "schema" "select" "seq" "shuffle" "skip" + "sleep" "sort" "sort-by" "split" "split-by" "start" "stor" "str" "sys" "table" "take" "tee" + "term" "timeit" "to" "touch" "transpose" "tutor" "ulimit" "uname" "uniq" "uniq-by" "update" + "upsert" "url" "values" "view" "watch" "where" "which" "whoami" "window" "with-env" "wrap" + "zip") + ]) + +(command + "^" @punctuation.delimiter + head: (_) @function) + +"where" @function.builtin + +(path + [ + "." + "?" + ] @punctuation.delimiter) @variable.parameter + +(stmt_let + (identifier) @variable) + +(val_variable + "$"? @punctuation.special + "...$"? @punctuation.special + [ + (identifier) @variable + "in" @variable.parameter.builtin + "nu" @module + "env" @constant + ]) @none + +; --- +; types +(flat_type) @type + +(list_type + "list" @type.builtin + [ + "<" + ">" + ] @punctuation.bracket) + +(collection_type + [ + "record" + "table" + ] @type.builtin + "<" @punctuation.bracket + key: (_) @variable.parameter + [ + "," + ":" + ] @punctuation.delimiter + ">" @punctuation.bracket) + +(shebang) @keyword.directive + +(comment) @comment @spell + +((comment)+ @comment.documentation @spell + . + (decl_def)) + +(parameter + (comment) @comment.documentation @spell) diff --git a/runtime/queries/nu/indents.scm b/runtime/queries/nu/indents.scm new file mode 100644 index 000000000..94b3fa72e --- /dev/null +++ b/runtime/queries/nu/indents.scm @@ -0,0 +1,27 @@ +; Forked from https://github.com/nushell/tree-sitter-nu +; Copyright (c) 2019 - 2022 The Nushell Project Developers +; Licensed under the MIT license. +[ + (ctrl_match) + (expr_parenthesized) + (parameter_bracks) + (val_record) + (val_list) + (val_closure) + (val_table) + (block) +] @indent.begin + +[ + "}" + "]" + ")" +] @indent.end + +[ + "}" + "]" + ")" +] @indent.branch + +(comment) @indent.auto diff --git a/runtime/queries/nu/injections.scm b/runtime/queries/nu/injections.scm new file mode 100644 index 000000000..d5e70acb5 --- /dev/null +++ b/runtime/queries/nu/injections.scm @@ -0,0 +1,5 @@ +; Forked from https://github.com/nushell/tree-sitter-nu +; Copyright (c) 2019 - 2022 The Nushell Project Developers +; Licensed under the MIT license. +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/objc/folds.scm b/runtime/queries/objc/folds.scm new file mode 100644 index 000000000..b922f8bf8 --- /dev/null +++ b/runtime/queries/objc/folds.scm @@ -0,0 +1,20 @@ +; inherits: c + +[ + (class_declaration) + (class_interface) + (class_implementation) + (protocol_declaration) + (property_declaration) + (method_declaration) + (struct_declaration) + (struct_declarator) + (try_statement) + (catch_clause) + (finally_clause) + (throw_statement) + (block_literal) + (ms_asm_block) + (dictionary_literal) + (array_literal) +] @fold diff --git a/runtime/queries/objc/highlights.scm b/runtime/queries/objc/highlights.scm new file mode 100644 index 000000000..0f412404f --- /dev/null +++ b/runtime/queries/objc/highlights.scm @@ -0,0 +1,268 @@ +; inherits: c + +; Preprocs +(preproc_undef + name: (_) @constant) @keyword.directive + +; Includes +(module_import + "@import" @keyword.import + path: (identifier) @module) + +((preproc_include + _ @keyword.import + path: (_)) + (#any-of? @keyword.import "#include" "#import")) + +; Type Qualifiers +[ + "@optional" + "@required" + "__covariant" + "__contravariant" + (visibility_specification) +] @keyword.modifier + +; Storageclasses +[ + "@autoreleasepool" + "@synthesize" + "@dynamic" + "volatile" + (protocol_qualifier) +] @keyword.modifier + +; Keywords +[ + "@protocol" + "@interface" + "@implementation" + "@compatibility_alias" + "@property" + "@selector" + "@defs" + "availability" + "@end" +] @keyword + +(class_declaration + "@" @keyword.type + "class" @keyword.type) ; I hate Obj-C for allowing "@ class" :) + +(method_definition + [ + "+" + "-" + ] @keyword.function) + +(method_declaration + [ + "+" + "-" + ] @keyword.function) + +[ + "__typeof__" + "__typeof" + "typeof" + "in" +] @keyword.operator + +[ + "@synchronized" + "oneway" +] @keyword.coroutine + +; Exceptions +[ + "@try" + "__try" + "@catch" + "__catch" + "@finally" + "__finally" + "@throw" +] @keyword.exception + +; Variables +((identifier) @variable.builtin + (#any-of? @variable.builtin "self" "super")) + +; Functions & Methods +[ + "objc_bridge_related" + "@available" + "__builtin_available" + "va_arg" + "asm" +] @function.builtin + +(method_definition + (identifier) @function.method) + +(method_declaration + (identifier) @function.method) + +(method_identifier + (identifier)? @function.method + ":" @function.method + (identifier)? @function.method) + +(message_expression + method: (identifier) @function.method.call) + +; Constructors +((message_expression + method: (identifier) @constructor) + (#eq? @constructor "init")) + +; Attributes +(availability_attribute_specifier + [ + "CF_FORMAT_FUNCTION" + "NS_AVAILABLE" + "__IOS_AVAILABLE" + "NS_AVAILABLE_IOS" + "API_AVAILABLE" + "API_UNAVAILABLE" + "API_DEPRECATED" + "NS_ENUM_AVAILABLE_IOS" + "NS_DEPRECATED_IOS" + "NS_ENUM_DEPRECATED_IOS" + "NS_FORMAT_FUNCTION" + "DEPRECATED_MSG_ATTRIBUTE" + "__deprecated_msg" + "__deprecated_enum_msg" + "NS_SWIFT_NAME" + "NS_SWIFT_UNAVAILABLE" + "NS_EXTENSION_UNAVAILABLE_IOS" + "NS_CLASS_AVAILABLE_IOS" + "NS_CLASS_DEPRECATED_IOS" + "__OSX_AVAILABLE_STARTING" + "NS_ROOT_CLASS" + "NS_UNAVAILABLE" + "NS_REQUIRES_NIL_TERMINATION" + "CF_RETURNS_RETAINED" + "CF_RETURNS_NOT_RETAINED" + "DEPRECATED_ATTRIBUTE" + "UI_APPEARANCE_SELECTOR" + "UNAVAILABLE_ATTRIBUTE" + ]) @attribute + +; Macros +(type_qualifier + [ + "_Complex" + "_Nonnull" + "_Nullable" + "_Nullable_result" + "_Null_unspecified" + "__autoreleasing" + "__block" + "__bridge" + "__bridge_retained" + "__bridge_transfer" + "__complex" + "__kindof" + "__nonnull" + "__nullable" + "__ptrauth_objc_class_ro" + "__ptrauth_objc_isa_pointer" + "__ptrauth_objc_super_pointer" + "__strong" + "__thread" + "__unsafe_unretained" + "__unused" + "__weak" + ]) @function.macro + +[ + "__real" + "__imag" +] @function.macro + +((call_expression + function: (identifier) @function.macro) + (#eq? @function.macro "testassert")) + +; Types +(class_declaration + (identifier) @type) + +(class_interface + "@interface" + . + (identifier) @type + superclass: _? @type + category: _? @module) + +(class_implementation + "@implementation" + . + (identifier) @type + superclass: _? @type + category: _? @module) + +(protocol_forward_declaration + (identifier) @type) ; @interface :( + +(protocol_reference_list + (identifier) @type) ; ^ + +[ + "BOOL" + "IMP" + "SEL" + "Class" + "id" +] @type.builtin + +; Constants +(property_attribute + (identifier) @constant + "="?) + +[ + "__asm" + "__asm__" +] @constant.macro + +; Properties +(property_implementation + "@synthesize" + (identifier) @variable.member) + +((identifier) @variable.member + (#has-ancestor? @variable.member struct_declaration)) + +; Parameters +(method_parameter + ":" @function.method + (identifier) @variable.parameter) + +(method_parameter + declarator: (identifier) @variable.parameter) + +(parameter_declaration + declarator: (function_declarator + declarator: (parenthesized_declarator + (block_pointer_declarator + declarator: (identifier) @variable.parameter)))) + +"..." @variable.parameter.builtin + +; Operators +"^" @operator + +; Literals +(platform) @string.special + +(version_number) @string.special + +; Punctuation +"@" @punctuation.special + +[ + "<" + ">" +] @punctuation.bracket diff --git a/runtime/queries/objc/indents.scm b/runtime/queries/objc/indents.scm new file mode 100644 index 000000000..a5a5208ca --- /dev/null +++ b/runtime/queries/objc/indents.scm @@ -0,0 +1 @@ +; inherits: c diff --git a/runtime/queries/objc/injections.scm b/runtime/queries/objc/injections.scm new file mode 100644 index 000000000..359420d10 --- /dev/null +++ b/runtime/queries/objc/injections.scm @@ -0,0 +1,10 @@ +; inherits: c + +; TODO(amaanq): uncomment/add when I add asm support +; (ms_asm_block "{" _ @asm "}") +; +; ((asm_specifier (string_literal) @asm) +; (#offset! @asm 0 1 0 -1)) +; +; ((asm_statement (string_literal) @asm) +; (#offset! @asm 0 1 0 -1)) diff --git a/runtime/queries/objc/locals.scm b/runtime/queries/objc/locals.scm new file mode 100644 index 000000000..a5a5208ca --- /dev/null +++ b/runtime/queries/objc/locals.scm @@ -0,0 +1 @@ +; inherits: c diff --git a/runtime/queries/objdump/highlights.scm b/runtime/queries/objdump/highlights.scm new file mode 100644 index 000000000..b73e18803 --- /dev/null +++ b/runtime/queries/objdump/highlights.scm @@ -0,0 +1,60 @@ +(byte) @constant + +[ + (hexadecimal) + (integer) + (address) +] @number + +; [ +; "file" "format" +; "File" "Offset:" +; "discriminator" +; ] @none +"Disassembly of section " @markup.heading + +(section_address) @string.special + +(identifier) @variable + +(code_location + (identifier) @function.call) + +(header + (identifier) @keyword) + +(disassembly_section_label + (identifier) @module) + +(disassembly_section + (identifier) @module) + +[ + (file_offset) + (discriminator) +] @variable.member + +(file_path) @string.special.path + +(instruction) @function + +(bad_instruction) @comment.warning + +(label) @label + +[ + "<" + ">" +] @punctuation.special + +[ + "(" + ")" +] @punctuation.bracket + +[ + "+" + ":" +] @punctuation.delimiter + +(comment) @comment.documentation diff --git a/runtime/queries/objdump/injections.scm b/runtime/queries/objdump/injections.scm new file mode 100644 index 000000000..9fb52dafe --- /dev/null +++ b/runtime/queries/objdump/injections.scm @@ -0,0 +1,6 @@ +; TODO: https://github.com/nvim-treesitter/nvim-treesitter/pull/5548#issuecomment-1773707396 +; +; To be added once a compatible Assembly parser is merged into nvim-treesitter +; +; ((instruction) @injection.content +; (#set! injection.language "asm")) diff --git a/runtime/queries/ocaml/folds.scm b/runtime/queries/ocaml/folds.scm new file mode 100644 index 000000000..1d45dbbde --- /dev/null +++ b/runtime/queries/ocaml/folds.scm @@ -0,0 +1,30 @@ +[ + (let_binding) + (external) + (type_binding) + (exception_definition) + (module_binding) + (module_type_definition) + (open_module) + (include_module) + (include_module_type) + (class_binding) + (class_type_binding) + (value_specification) + (inheritance_specification) + (instance_variable_specification) + (method_specification) + (inheritance_definition) + (instance_variable_definition) + (method_definition) + (class_initializer) + (match_case) + (attribute) + (item_attribute) + (floating_attribute) + (extension) + (item_extension) + (quoted_extension) + (quoted_item_extension) + (comment) +] @fold diff --git a/runtime/queries/ocaml/highlights.scm b/runtime/queries/ocaml/highlights.scm new file mode 100644 index 000000000..891ff7bd5 --- /dev/null +++ b/runtime/queries/ocaml/highlights.scm @@ -0,0 +1,329 @@ +; Modules +;-------- +[ + (module_name) + (module_type_name) +] @module + +; Types +;------ +((type_constructor) @type.builtin + (#any-of? @type.builtin + "int" "char" "bytes" "string" "float" "bool" "unit" "exn" "array" "list" "option" "int32" + "int64" "nativeint" "format6" "lazy_t")) + +[ + (class_name) + (class_type_name) + (type_constructor) +] @type + +[ + (constructor_name) + (tag) +] @constructor + +; Variables +;---------- +[ + (value_name) + (type_variable) +] @variable + +(value_pattern) @variable.parameter + +((value_pattern) @character.special + (#eq? @character.special "_")) + +; Functions +;---------- +(let_binding + pattern: (value_name) @function + (parameter)) + +(let_binding + pattern: (value_name) @function + body: [ + (fun_expression) + (function_expression) + ]) + +(value_specification + (value_name) @function) + +(external + (value_name) @function) + +(method_name) @function.method + +; Application +;------------ +(infix_expression + left: (value_path + (value_name) @function.call) + operator: (concat_operator) @_operator + (#eq? @_operator "@@")) + +(infix_expression + operator: (rel_operator) @_operator + right: (value_path + (value_name) @function.call) + (#eq? @_operator "|>")) + +(application_expression + function: (value_path + (value_name) @function.call)) + +((value_name) @function.builtin + (#any-of? @function.builtin "raise" "raise_notrace" "failwith" "invalid_arg")) + +; Fields +;------- +[ + (field_name) + (instance_variable_name) +] @variable.member + +; Labels +; ------ +(label_name) @label + +; Constants +;---------- +; Don't let normal parens take priority over this +((unit) @constant.builtin + (#set! priority 105)) + +(boolean) @boolean + +[ + (number) + (signed_number) +] @number + +(character) @character + +(string) @string + +(quoted_string + "{" @string + "}" @string) @string + +(escape_sequence) @string.escape + +[ + (conversion_specification) + (pretty_printing_indication) +] @string.special + +; Keywords +;--------- +[ + "and" + "as" + "assert" + "begin" + "constraint" + "end" + "external" + "in" + "inherit" + "initializer" + "let" + "match" + "method" + "module" + "new" + "of" + "sig" + "val" + "when" + "with" +] @keyword + +[ + "object" + "class" + "struct" + "type" +] @keyword.type + +[ + "lazy" + "mutable" + "nonrec" + "rec" + "private" + "virtual" +] @keyword.modifier + +[ + "fun" + "function" + "functor" +] @keyword.function + +[ + "if" + "then" + "else" +] @keyword.conditional + +[ + "exception" + "try" +] @keyword.exception + +[ + "include" + "open" +] @keyword.import + +[ + "for" + "to" + "downto" + "while" + "do" + "done" +] @keyword.repeat + +; Punctuation +;------------ +(attribute + [ + "[@" + "]" + ] @punctuation.special) + +(item_attribute + [ + "[@@" + "]" + ] @punctuation.special) + +(floating_attribute + [ + "[@@@" + "]" + ] @punctuation.special) + +(extension + [ + "[%" + "]" + ] @punctuation.special) + +(item_extension + [ + "[%%" + "]" + ] @punctuation.special) + +(quoted_extension + [ + "{%" + "}" + ] @punctuation.special) + +(quoted_item_extension + [ + "{%%" + "}" + ] @punctuation.special) + +"%" @punctuation.special + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "[|" + "|]" + "[<" + "[>" +] @punctuation.bracket + +(object_type + [ + "<" + ">" + ] @punctuation.bracket) + +[ + "," + "." + ";" + ":" + "=" + "|" + "~" + "?" + "+" + "-" + "!" + ">" + "&" + "->" + ";;" + ":>" + "+=" + ":=" + ".." +] @punctuation.delimiter + +(range_pattern + ".." @character.special) + +; Operators +;---------- +[ + (prefix_operator) + (sign_operator) + (pow_operator) + (mult_operator) + (add_operator) + (concat_operator) + (rel_operator) + (and_operator) + (or_operator) + (assign_operator) + (hash_operator) + (indexing_operator) + (let_operator) + (and_operator) + (match_operator) +] @operator + +(match_expression + (match_operator) @keyword) + +(value_definition + [ + (let_operator) + (let_and_operator) + ] @keyword) + +[ + "*" + "#" + "::" + "<-" +] @operator + +; Attributes +;----------- +(attribute_id) @attribute + +; Comments +;--------- +[ + (comment) + (line_number_directive) + (directive) +] @comment @spell + +(shebang) @keyword.directive diff --git a/runtime/queries/ocaml/indents.scm b/runtime/queries/ocaml/indents.scm new file mode 100644 index 000000000..d7f05367d --- /dev/null +++ b/runtime/queries/ocaml/indents.scm @@ -0,0 +1,77 @@ +; format-ignore +[ + (let_binding) ; let = ... + (type_binding) + + (external) + (record_declaration) ; { foo: bar ... } + (structure) ; struct ... end + (signature) ; sig ... end + (value_specification) ; val x: bar + + (do_clause) ; do ... done + (match_case) + + (field_expression) + (application_expression) + (parenthesized_expression) ; ( ... ) + (record_expression) ; { foo = bar ... } + (list_expression) ; [...;...] + (try_expression) ; try ... with +] @indent.begin + +; handle if-else if-else case +(if_expression + condition: (_) @indent.begin) + +(then_clause) @indent.begin + +((else_clause + (_) @_not_if) @indent.begin + (#not-kind-eq? @_not_if "if_expression")) + +((parameter) @indent.begin + (#set! indent.start_at_same_line)) + +(_ + (ERROR) @indent.begin + (#set! indent.start_at_same_line)) + +(ERROR + "|" @indent.begin + (#set! indent.start_at_same_line)) + +(try_expression + "with" @indent.branch + [ + (match_case) @indent.dedent + (match_case + [ + (parenthesized_expression) + (list_expression) + ] @indent.dedent) + ]) + +"}" @indent.branch @indent.end + +(list_expression + "]" @indent.branch) + +(parenthesized_expression + ")" @indent.branch) + +";;" @indent.end + +(do_clause + "done" @indent.end @indent.branch) + +(structure + "end" @indent.end @indent.branch) + +(signature + "end" @indent.end @indent.branch) + +[ + (string) + (comment) +] @indent.auto diff --git a/runtime/queries/ocaml/injections.scm b/runtime/queries/ocaml/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/ocaml/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/ocaml/locals.scm b/runtime/queries/ocaml/locals.scm new file mode 100644 index 000000000..38d392609 --- /dev/null +++ b/runtime/queries/ocaml/locals.scm @@ -0,0 +1,87 @@ +; Scopes +;------- +[ + (compilation_unit) + (structure) + (signature) + (module_binding) + (functor) + (let_binding) + (match_case) + (class_binding) + (class_function) + (method_definition) + (let_expression) + (fun_expression) + (for_expression) + (let_class_expression) + (object_expression) + (attribute_payload) +] @local.scope + +; Definitions +;------------ +(value_pattern) @local.definition.var + +(let_binding + pattern: (value_name) @local.definition.var + (#set! definition.var.scope "parent")) + +(let_binding + pattern: (tuple_pattern + (value_name) @local.definition.var) + (#set! definition.var.scope "parent")) + +(let_binding + pattern: (record_pattern + (field_pattern + (value_name) @local.definition.var)) + (#set! definition.var.scope "parent")) + +(external + (value_name) @local.definition.var) + +(type_binding + (type_constructor) @local.definition.type) + +(abstract_type + (type_constructor) @local.definition.type) + +(method_definition + (method_name) @local.definition.method) + +(module_binding + (module_name) @local.definition.namespace + (#set! definition.namespace.scope "parent")) + +(module_parameter + (module_name) @local.definition.namespace) + +(module_type_definition + (module_type_name) @local.definition.type) + +; References +;------------ +(value_path + . + (value_name) @local.reference + (#set! reference.kind "var")) + +(type_constructor_path + . + (type_constructor) @local.reference + (#set! reference.kind "type")) + +(method_invocation + (method_name) @local.reference + (#set! reference.kind "method")) + +(module_path + . + (module_name) @local.reference + (#set! reference.kind "type")) + +(module_type_path + . + (module_type_name) @local.reference + (#set! reference.kind "type")) diff --git a/runtime/queries/ocaml_interface/folds.scm b/runtime/queries/ocaml_interface/folds.scm new file mode 100644 index 000000000..6d3dfbcf2 --- /dev/null +++ b/runtime/queries/ocaml_interface/folds.scm @@ -0,0 +1 @@ +; inherits: ocaml diff --git a/runtime/queries/ocaml_interface/highlights.scm b/runtime/queries/ocaml_interface/highlights.scm new file mode 100644 index 000000000..b623e432b --- /dev/null +++ b/runtime/queries/ocaml_interface/highlights.scm @@ -0,0 +1,327 @@ +; Modules +;-------- +[ + (module_name) + (module_type_name) +] @module + +; Types +;------ +((type_constructor) @type.builtin + (#any-of? @type.builtin + "int" "char" "bytes" "string" "float" "bool" "unit" "exn" "array" "list" "option" "int32" + "int64" "nativeint" "format6" "lazy_t")) + +[ + (class_name) + (class_type_name) + (type_constructor) +] @type + +[ + (constructor_name) + (tag) +] @constructor + +; Variables +;---------- +[ + (value_name) + (type_variable) +] @variable + +(value_pattern) @variable.parameter + +((value_pattern) @character.special + (#eq? @character.special "_")) + +; Functions +;---------- +(let_binding + pattern: (value_name) @function + (parameter)) + +(let_binding + pattern: (value_name) @function + body: [ + (fun_expression) + (function_expression) + ]) + +(value_specification + (value_name) @function) + +(external + (value_name) @function) + +(method_name) @function.method + +; Application +;------------ +(infix_expression + left: (value_path + (value_name) @function.call) + operator: (concat_operator) @_operator + (#eq? @_operator "@@")) + +(infix_expression + operator: (rel_operator) @_operator + right: (value_path + (value_name) @function.call) + (#eq? @_operator "|>")) + +(application_expression + function: (value_path + (value_name) @function.call)) + +((value_name) @function.builtin + (#any-of? @function.builtin "raise" "raise_notrace" "failwith" "invalid_arg")) + +; Fields +;------- +[ + (field_name) + (instance_variable_name) +] @variable.member + +; Labels +; ------ +(label_name) @label + +; Constants +;---------- +; Don't let normal parens take priority over this +((unit) @constant.builtin + (#set! priority 105)) + +(boolean) @boolean + +[ + (number) + (signed_number) +] @number + +(character) @character + +(string) @string + +(quoted_string + "{" @string + "}" @string) @string + +(escape_sequence) @string.escape + +[ + (conversion_specification) + (pretty_printing_indication) +] @string.special + +; Keywords +;--------- +[ + "and" + "as" + "assert" + "begin" + "constraint" + "end" + "external" + "in" + "inherit" + "initializer" + "let" + "match" + "method" + "module" + "new" + "of" + "sig" + "val" + "when" + "with" +] @keyword + +[ + "object" + "class" + "struct" + "type" +] @keyword.type + +[ + "lazy" + "mutable" + "nonrec" + "rec" + "private" + "virtual" +] @keyword.modifier + +[ + "fun" + "function" + "functor" +] @keyword.function + +[ + "if" + "then" + "else" +] @keyword.conditional + +[ + "exception" + "try" +] @keyword.exception + +[ + "include" + "open" +] @keyword.import + +[ + "for" + "to" + "downto" + "while" + "do" + "done" +] @keyword.repeat + +; Punctuation +;------------ +(attribute + [ + "[@" + "]" + ] @punctuation.special) + +(item_attribute + [ + "[@@" + "]" + ] @punctuation.special) + +(floating_attribute + [ + "[@@@" + "]" + ] @punctuation.special) + +(extension + [ + "[%" + "]" + ] @punctuation.special) + +(item_extension + [ + "[%%" + "]" + ] @punctuation.special) + +(quoted_extension + [ + "{%" + "}" + ] @punctuation.special) + +(quoted_item_extension + [ + "{%%" + "}" + ] @punctuation.special) + +"%" @punctuation.special + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "[|" + "|]" + "[<" + "[>" +] @punctuation.bracket + +(object_type + [ + "<" + ">" + ] @punctuation.bracket) + +[ + "," + "." + ";" + ":" + "=" + "|" + "~" + "?" + "+" + "-" + "!" + ">" + "&" + "->" + ";;" + ":>" + "+=" + ":=" + ".." +] @punctuation.delimiter + +(range_pattern + ".." @character.special) + +; Operators +;---------- +[ + (prefix_operator) + (sign_operator) + (pow_operator) + (mult_operator) + (add_operator) + (concat_operator) + (rel_operator) + (and_operator) + (or_operator) + (assign_operator) + (hash_operator) + (indexing_operator) + (let_operator) + (and_operator) + (match_operator) +] @operator + +(match_expression + (match_operator) @keyword) + +(value_definition + [ + (let_operator) + (let_and_operator) + ] @keyword) + +[ + "*" + "#" + "::" + "<-" +] @operator + +; Attributes +;----------- +(attribute_id) @attribute + +; Comments +;--------- +[ + (comment) + (line_number_directive) + (directive) +] @comment @spell diff --git a/runtime/queries/ocaml_interface/indents.scm b/runtime/queries/ocaml_interface/indents.scm new file mode 100644 index 000000000..6d3dfbcf2 --- /dev/null +++ b/runtime/queries/ocaml_interface/indents.scm @@ -0,0 +1 @@ +; inherits: ocaml diff --git a/runtime/queries/ocaml_interface/injections.scm b/runtime/queries/ocaml_interface/injections.scm new file mode 100644 index 000000000..6d3dfbcf2 --- /dev/null +++ b/runtime/queries/ocaml_interface/injections.scm @@ -0,0 +1 @@ +; inherits: ocaml diff --git a/runtime/queries/ocaml_interface/locals.scm b/runtime/queries/ocaml_interface/locals.scm new file mode 100644 index 000000000..6d3dfbcf2 --- /dev/null +++ b/runtime/queries/ocaml_interface/locals.scm @@ -0,0 +1 @@ +; inherits: ocaml diff --git a/runtime/queries/ocamllex/highlights.scm b/runtime/queries/ocamllex/highlights.scm new file mode 100644 index 000000000..2556aa4c2 --- /dev/null +++ b/runtime/queries/ocamllex/highlights.scm @@ -0,0 +1,70 @@ +; Allow OCaml highlighter +(ocaml) @none + +; Regular expressions +(regexp_name) @variable + +[ + (eof) + (any) +] @constant + +(character) @character + +(string) @string + +(escape_sequence) @string.escape + +(character_set + "^" @punctuation.special) + +(character_range + "-" @punctuation.delimiter) + +(regexp_difference + "#" @operator) + +(regexp_repetition + [ + "?" + "*" + "+" + ] @operator) + +(regexp_alternative + "|" @operator) + +; Rules +(lexer_entry_name) @function + +(lexer_argument) @variable.parameter + +(lexer_entry + [ + "=" + "|" + ] @punctuation.delimiter) + +; keywords +[ + "and" + "as" + "let" + "parse" + "refill" + "rule" + "shortest" +] @keyword + +; Punctuation +[ + "[" + "]" + "(" + ")" + "{" + "}" +] @punctuation.bracket + +; Misc +(comment) @comment @spell diff --git a/runtime/queries/ocamllex/injections.scm b/runtime/queries/ocamllex/injections.scm new file mode 100644 index 000000000..ecc577d40 --- /dev/null +++ b/runtime/queries/ocamllex/injections.scm @@ -0,0 +1,5 @@ +((ocaml) @injection.content + (#set! injection.language "ocaml")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/odin/folds.scm b/runtime/queries/odin/folds.scm new file mode 100644 index 000000000..5367cb5f2 --- /dev/null +++ b/runtime/queries/odin/folds.scm @@ -0,0 +1,7 @@ +[ + (declaration) + (statement) + (else_when_clause) + (else_if_clause) + (else_clause) +] @fold diff --git a/runtime/queries/odin/highlights.scm b/runtime/queries/odin/highlights.scm new file mode 100644 index 000000000..b7e2176a8 --- /dev/null +++ b/runtime/queries/odin/highlights.scm @@ -0,0 +1,350 @@ +; Preprocs +[ + (calling_convention) + (tag) +] @keyword.directive + +; Includes +[ + "import" + "package" +] @keyword.import + +; Keywords +[ + "foreign" + "using" + "defer" + "cast" + "transmute" + "auto_cast" + "map" + "bit_set" + "matrix" +] @keyword + +[ + "struct" + "enum" + "union" + "bit_field" +] @keyword.type + +"proc" @keyword.function + +[ + "return" + "or_return" +] @keyword.return + +[ + "distinct" + "dynamic" +] @keyword.modifier + +; Conditionals +[ + "if" + "else" + "when" + "switch" + "case" + "where" + "break" + "or_break" + "or_continue" + (fallthrough_statement) +] @keyword.conditional + +((ternary_expression + [ + "?" + ":" + "if" + "else" + "when" + ] @keyword.conditional.ternary) + (#set! priority 105)) + +; Repeats +[ + "for" + "do" + "continue" +] @keyword.repeat + +; Variables +(identifier) @variable + +; Namespaces +(package_declaration + (identifier) @module) + +(import_declaration + alias: (identifier) @module) + +(foreign_block + (identifier) @module) + +(using_statement + (identifier) @module) + +; Parameters +(parameter + (identifier) @variable.parameter + ":" + "="? + (identifier)? @constant) + +(default_parameter + (identifier) @variable.parameter + ":=") + +(named_type + (identifier) @variable.parameter) + +(call_expression + argument: (identifier) @variable.parameter + "=") + +; Functions +(procedure_declaration + (identifier) @type) + +(procedure_declaration + (identifier) @function + (procedure + (block))) + +(procedure_declaration + (identifier) @function + (procedure + (uninitialized))) + +(overloaded_procedure_declaration + (identifier) @function) + +(call_expression + function: (identifier) @function.call) + +; Types +(type + (identifier) @type) + +((type + (identifier) @type.builtin) + (#any-of? @type.builtin + "bool" "byte" "b8" "b16" "b32" "b64" "int" "i8" "i16" "i32" "i64" "i128" "uint" "u8" "u16" "u32" + "u64" "u128" "uintptr" "i16le" "i32le" "i64le" "i128le" "u16le" "u32le" "u64le" "u128le" "i16be" + "i32be" "i64be" "i128be" "u16be" "u32be" "u64be" "u128be" "float" "double" "f16" "f32" "f64" + "f16le" "f32le" "f64le" "f16be" "f32be" "f64be" "complex32" "complex64" "complex128" + "complex_float" "complex_double" "quaternion64" "quaternion128" "quaternion256" "rune" "string" + "cstring" "rawptr" "typeid" "any")) + +"..." @type.builtin + +(struct_declaration + (identifier) @type + "::") + +(enum_declaration + (identifier) @type + "::") + +(union_declaration + (identifier) @type + "::") + +(bit_field_declaration + (identifier) @type + "::") + +(const_declaration + (identifier) @type + "::" + [ + (array_type) + (distinct_type) + (bit_set_type) + (pointer_type) + ]) + +(struct + . + (identifier) @type) + +(field_type + . + (identifier) @module + "." + (identifier) @type) + +(bit_set_type + (identifier) @type + ";") + +(procedure_type + (parameters + (parameter + (identifier) @type))) + +(polymorphic_parameters + (identifier) @type) + +((identifier) @type + (#lua-match? @type "^[_A-Z][_a-zA-Z0-9]*$") + (#not-has-parent? @type parameter procedure_declaration call_expression)) + +; Fields +(member_expression + "." + (identifier) @variable.member) + +(struct_type + "{" + (identifier) @variable.member) + +(struct_field + (identifier) @variable.member + "="?) + +(field + (identifier) @variable.member) + +; Constants +((identifier) @constant + (#lua-match? @constant "^_*[A-Z][A-Z0-9_]*$") + (#not-has-parent? @constant type parameter)) + +(member_expression + . + "." + (identifier) @constant) + +(enum_declaration + "{" + (identifier) @constant) + +; Macros +((call_expression + function: (identifier) @function.macro) + (#lua-match? @function.macro "^_*[A-Z][A-Z0-9_]*$")) + +; Attributes +(attribute + (identifier) @attribute + "="?) + +; Labels +(label_statement + (identifier) @label + ":") + +; Literals +(number) @number + +(float) @number.float + +(string) @string + +(character) @character + +(escape_sequence) @string.escape + +(boolean) @boolean + +[ + (uninitialized) + (nil) +] @constant.builtin + +((identifier) @variable.builtin + (#any-of? @variable.builtin "context" "self")) + +; Operators +[ + ":=" + "=" + "+" + "-" + "*" + "/" + "%" + "%%" + ">" + ">=" + "<" + "<=" + "==" + "!=" + "~=" + "|" + "~" + "&" + "&~" + "<<" + ">>" + "||" + "&&" + "!" + "^" + ".." + "+=" + "-=" + "*=" + "/=" + "%=" + "&=" + "|=" + "^=" + "<<=" + ">>=" + "||=" + "&&=" + "&~=" + "..=" + "..<" + "?" +] @operator + +[ + "or_else" + "in" + "not_in" +] @keyword.operator + +; Punctuation +[ + "{" + "}" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "::" + "->" + "." + "," + ":" + ";" +] @punctuation.delimiter + +[ + "@" + "$" +] @punctuation.special + +; Comments +[ + (comment) + (block_comment) +] @comment @spell diff --git a/runtime/queries/odin/indents.scm b/runtime/queries/odin/indents.scm new file mode 100644 index 000000000..9c8632978 --- /dev/null +++ b/runtime/queries/odin/indents.scm @@ -0,0 +1,46 @@ +[ + (block) + (enum_declaration) + (union_declaration) + (bit_field_declaration) + (struct_declaration) + (struct) + (parameters) + (tuple_type) + (call_expression) + (switch_case) +] @indent.begin + +; hello( +((identifier) + . + (ERROR + "(" @indent.begin)) + +[ + ")" + "]" +] @indent.branch @indent.end + +; Have to do all closing brackets separately because the one for switch statements shouldn't end. +(block + "}" @indent.branch @indent.end) + +(enum_declaration + "}" @indent.branch @indent.end) + +(union_declaration + "}" @indent.branch @indent.end) + +(struct_declaration + "}" @indent.branch @indent.end) + +(struct + "}" @indent.branch @indent.end) + +[ + (comment) + (block_comment) + (string) + (ERROR) +] @indent.auto diff --git a/runtime/queries/odin/injections.scm b/runtime/queries/odin/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/odin/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/odin/locals.scm b/runtime/queries/odin/locals.scm new file mode 100644 index 000000000..3e794b2f6 --- /dev/null +++ b/runtime/queries/odin/locals.scm @@ -0,0 +1,63 @@ +; Scopes +[ + (block) + (declaration) + (statement) +] @local.scope + +; References +(identifier) @local.reference + +; Definitions +(package_declaration + (identifier) @local.definition.namespace) + +(import_declaration + alias: (identifier) @local.definition.namespace) + +(procedure_declaration + (identifier) @local.definition.function) + +(struct_declaration + (identifier) @local.definition.type + "::") + +(enum_declaration + (identifier) @local.definition.enum + "::") + +(union_declaration + (identifier) @local.definition.type + "::") + +(bit_field_declaration + (identifier) @local.definition.type + "::") + +(variable_declaration + (identifier) @local.definition.var + ":=") + +(const_declaration + (identifier) @local.definition.constant + "::") + +(const_type_declaration + (identifier) @local.definition.type + ":") + +(parameter + (identifier) @local.definition.parameter + ":"?) + +(default_parameter + (identifier) @local.definition.parameter + ":=") + +(field + (identifier) @local.definition.field + ":") + +(label_statement + (identifier) @local.definition + ":") diff --git a/runtime/queries/pascal/folds.scm b/runtime/queries/pascal/folds.scm new file mode 100644 index 000000000..8fcde3ac0 --- /dev/null +++ b/runtime/queries/pascal/folds.scm @@ -0,0 +1,31 @@ +[ + (interface) + (implementation) + (initialization) + (finalization) + (if) + (ifElse) + (while) + (repeat) + (for) + (foreach) + (try) + (case) + (caseCase) + (asm) + (with) + (declVar) + (declConst) + (declEnum) + (declProcRef) + (declExports) + (declProcRef) + (declType) + (defProc) + (declField) + (declProp) + (comment) +] @fold + +(interface + (declProc) @fold) diff --git a/runtime/queries/pascal/highlights.scm b/runtime/queries/pascal/highlights.scm new file mode 100644 index 000000000..d6014ee1d --- /dev/null +++ b/runtime/queries/pascal/highlights.scm @@ -0,0 +1,524 @@ +; -- Keywords +[ + (kProgram) + (kLibrary) + (kUnit) + (kBegin) + (kEnd) + (kAsm) + (kVar) + (kThreadvar) + (kConst) + (kConstref) + (kResourcestring) + (kOut) + (kType) + (kLabel) + (kExports) + (kProperty) + (kRead) + (kWrite) + (kImplements) + (kClass) + (kInterface) + (kObject) + (kRecord) + (kObjcclass) + (kObjccategory) + (kObjcprotocol) + (kArray) + (kFile) + (kString) + (kSet) + (kOf) + (kHelper) + (kInherited) + (kGeneric) + (kSpecialize) + (kFunction) + (kProcedure) + (kConstructor) + (kDestructor) + (kOperator) + (kReference) + (kInterface) + (kImplementation) + (kInitialization) + (kFinalization) + (kTry) + (kExcept) + (kFinally) + (kRaise) + (kOn) + (kCase) + (kWith) + (kGoto) +] @keyword + +[ + (kFor) + (kTo) + (kDownto) + (kDo) + (kWhile) + (kRepeat) + (kUntil) +] @keyword.repeat + +[ + (kIf) + (kThen) + (kElse) +] @keyword.conditional + +[ + (kPublished) + (kPublic) + (kProtected) + (kPrivate) + (kStrict) + (kRequired) + (kOptional) +] @keyword.modifier + +[ + (kPacked) + (kAbsolute) +] @keyword.modifier + +(kUses) @keyword.import + +; -- Attributes +[ + (kDefault) + (kIndex) + (kNodefault) + (kStored) + (kStatic) + (kVirtual) + (kAbstract) + (kSealed) + (kDynamic) + (kOverride) + (kOverload) + (kReintroduce) + (kInline) + (kForward) + (kStdcall) + (kCdecl) + (kCppdecl) + (kPascal) + (kRegister) + (kMwpascal) + (kExternal) + (kName) + (kMessage) + (kDeprecated) + (kExperimental) + (kPlatform) + (kUnimplemented) + (kCvar) + (kExport) + (kFar) + (kNear) + (kSafecall) + (kAssembler) + (kNostackframe) + (kInterrupt) + (kNoreturn) + (kIocheck) + (kLocal) + (kHardfloat) + (kSoftfloat) + (kMs_abi_default) + (kMs_abi_cdecl) + (kSaveregisters) + (kSysv_abi_default) + (kSysv_abi_cdecl) + (kVectorcall) + (kVarargs) + (kWinapi) + (kAlias) + (kDelayed) + (rttiAttributes) + (procAttribute) +] @attribute + +(procAttribute + (kPublic) @attribute) + +; -- Punctuation & operators +[ + "(" + ")" + "[" + "]" +] @punctuation.bracket + +[ + ";" + "," + ":" + (kEndDot) +] @punctuation.delimiter + +".." @punctuation.special + +[ + (kDot) + (kAdd) + (kSub) + (kMul) + (kFdiv) + (kAssign) + (kAssignAdd) + (kAssignSub) + (kAssignMul) + (kAssignDiv) + (kEq) + (kLt) + (kLte) + (kGt) + (kGte) + (kNeq) + (kAt) + (kHat) +] @operator + +[ + (kOr) + (kXor) + (kDiv) + (kMod) + (kAnd) + (kShl) + (kShr) + (kNot) + (kIs) + (kAs) + (kIn) +] @keyword.operator + +; -- Builtin constants +[ + (kTrue) + (kFalse) +] @boolean + +(kNil) @constant.builtin + +; -- Literals +(literalNumber) @number + +(literalString) @string + +; -- Variables +(exprBinary + (identifier) @variable) + +(exprUnary + (identifier) @variable) + +(assignment + (identifier) @variable) + +(exprBrackets + (identifier) @variable) + +(exprParens + (identifier) @variable) + +(exprDot + (identifier) @variable) + +(exprTpl + (identifier) @variable) + +(exprArgs + (identifier) @variable) + +(defaultValue + (identifier) @variable) + +; -- Comments +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) + +((comment) @comment.documentation + . + [ + (unit) + (declProc) + ]) + +(declTypes + (comment) @comment.documentation + . + (declType)) + +(declSection + (comment) @comment.documentation + . + [ + (declField) + (declProc) + ]) + +(declEnum + (comment) @comment.documentation + . + (declEnumValue)) + +(declConsts + (comment) @comment.documentation + . + (declConst)) + +(declVars + (comment) @comment.documentation + . + (declVar)) + +(pp) @keyword.directive + +; -- Type declaration +(declType + name: (identifier) @type) + +(declType + name: (genericTpl + entity: (identifier) @type)) + +; -- Procedure & function declarations +; foobar +(declProc + name: (identifier) @function) + +; foobar<t> +(declProc + name: (genericTpl + entity: (identifier) @function)) + +; foo.bar +(declProc + name: (genericDot + rhs: (identifier) @function)) + +; foo.bar<t> +(declProc + name: (genericDot + rhs: (genericTpl + entity: (identifier) @function))) + +; Treat property declarations like functions +(declProp + name: (identifier) @function) + +(declProp + getter: (identifier) @variable.member) + +(declProp + setter: (identifier) @variable.member) + +; -- Function parameters +(declArg + name: (identifier) @variable.parameter) + +; -- Template parameters +(genericArg + name: (identifier) @variable.parameter) + +(genericArg + type: (typeref) @type) + +(declProc + name: (genericDot + lhs: (identifier) @type)) + +(declType + (genericDot + (identifier) @type)) + +(genericDot + (genericTpl + (identifier) @type)) + +(genericDot + (genericDot + (identifier) @type)) + +(genericTpl + entity: (identifier) @type) + +(genericTpl + entity: (genericDot + (identifier) @type)) + +; -- Exception parameters +(exceptionHandler + variable: (identifier) @variable.parameter) + +; -- Type usage +(typeref) @type + +; -- Constant usage +[ + (caseLabel) + (label) +] @constant + +(procAttribute + (identifier) @constant) + +(procExternal + (identifier) @constant) + +; -- Variable & constant declarations +; (This is only questionable because we cannot detect types of identifiers +; declared in other units, so the results will be inconsistent) +(declVar + name: (identifier) @variable) + +(declConst + name: (identifier) @constant) + +(declEnumValue + name: (identifier) @constant) + +; -- Fields +(exprDot + rhs: (identifier) @variable.member) + +(exprDot + rhs: (exprDot) @variable.member) + +(declClass + (declField + name: (identifier) @variable.member)) + +(declSection + (declField + name: (identifier) @variable.member)) + +(declSection + (declVars + (declVar + name: (identifier) @variable.member))) + +(recInitializerField + name: (identifier) @variable.member) + +; ---------------------------------------------- ;;; +; EVERYTHING BELOW THIS IS OF QUESTIONABLE VALUE ;;; +; ---------------------------------------------- ;;; +; -- Procedure name in calls with parentheses +; (Pascal doesn't require parentheses for procedure calls, so this will not +; detect all calls) +; foobar +(exprCall + entity: (identifier) @function) + +; foobar<t> +(exprCall + entity: (exprTpl + entity: (identifier) @function)) + +; foo.bar +(exprCall + entity: (exprDot + rhs: (identifier) @function)) + +; foo.bar<t> +(exprCall + entity: (exprDot + rhs: (exprTpl + entity: (identifier) @function))) + +(inherited) @function + +; -- Heuristic for procedure/function calls without parentheses +; (If a statement consists only of an identifier, assume it's a procedure) +; (This will still not match all procedure calls, and also may produce false +; positives in rare cases, but only for nonsensical code) +(statement + (identifier) @function) + +(statement + (exprDot + rhs: (identifier) @function)) + +(statement + (exprTpl + entity: (identifier) @function)) + +(statement + (exprDot + rhs: (exprTpl + entity: (identifier) @function))) + +; -- Break, Continue & Exit +; (Not ideal: ideally, there would be a way to check if these special +; identifiers are shadowed by a local variable) +(statement + ((identifier) @keyword.return + (#lua-match? @keyword.return "^[eE][xX][iI][tT]$"))) + +(statement + (exprCall + entity: ((identifier) @keyword.return + (#lua-match? @keyword.return "^[eE][xX][iI][tT]$")))) + +(statement + ((identifier) @keyword.repeat + (#lua-match? @keyword.repeat "^[bB][rR][eE][aA][kK]$"))) + +(statement + ((identifier) @keyword.repeat + (#lua-match? @keyword.repeat "^[cC][oO][nN][tT][iI][nN][uU][eE]$"))) + +; -- Identifier type inference +; VERY QUESTIONABLE: Highlighting of identifiers based on spelling +(exprBinary + ((identifier) @constant + (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$"))) + +(exprUnary + ((identifier) @constant + (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$"))) + +(assignment + rhs: ((identifier) @constant + (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$"))) + +(exprBrackets + ((identifier) @constant + (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$"))) + +(exprParens + ((identifier) @constant + (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$"))) + +(exprDot + rhs: ((identifier) @constant + (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$"))) + +(exprTpl + args: ((identifier) @constant + (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$"))) + +(exprArgs + ((identifier) @constant + (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$"))) + +(declEnumValue + ((identifier) @constant + (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$"))) + +(defaultValue + ((identifier) @constant + (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$"))) diff --git a/runtime/queries/pascal/indents.scm b/runtime/queries/pascal/indents.scm new file mode 100644 index 000000000..879e7b86f --- /dev/null +++ b/runtime/queries/pascal/indents.scm @@ -0,0 +1,33 @@ +[ + (statement) + (declVars) + (declConsts) + (declTypes) + (declProc) + (declArgs) + (declUses) + (declClass) + (exprArgs) + (exprSubscript) + (exprBrackets) + (exprParens) + (recInitializer) + (arrInitializer) + (defaultValue) +] @indent.begin + +(defProc + (block) @indent.begin) + +[ + (kEnd) + (kFinally) + (kDo) + (kUntil) + (kExcept) + (kElse) + (kThen) + (declSection) + "]" + ")" +] @indent.branch diff --git a/runtime/queries/pascal/injections.scm b/runtime/queries/pascal/injections.scm new file mode 100644 index 000000000..1f6e475c8 --- /dev/null +++ b/runtime/queries/pascal/injections.scm @@ -0,0 +1,5 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((asmBody) @injection.content + (#set! injection.language "asm")) diff --git a/runtime/queries/pascal/locals.scm b/runtime/queries/pascal/locals.scm new file mode 100644 index 000000000..d74d54ad4 --- /dev/null +++ b/runtime/queries/pascal/locals.scm @@ -0,0 +1,54 @@ +(root) @local.scope + +(defProc) @local.scope + +(lambda) @local.scope + +(interface + (declProc) @local.scope) + +(declSection + (declProc) @local.scope) + +(declClass + (declProc) @local.scope) + +(declHelper + (declProc) @local.scope) + +(declProcRef) @local.scope + +(exceptionHandler) @local.scope + +(exceptionHandler + variable: (identifier) @local.definition) + +(declArg + name: (identifier) @local.definition) + +(declVar + name: (identifier) @local.definition) + +(declConst + name: (identifier) @local.definition) + +(declLabel + name: (identifier) @local.definition) + +(genericArg + name: (identifier) @local.definition) + +(declEnumValue + name: (identifier) @local.definition) + +(declType + name: (identifier) @local.definition) + +(declType + name: (genericTpl + entity: (identifier) @local.definition)) + +(declProc + name: (identifier) @local.definition) + +(identifier) @local.reference diff --git a/runtime/queries/passwd/highlights.scm b/runtime/queries/passwd/highlights.scm new file mode 100644 index 000000000..51bb8fc5f --- /dev/null +++ b/runtime/queries/passwd/highlights.scm @@ -0,0 +1,16 @@ +(user) @module + +(auth) @string.special.symbol + +(gecos) @string + +(home) @string.special.path + +(shell) @string.special.path + +[ + (gid) + (uid) +] @number + +(separator) @punctuation.delimiter diff --git a/runtime/queries/pem/folds.scm b/runtime/queries/pem/folds.scm new file mode 100644 index 000000000..f0cdabd26 --- /dev/null +++ b/runtime/queries/pem/folds.scm @@ -0,0 +1 @@ +(content) @fold diff --git a/runtime/queries/pem/highlights.scm b/runtime/queries/pem/highlights.scm new file mode 100644 index 000000000..b8dbb0f11 --- /dev/null +++ b/runtime/queries/pem/highlights.scm @@ -0,0 +1,12 @@ +[ + "BEGIN" + "END" +] @keyword + +(dashes) @punctuation.delimiter + +(label) @label + +(data) @none + +(comment) @comment @spell diff --git a/runtime/queries/pem/injections.scm b/runtime/queries/pem/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/pem/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/perl/folds.scm b/runtime/queries/perl/folds.scm new file mode 100644 index 000000000..a457a0a50 --- /dev/null +++ b/runtime/queries/perl/folds.scm @@ -0,0 +1,36 @@ +(comment)+ @fold + +(pod) @fold + +; fold the block-typed package and class statements only +(package_statement + (block)) @fold + +(class_statement + (block)) @fold + +[ + (subroutine_declaration_statement) + (method_declaration_statement) + (conditional_statement) + (loop_statement) + (for_statement) + (cstyle_for_statement) + (block_statement) + (defer_statement) + (phaser_statement) +] @fold + +(try_statement + (block) @fold) + +(eval_expression + (block) @fold) + +(anonymous_subroutine_expression) @fold + +; perhaps folks want to fold these too? +[ + (anonymous_array_expression) + (anonymous_hash_expression) +] @fold diff --git a/runtime/queries/perl/highlights.scm b/runtime/queries/perl/highlights.scm new file mode 100644 index 000000000..d52baab44 --- /dev/null +++ b/runtime/queries/perl/highlights.scm @@ -0,0 +1,324 @@ +((source_file + . + (comment) @keyword.directive @nospell) + (#lua-match? @keyword.directive "^#!/")) + +[ + "use" + "no" + "require" +] @keyword.import + +[ + "if" + "elsif" + "unless" + "else" +] @keyword.conditional + +(conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +[ + "while" + "until" + "for" + "foreach" +] @keyword.repeat + +("continue" @keyword.repeat + (block)) + +[ + "try" + "catch" + "finally" +] @keyword.exception + +"return" @keyword.return + +[ + "sub" + "method" +] @keyword.function + +[ + "async" + "await" +] @keyword.coroutine + +[ + "map" + "grep" + "sort" +] @function.builtin + +[ + "package" + "class" + "role" +] @keyword.import + +[ + "defer" + "do" + "eval" + "my" + "our" + "local" + "dynamically" + "state" + "field" + "last" + "next" + "redo" + "goto" + "undef" +] @keyword + +(_ + operator: _ @operator) + +"\\" @operator + +(yadayada) @keyword.exception + +(phaser_statement + phase: _ @keyword) + +(class_phaser_statement + phase: _ @keyword) + +[ + "or" + "xor" + "and" + "eq" + "equ" + "eqr" + "ne" + "cmp" + "lt" + "le" + "ge" + "gt" + "isa" +] @keyword.operator + +(eof_marker) @keyword.directive + +(data_section) @comment + +(pod) @none + +[ + (number) + (version) +] @number + +(boolean) @boolean + +[ + (string_literal) + (interpolated_string_literal) + (quoted_word_list) + (command_string) + (heredoc_content) + (replacement) + (transliteration_content) +] @string + +[ + (heredoc_token) + (command_heredoc_token) + (heredoc_end) +] @label + +[ + (escape_sequence) + (escaped_delimiter) +] @string.escape + +(_ + modifiers: _ @character.special) + +[ + (quoted_regexp) + (match_regexp) + (regexp_content) +] @string.regexp + +(autoquoted_bareword) @string.special + +(use_statement + (package) @type) + +(package_statement + (package) @type) + +(class_statement + (package) @type) + +(require_expression + (bareword) @type) + +(subroutine_declaration_statement + name: (bareword) @function) + +(method_declaration_statement + name: (bareword) @function) + +(attribute_name) @attribute + +(attribute_value) @string + +(label) @label + +(statement_label + label: _ @label) + +(relational_expression + operator: "isa" + right: (bareword) @type) + +(function_call_expression + (function) @function.call) + +(method_call_expression + (method) @function.method.call) + +(method_call_expression + invocant: (bareword) @type) + +(func0op_call_expression + function: _ @function.builtin) + +(func1op_call_expression + function: _ @function.builtin) + +; this was a regex for the CLI +([ + (function) + (expression_statement + (bareword)) +] @function.builtin + (#any-of? @function.builtin + "accept" "atan2" "bind" "binmode" "bless" "crypt" "chmod" "chown" "connect" "die" "dbmopen" + "exec" "fcntl" "flock" "formline" "getpriority" "getprotobynumber" "gethostbyaddr" + "getnetbyaddr" "getservbyname" "getservbyport" "getsockopt" "glob" "index" "ioctl" "join" "kill" + "link" "listen" "mkdir" "msgctl" "msgget" "msgrcv" "msgsend" "open" "opendir" "print" "printf" + "push" "pack" "pipe" "return" "rename" "rindex" "read" "recv" "reverse" "say" "select" "seek" + "semctl" "semget" "semop" "send" "setpgrp" "setpriority" "seekdir" "setsockopt" "shmctl" + "shmread" "shmwrite" "shutdown" "socket" "socketpair" "split" "sprintf" "splice" "substr" + "system" "symlink" "syscall" "sysopen" "sysseek" "sysread" "syswrite" "tie" "truncate" "unlink" + "unpack" "utime" "unshift" "vec" "warn" "waitpid")) + +(function) @function + +(_ + "{" @punctuation.special + (varname) + "}" @punctuation.special) + +(varname + (block + "{" @punctuation.special + "}" @punctuation.special)) + +([ + (varname) + (filehandle) +] @variable.builtin + (#any-of? @variable.builtin + "ENV" "ARGV" "INC" "ARGVOUT" "SIG" "STDIN" "STDOUT" "STDERR" "a" "b" "_")) + +((varname) @variable.builtin + ; highlights all the reserved ^ vars like ${^THINGS} + (#lua-match? @variable.builtin "%^")) + +((varname) @variable.builtin + ; highlights punc vars and also numeric only like $11 + (#lua-match? @variable.builtin "^%A+$")) + +[ + (scalar) + (array) + (hash) + (glob) + ; arraylen's sigil is kinda special b/c it's not a data type + (arraylen + "$#" @operator) +] @variable + +; all post deref sigils highlighted as operators, and the unrolly star is a special char +(postfix_deref + [ + "$" + "@" + "%" + "*" + "$#" + ] @operator + "*" @character.special) + +(slices + [ + arrayref: _ + hashref: _ + ] + [ + "@" + "%" + ] @operator) + +; except for subref deref, b/c that's actually a function call +(amper_deref_expression + [ + "&" + "*" + ] @function.call) + +; mark hash or glob keys that are any form of string in any form of access +(_ + "{" + [ + (autoquoted_bareword) + (_ + (string_content)) + ] @variable.member + "}") + +; mark stringies on the LHS of a fat comma as a hash key, b/c that's usually what it +; denotes somewhat +(_ + [ + (autoquoted_bareword) + (_ + (string_content)) + ] @variable.member + . + "=>" + (_)) + +(comment) @comment @spell + +[ + "=>" + "," + ";" + "->" +] @punctuation.delimiter + +([ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket + ; priority hack so nvim + ts-cli behave the same + (#set! priority 90)) diff --git a/runtime/queries/perl/injections.scm b/runtime/queries/perl/injections.scm new file mode 100644 index 000000000..ec11e9013 --- /dev/null +++ b/runtime/queries/perl/injections.scm @@ -0,0 +1,15 @@ +; an injections.scm file for nvim-treesitter +((comment) @injection.content + (#set! injection.language "comment")) + +((pod) @injection.content + (#set! injection.language "pod")) + +((substitution_regexp + (replacement) @injection.content + (substitution_regexp_modifiers) @_modifiers) + ; match if there's a single `e` in the modifiers list + (#lua-match? @_modifiers "e") + (#not-lua-match? @_modifiers "e.*e") + (#set! injection.language "perl") + (#set! injection.include-children)) diff --git a/runtime/queries/php/folds.scm b/runtime/queries/php/folds.scm new file mode 100644 index 000000000..f32463888 --- /dev/null +++ b/runtime/queries/php/folds.scm @@ -0,0 +1 @@ +; inherits: php_only diff --git a/runtime/queries/php/highlights.scm b/runtime/queries/php/highlights.scm new file mode 100644 index 000000000..f32463888 --- /dev/null +++ b/runtime/queries/php/highlights.scm @@ -0,0 +1 @@ +; inherits: php_only diff --git a/runtime/queries/php/indents.scm b/runtime/queries/php/indents.scm new file mode 100644 index 000000000..f32463888 --- /dev/null +++ b/runtime/queries/php/indents.scm @@ -0,0 +1 @@ +; inherits: php_only diff --git a/runtime/queries/php/injections.scm b/runtime/queries/php/injections.scm new file mode 100644 index 000000000..3ccbb2bb4 --- /dev/null +++ b/runtime/queries/php/injections.scm @@ -0,0 +1,5 @@ +; inherits: php_only + +((text) @injection.content + (#set! injection.language "html") + (#set! injection.combined)) diff --git a/runtime/queries/php/locals.scm b/runtime/queries/php/locals.scm new file mode 100644 index 000000000..f32463888 --- /dev/null +++ b/runtime/queries/php/locals.scm @@ -0,0 +1 @@ +; inherits: php_only diff --git a/runtime/queries/php_only/folds.scm b/runtime/queries/php_only/folds.scm new file mode 100644 index 000000000..43453b174 --- /dev/null +++ b/runtime/queries/php_only/folds.scm @@ -0,0 +1,17 @@ +[ + (if_statement) + (switch_statement) + (while_statement) + (do_statement) + (for_statement) + (foreach_statement) + (try_statement) + (function_definition) + (class_declaration) + (interface_declaration) + (trait_declaration) + (enum_declaration) + (function_static_declaration) + (method_declaration) + (namespace_use_declaration)+ +] @fold diff --git a/runtime/queries/php_only/highlights.scm b/runtime/queries/php_only/highlights.scm new file mode 100644 index 000000000..2d473dd0c --- /dev/null +++ b/runtime/queries/php_only/highlights.scm @@ -0,0 +1,479 @@ +; Keywords +[ + "and" + "as" + "instanceof" + "or" + "xor" +] @keyword.operator + +[ + "fn" + "function" +] @keyword.function + +[ + "clone" + "declare" + "default" + "echo" + "enddeclare" + "extends" + "global" + "goto" + "implements" + "insteadof" + "print" + "new" + "unset" +] @keyword + +[ + "enum" + "class" + "interface" + "namespace" + "trait" +] @keyword.type + +[ + "abstract" + "const" + "final" + "private" + "protected" + "public" + "readonly" + (static_modifier) +] @keyword.modifier + +(function_static_declaration + "static" @keyword.modifier) + +[ + "return" + "exit" + "yield" +] @keyword.return + +(yield_expression + "from" @keyword.return) + +[ + "case" + "else" + "elseif" + "endif" + "endswitch" + "if" + "switch" + "match" + "??" +] @keyword.conditional + +[ + "break" + "continue" + "do" + "endfor" + "endforeach" + "endwhile" + "for" + "foreach" + "while" +] @keyword.repeat + +[ + "catch" + "finally" + "throw" + "try" +] @keyword.exception + +[ + "include_once" + "include" + "require_once" + "require" + "use" +] @keyword.import + +[ + "," + ";" + ":" + "\\" +] @punctuation.delimiter + +[ + (php_tag) + "?>" + "(" + ")" + "[" + "]" + "{" + "}" + "#[" +] @punctuation.bracket + +[ + "=" + "." + "-" + "*" + "/" + "+" + "%" + "**" + "~" + "|" + "^" + "&" + "<<" + ">>" + "<<<" + "->" + "?->" + "=>" + "<" + "<=" + ">=" + ">" + "<>" + "<=>" + "==" + "!=" + "===" + "!==" + "!" + "&&" + "||" + ".=" + "-=" + "+=" + "*=" + "/=" + "%=" + "**=" + "&=" + "|=" + "^=" + "<<=" + ">>=" + "??=" + "--" + "++" + "@" + "::" +] @operator + +; Variables +(variable_name) @variable + +; Constants +((name) @constant + (#lua-match? @constant "^_?[A-Z][A-Z%d_]*$")) + +((name) @constant.builtin + (#lua-match? @constant.builtin "^__[A-Z][A-Z%d_]+__$")) + +(const_declaration + (const_element + (name) @constant)) + +; Types +[ + (primitive_type) + (cast_type) + (bottom_type) +] @type.builtin + +(named_type + [ + (name) @type + (qualified_name + (name) @type) + (relative_name + (name) @type) + ]) + +(named_type + (name) @type.builtin + (#any-of? @type.builtin "static" "self")) + +(class_declaration + name: (name) @type) + +(base_clause + [ + (name) @type + (qualified_name + (name) @type) + (relative_name + (name) @type) + ]) + +(enum_declaration + name: (name) @type) + +(interface_declaration + name: (name) @type) + +(namespace_use_clause + [ + (name) @type + (qualified_name + (name) @type) + alias: (name) @type.definition + ]) + +(namespace_use_clause + type: "function" + [ + (name) @function + (qualified_name + (name) @function) + alias: (name) @function + ]) + +(namespace_use_declaration + type: "function" + body: (namespace_use_group + (namespace_use_clause + [ + (name) @function + (qualified_name + (name) @function) + alias: (name) @function + ]))) + +(namespace_use_clause + type: "const" + [ + (name) @constant + (qualified_name + (name) @constant) + alias: (name) @constant + ]) + +(namespace_use_declaration + type: "const" + body: (namespace_use_group + (namespace_use_clause + [ + (name) @constant + (qualified_name + (name) @constant) + alias: (name) @constant + ]))) + +(class_interface_clause + [ + (name) @type + (qualified_name + (name) @type) + (relative_name + (name) @type) + ]) + +(scoped_call_expression + scope: [ + (name) @type + (qualified_name + (name) @type) + (relative_name + (name) @type) + ]) + +(class_constant_access_expression + . + [ + (name) @type + (qualified_name + (name) @type) + (relative_name + (name) @type) + ] + (name) @constant) + +(scoped_property_access_expression + scope: [ + (name) @type + (qualified_name + (name) @type) + (relative_name + (name) @type) + ]) + +(scoped_property_access_expression + name: (variable_name) @variable.member) + +(trait_declaration + name: (name) @type) + +(use_declaration + (name) @type) + +(binary_expression + operator: "instanceof" + right: [ + (name) @type + (qualified_name + (name) @type) + (relative_name + (name) @type) + ]) + +; Functions, methods, constructors +(array_creation_expression + "array" @function.builtin) + +(list_literal + "list" @function.builtin) + +(exit_statement + "exit" @function.builtin + "(") + +(method_declaration + name: (name) @function.method) + +(function_call_expression + function: [ + (name) @function.call + (qualified_name + (name) @function.call) + (relative_name + (name) @function.call) + ]) + +(scoped_call_expression + name: (name) @function.call) + +(member_call_expression + name: (name) @function.method.call) + +(function_definition + name: (name) @function) + +(nullsafe_member_call_expression + name: (name) @function.method) + +(use_instead_of_clause + (class_constant_access_expression + (_) + (name) @function.method) + (name) @type) + +(use_as_clause + (class_constant_access_expression + (_) + (name) @function.method)* + (name) @function.method) + +(method_declaration + name: (name) @constructor + (#eq? @constructor "__construct")) + +(object_creation_expression + [ + (name) @constructor + (qualified_name + (name) @constructor) + (relative_name + (name) @constructor) + ]) + +; Parameters +(variadic_parameter + "..." @operator + name: (variable_name) @variable.parameter) + +(simple_parameter + name: (variable_name) @variable.parameter) + +(argument + (name) @variable.parameter) + +; Member +(property_element + (variable_name) @property) + +(member_access_expression + name: (variable_name + (name)) @variable.member) + +(member_access_expression + name: (name) @variable.member) + +(nullsafe_member_access_expression + name: (variable_name + (name)) @variable.member) + +(nullsafe_member_access_expression + name: (name) @variable.member) + +; Variables +(relative_scope) @variable.builtin + +((variable_name) @variable.builtin + (#eq? @variable.builtin "$this")) + +; Namespace +(namespace_definition + name: (namespace_name + (name) @module)) + +(namespace_name + (name) @module) + +(relative_name + "namespace" @module.builtin) + +; Attributes +(attribute_list) @attribute + +; Conditions ( ? : ) +(conditional_expression + "?" @keyword.conditional.ternary + ":" @keyword.conditional.ternary) + +; Directives +(declare_directive + [ + "strict_types" + "ticks" + "encoding" + ] @variable.parameter) + +; Basic tokens +[ + (string) + (encapsed_string) + (heredoc_body) + (nowdoc_body) + (shell_command_expression) ; backtick operator: `ls -la` +] @string + +(escape_sequence) @string.escape + +[ + (heredoc_start) + (heredoc_end) +] @label + +(nowdoc + "'" @label) + +(boolean) @boolean + +(null) @constant.builtin + +(integer) @number + +(float) @number.float + +(comment) @comment @spell + +(named_label_statement) @label diff --git a/runtime/queries/php_only/indents.scm b/runtime/queries/php_only/indents.scm new file mode 100644 index 000000000..1755d4285 --- /dev/null +++ b/runtime/queries/php_only/indents.scm @@ -0,0 +1,68 @@ +[ + (array_creation_expression) + (parenthesized_expression) + (compound_statement) + (declaration_list) + (member_call_expression) + (binary_expression) + (return_statement) + (arguments) + (formal_parameters) + (enum_declaration_list) + (switch_block) + (match_block) + (case_statement) + (default_statement) + (property_hook_list) +] @indent.begin + +(return_statement + [ + (object_creation_expression) + (anonymous_function) + (arrow_function) + (match_expression) + ]) @indent.dedent + +[ + ")" + "}" + "]" +] @indent.branch + +(comment) @indent.auto + +(arguments + ")" @indent.end) + +(formal_parameters + ")" @indent.end) + +(compound_statement + "}" @indent.end) + +(declaration_list + "}" @indent.end) + +(enum_declaration_list + "}" @indent.end) + +(return_statement + ";" @indent.end) + +(property_hook_list + "}" @indent.end) + +(ERROR + "(" @indent.align + . + (_) + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +(ERROR + "[" @indent.align + . + (_) + (#set! indent.open_delimiter "[") + (#set! indent.close_delimiter "]")) diff --git a/runtime/queries/php_only/injections.scm b/runtime/queries/php_only/injections.scm new file mode 100644 index 000000000..368177643 --- /dev/null +++ b/runtime/queries/php_only/injections.scm @@ -0,0 +1,43 @@ +((comment) @injection.content + (#set! injection.language "phpdoc")) + +(heredoc + (heredoc_body) @injection.content + (heredoc_end) @injection.language + (#set! injection.include-children) + (#downcase! @injection.language)) + +(nowdoc + (nowdoc_body) @injection.content + (heredoc_end) @injection.language + (#set! injection.include-children) + (#downcase! @injection.language)) + +; regex +((function_call_expression + function: (_) @_preg_func_identifier + arguments: (arguments + . + (argument + (_ + (string_content) @injection.content)))) + (#set! injection.language "regex") + (#lua-match? @_preg_func_identifier "^preg_")) + +; bash +((function_call_expression + function: (_) @_shell_func_identifier + arguments: (arguments + . + (argument + (_ + (string_content) @injection.content)))) + (#set! injection.language "bash") + (#any-of? @_shell_func_identifier + "shell_exec" "escapeshellarg" "escapeshellcmd" "exec" "passthru" "proc_open" "shell_exec" + "system")) + +(expression_statement + (shell_command_expression + (string_content) @injection.content) + (#set! injection.language "bash")) diff --git a/runtime/queries/php_only/locals.scm b/runtime/queries/php_only/locals.scm new file mode 100644 index 000000000..6739b383d --- /dev/null +++ b/runtime/queries/php_only/locals.scm @@ -0,0 +1,84 @@ +; Scopes +;------- +((class_declaration + name: (name) @local.definition.type) @local.scope + (#set! definition.type.scope "parent")) + +((method_declaration + name: (name) @local.definition.method) @local.scope + (#set! definition.method.scope "parent")) + +((function_definition + name: (name) @local.definition.function) @local.scope + (#set! definition.function.scope "parent")) + +(anonymous_function + (anonymous_function_use_clause + (variable_name + (name) @local.definition.var))) @local.scope + +; Definitions +;------------ +(simple_parameter + (variable_name + (name) @local.definition.var)) + +(foreach_statement + (pair + (variable_name + (name) @local.definition.var))) + +(foreach_statement + (variable_name + (name) @local.reference + (#set! reference.kind "var")) + (variable_name + (name) @local.definition.var)) + +(property_declaration + (property_element + (variable_name + (name) @local.definition.field))) + +(namespace_use_clause + (qualified_name + (name) @local.definition.type)) + +; References +;------------ +(named_type + (name) @local.reference + (#set! reference.kind "type")) + +(named_type + (qualified_name) @local.reference + (#set! reference.kind "type")) + +(variable_name + (name) @local.reference + (#set! reference.kind "var")) + +(member_access_expression + name: (name) @local.reference + (#set! reference.kind "field")) + +(member_call_expression + name: (name) @local.reference + (#set! reference.kind "method")) + +(function_call_expression + function: (qualified_name + (name) @local.reference + (#set! reference.kind "function"))) + +(object_creation_expression + (qualified_name + (name) @local.reference + (#set! reference.kind "type"))) + +(scoped_call_expression + scope: (qualified_name + (name) @local.reference + (#set! reference.kind "type")) + name: (name) @local.reference + (#set! reference.kind "method")) diff --git a/runtime/queries/phpdoc/highlights.scm b/runtime/queries/phpdoc/highlights.scm new file mode 100644 index 000000000..3ebe4a66e --- /dev/null +++ b/runtime/queries/phpdoc/highlights.scm @@ -0,0 +1,72 @@ +(tag_name) @attribute @nospell + +(tag + (tag_name) @_tag + (#eq? @_tag "@param") + (variable_name) @variable.parameter) + +(tag + (tag_name) @_tag + (#eq? @_tag "@property") + (variable_name) @variable.member) + +(tag + (tag_name) @_tag + (#eq? @_tag "@var") + (variable_name) @variable) + +(tag + (tag_name) @_tag + (#eq? @_tag "@function.method") + (name) @function.method) + +(parameter + (variable_name) @variable.parameter) + +[ + (array_type) + (primitive_type) + (named_type) + (optional_type) +] @type + +(union_type + [ + (array_type) + (primitive_type) + (named_type) + (optional_type) + ] @type) + +(union_type) @nospell + +(variable_name) @nospell + +(tag + (description + (text) @none @spell)) + +(tag + [ + (author_name) + (version) + ] @none) + +(tag + (email_address) @string.special.url) + +(union_type + "|" @keyword) + +(variable_name + "$" @keyword) + +(tag + (tag_name) @_tag_name + [ + "<" + ">" + ] @keyword + (#eq? @_tag_name "@author")) + +(text) @spell diff --git a/runtime/queries/pioasm/highlights.scm b/runtime/queries/pioasm/highlights.scm new file mode 100644 index 000000000..325005928 --- /dev/null +++ b/runtime/queries/pioasm/highlights.scm @@ -0,0 +1,93 @@ +[ + (line_comment) + (block_comment) +] @comment @spell + +(label_decl) @label + +(string) @string + +(instruction + opcode: _ @function.call) + +[ + "pins" + "x" + "y" + "null" + "isr" + "osr" + "osre" + "status" + "pc" + "exec" +] @constant.builtin + +(wait_source + [ + "irq" + "gpio" + "pin" + ] @constant.builtin) + +(out_target + "pindirs" @constant.builtin) + +(set_target + "pindirs" @constant.builtin) + +(directive + "pindirs" @attribute) + +(condition + [ + "--" + "!=" + ] @operator) + +(expression + [ + "+" + "-" + "*" + "/" + "|" + "&" + "^" + "::" + ] @operator) + +(not) @operator + +[ + (optional) + (irq_modifiers) +] @keyword.modifier + +[ + "block" + "noblock" + "rel" +] @attribute + +[ + "iffull" + "ifempty" +] @keyword.conditional + +"public" @keyword.modifier + +(integer) @number + +(directive + (identifier) @variable) + +(directive + (symbol_def + (identifier) @variable)) + +(value + (identifier) @variable) + +(directive + directive: _ @keyword.directive) diff --git a/runtime/queries/pioasm/injections.scm b/runtime/queries/pioasm/injections.scm new file mode 100644 index 000000000..84d17cf2d --- /dev/null +++ b/runtime/queries/pioasm/injections.scm @@ -0,0 +1,15 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) + +((code_block + (code_block_language) @_language + (code_block_body) @injection.content) + (#eq? @_language "c-sdk") + (#set! injection.language "c")) + +(code_block + (code_block_language) @injection.language + (code_block_body) @injection.content) diff --git a/runtime/queries/po/folds.scm b/runtime/queries/po/folds.scm new file mode 100644 index 000000000..fd1fb1ebf --- /dev/null +++ b/runtime/queries/po/folds.scm @@ -0,0 +1,8 @@ +[ + (msgctxt) + (msgid) + (msgid_plural) + (msgstr) + (msgstr_plural) + (message) +] @fold diff --git a/runtime/queries/po/highlights.scm b/runtime/queries/po/highlights.scm new file mode 100644 index 000000000..0cc92e72a --- /dev/null +++ b/runtime/queries/po/highlights.scm @@ -0,0 +1,32 @@ +; Keywords +[ + "msgctxt" + "msgid" + "msgid_plural" + "msgstr" + "msgstr_plural" +] @keyword + +; Punctuation +[ + "[" + "]" +] @punctuation.bracket + +; Literals +(string) @string + +(escape_sequence) @string.escape + +(number) @number + +; Comments +(comment) @comment @spell + +(comment + (reference + (text) @string.special.path)) + +(comment + (flag + (text) @keyword.directive)) diff --git a/runtime/queries/po/injections.scm b/runtime/queries/po/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/po/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/pod/highlights.scm b/runtime/queries/pod/highlights.scm new file mode 100644 index 000000000..8252ac1ba --- /dev/null +++ b/runtime/queries/pod/highlights.scm @@ -0,0 +1,76 @@ +; A highlight file for nvim-treesitter to use +[ + (pod_command) + (command) + (cut_command) +] @keyword + +((command_paragraph + (command) @keyword + (content) @string) + (#set! priority 99)) + +(command_paragraph + (command) @keyword + (#lua-match? @keyword "^=head") + (content) @markup.heading) + +(command_paragraph + (command) @keyword + (#lua-match? @keyword "^=over") + (content) @number) + +(command_paragraph + (command) @keyword + (#lua-match? @keyword "^=item") + (content) @none) + +(command_paragraph + (command) @keyword + (#lua-match? @keyword "^=encoding") + (content) @string.special) + +(verbatim_paragraph + (content) @markup.raw) + +(interior_sequence + (sequence_letter) @character + [ + "<" + ">" + ] @punctuation.delimiter) + +(interior_sequence + (sequence_letter) @character + (#eq? @character "B") + (content) @markup.strong) + +(interior_sequence + (sequence_letter) @character + (#eq? @character "C") + (content) @markup.raw) + +(interior_sequence + (sequence_letter) @character + (#eq? @character "F") + (content) @string.special.path) + +(interior_sequence + (sequence_letter) @character + (#eq? @character "I") + (content) @markup.italic) + +(interior_sequence + (sequence_letter) @character + (#eq? @character "L") + (content) @string.special.url) + +(interior_sequence + (sequence_letter) @character + (#eq? @character "X") + (content) @markup.link) + +(interior_sequence + (sequence_letter) @character + (#eq? @character "E") + (content) @string.escape) diff --git a/runtime/queries/poe_filter/folds.scm b/runtime/queries/poe_filter/folds.scm new file mode 100644 index 000000000..fd7d23999 --- /dev/null +++ b/runtime/queries/poe_filter/folds.scm @@ -0,0 +1 @@ +(block) @fold diff --git a/runtime/queries/poe_filter/highlights.scm b/runtime/queries/poe_filter/highlights.scm new file mode 100644 index 000000000..b0c715ac9 --- /dev/null +++ b/runtime/queries/poe_filter/highlights.scm @@ -0,0 +1,52 @@ +[ + "Show" + "Hide" + "Minimal" +] @module + +[ + "Import" + "Optional" +] @keyword.import + +(condition + (name) @keyword.conditional) + +(action + (name) @keyword) + +(continue) @label + +(operator) @operator + +(string) @string + +(file) @string.special.path + +[ + (quality) + (rarity) + (influence) + (colour) + (shape) +] @constant.builtin + +(sockets) @variable.builtin + +(number) @number + +(boolean) @boolean + +[ + (disable) + "Temp" +] @constant + +(comment) @comment @spell + +"\"" @punctuation.delimiter + +; conceal unnecessary quotes +("\"" @conceal + (#not-has-parent? @conceal string file) + (#set! conceal "")) diff --git a/runtime/queries/poe_filter/indents.scm b/runtime/queries/poe_filter/indents.scm new file mode 100644 index 000000000..78b7a2ed1 --- /dev/null +++ b/runtime/queries/poe_filter/indents.scm @@ -0,0 +1,5 @@ +(block) @indent.begin + +(ERROR) @indent.auto + +(comment) @indent.ignore diff --git a/runtime/queries/poe_filter/injections.scm b/runtime/queries/poe_filter/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/poe_filter/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/pony/folds.scm b/runtime/queries/pony/folds.scm new file mode 100644 index 000000000..95b76eb69 --- /dev/null +++ b/runtime/queries/pony/folds.scm @@ -0,0 +1,33 @@ +[ + (use_statement) + (actor_definition) + (class_definition) + (primitive_definition) + (interface_definition) + (trait_definition) + (struct_definition) + (constructor) + (method) + (behavior) + (parameters) + (type) + (if_statement) + (iftype_statement) + (elseif_block) + (elseiftype_block) + (else_block) + (for_statement) + (while_statement) + (try_statement) + (with_statement) + (repeat_statement) + (recover_statement) + (match_statement) + (case_statement) + (parenthesized_expression) + (tuple_expression) + (array_literal) + (object_literal) + (string) + (block_comment) +] @fold diff --git a/runtime/queries/pony/highlights.scm b/runtime/queries/pony/highlights.scm new file mode 100644 index 000000000..f3d4b5dca --- /dev/null +++ b/runtime/queries/pony/highlights.scm @@ -0,0 +1,333 @@ +; Includes +"use" @keyword.import + +; Keywords +[ + "primitive" + "embed" + "let" + "var" + (compile_intrinsic) + "as" + "consume" + "recover" + "object" + "where" +] @keyword + +[ + "class" + "struct" + "type" + "interface" + "trait" + "actor" +] @keyword.type + +"fun" @keyword.function + +"be" @keyword.coroutine + +[ + "in" + "is" +] @keyword.operator + +"return" @keyword.return + +; Qualifiers +[ + "iso" + "trn" + "ref" + "val" + "box" + "tag" + "#read" + "#send" + "#share" + "#alias" + "#any" +] @keyword.modifier + +; Conditionals +[ + "if" + "ifdef" + "iftype" + "then" + "else" + "elseif" + "match" +] @keyword.conditional + +(if_statement + "end" @keyword.conditional) + +(iftype_statement + "end" @keyword.conditional) + +(match_statement + "end" @keyword.conditional) + +; Repeats +[ + "repeat" + "until" + "while" + "for" + "continue" + "do" + "break" +] @keyword.repeat + +(do_block + "end" @keyword.repeat) + +(repeat_statement + "end" @keyword.repeat) + +; Exceptions +[ + "try" + (error) + "compile_error" +] @keyword.exception + +(try_statement + "end" @keyword.exception) + +(recover_statement + "end" @keyword.exception) + +; Attributes +(annotation) @attribute + +; Variables +(identifier) @variable + +(this) @variable.builtin + +; Fields +(field + name: (identifier) @variable.member) + +(member_expression + "." + (identifier) @variable.member) + +; Constructors +(constructor + "new" @keyword.operator + (identifier) @constructor) + +; Methods +(method + (identifier) @function.method) + +(behavior + (identifier) @function.method) + +(ffi_method + (identifier) @function.method) + +((ffi_method + (string) @string.special) + (#set! priority 105)) + +(call_expression + callee: [ + (identifier) @function.method.call + (ffi_identifier + (identifier) @function.method.call) + (member_expression + "." + (identifier) @function.method.call) + ]) + +; Parameters +(parameter + name: (identifier) @variable.parameter) + +(lambda_parameter + name: (identifier) @variable.parameter) + +; Types +(type_alias + (identifier) @type.definition) + +(base_type + name: (identifier) @type) + +(generic_parameter + (identifier) @type) + +(lambda_type + (identifier)? @function.method) + +((identifier) @type + (#lua-match? @type "^_*[A-Z][a-zA-Z0-9_]*$")) + +; Operators +(unary_expression + operator: [ + "not" + "addressof" + "digestof" + ] @keyword.operator) + +(binary_expression + operator: [ + "and" + "or" + "xor" + "is" + "isnt" + ] @keyword.operator) + +[ + "=" + "?" + "|" + "&" + "-~" + "+" + "-" + "*" + "/" + "%" + "%%" + "<<" + ">>" + "==" + "!=" + ">" + ">=" + "<=" + "<" + "+~" + "-~" + "*~" + "/~" + "%~" + "%%~" + "<<~" + ">>~" + "==~" + "!=~" + ">~" + ">=~" + "<=~" + "<~" + "+?" + "-?" + "*?" + "/?" + "%?" + "%%?" + "<:" +] @operator + +; Literals +(string) @string + +(source_file + (string) @string.documentation) + +(actor_definition + (string) @string.documentation) + +(class_definition + (string) @string.documentation) + +(primitive_definition + (string) @string.documentation) + +(interface_definition + (string) @string.documentation) + +(trait_definition + (string) @string.documentation) + +(struct_definition + (string) @string.documentation) + +(type_alias + (string) @string.documentation) + +(field + (string) @string.documentation) + +(constructor + [ + (string) @string.documentation + (block + . + (string) @string.documentation) + ]) + +(method + [ + (string) @string.documentation + (block + . + (string) @string.documentation) + ]) + +(behavior + [ + (string) @string.documentation + (block + . + (string) @string.documentation) + ]) + +(character) @character + +(escape_sequence) @string.escape + +(number) @number + +(float) @number.float + +(boolean) @boolean + +; Punctuation +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "." + "," + ";" + ":" + "~" + ".>" + "->" + "=>" +] @punctuation.delimiter + +[ + "@" + "!" + "^" + "..." +] @punctuation.special + +; Comments +[ + (line_comment) + (block_comment) +] @comment @spell diff --git a/runtime/queries/pony/indents.scm b/runtime/queries/pony/indents.scm new file mode 100644 index 000000000..3bddd29de --- /dev/null +++ b/runtime/queries/pony/indents.scm @@ -0,0 +1,71 @@ +[ + (use_statement) + (actor_definition) + (class_definition) + (primitive_definition) + (interface_definition) + (trait_definition) + (struct_definition) + (constructor) + (method) + (behavior) + (parameters) + (if_block) + (then_block) + (elseif_block) + (else_block) + (iftype_statement) + (elseiftype_block) + (do_block) + (match_statement) + (parenthesized_expression) + (tuple_expression) + (array_literal) + (object_literal) +] @indent.begin + +(try_statement + (block) @indent.begin) + +(repeat_statement + (block) @indent.begin) + +(recover_statement + (block) @indent.begin) + +(return_statement + (block) @indent.begin) + +(continue_statement + (block) @indent.begin) + +(break_statement + (block) @indent.begin) + +[ + "}" + "]" + ")" +] @indent.end + +[ + "{" + "}" +] @indent.branch + +[ + "[" + "]" +] @indent.branch + +[ + "(" + ")" +] @indent.branch + +[ + (ERROR) + (string) + (line_comment) + (block_comment) +] @indent.auto diff --git a/runtime/queries/pony/injections.scm b/runtime/queries/pony/injections.scm new file mode 100644 index 000000000..3cd6aac8e --- /dev/null +++ b/runtime/queries/pony/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/pony/locals.scm b/runtime/queries/pony/locals.scm new file mode 100644 index 000000000..a27e501a3 --- /dev/null +++ b/runtime/queries/pony/locals.scm @@ -0,0 +1,86 @@ +; Scopes +[ + (use_statement) + (actor_definition) + (class_definition) + (primitive_definition) + (interface_definition) + (trait_definition) + (struct_definition) + (constructor) + (method) + (behavior) + (if_statement) + (iftype_statement) + (elseif_block) + (elseiftype_block) + (else_block) + (for_statement) + (while_statement) + (try_statement) + (with_statement) + (repeat_statement) + (recover_statement) + (match_statement) + (case_statement) + (parenthesized_expression) + (tuple_expression) + (array_literal) + (object_literal) +] @local.scope + +; References +(identifier) @local.reference + +; Definitions +(field + name: (identifier) @local.definition.field) + +(use_statement + (identifier) @local.definition.import) + +(constructor + (identifier) @local.definition.method) + +(method + (identifier) @local.definition.method) + +(behavior + (identifier) @local.definition.method) + +(actor_definition + (identifier) @local.definition.type) + +(type_alias + (identifier) @local.definition.type) + +(class_definition + (identifier) @local.definition.type) + +(primitive_definition + (identifier) @local.definition.type) + +(interface_definition + (identifier) @local.definition.type) + +(trait_definition + (identifier) @local.definition.type) + +(struct_definition + (identifier) @local.definition.type) + +(parameter + name: (identifier) @local.definition.parameter) + +(variable_declaration + (identifier) @local.definition.var) + +(for_statement + [ + (identifier) @local.definition.var + (tuple_expression + (identifier) @local.definition.var) + ]) + +(with_elem + (identifier) @local.definition.var) diff --git a/runtime/queries/powershell/folds.scm b/runtime/queries/powershell/folds.scm new file mode 100644 index 000000000..d87e3f688 --- /dev/null +++ b/runtime/queries/powershell/folds.scm @@ -0,0 +1,13 @@ +[ + (expandable_here_string_literal) + (verbatim_here_string_characters) + (function_statement) + (param_block) + (script_block_expression) + (statement_block) + (switch_body) + (array_expression) + (hash_literal_expression) + (class_statement) + (class_method_definition) +] @fold diff --git a/runtime/queries/powershell/highlights.scm b/runtime/queries/powershell/highlights.scm new file mode 100644 index 000000000..6081e8f1b --- /dev/null +++ b/runtime/queries/powershell/highlights.scm @@ -0,0 +1,333 @@ +; Punctuation +;------------ +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(hash_literal_expression + [ + "@{" + "}" + ] @punctuation.special) + +(array_expression + [ + "@(" + ")" + ] @punctuation.special) + +[ + "." + "::" + "," + ";" + (empty_statement) + (command_argument_sep) +] @punctuation.delimiter + +; Keywords +;--------- +[ + "if" + "elseif" + "else" + "switch" +] @keyword.conditional + +[ + "foreach" + "for" + "while" + "do" + "until" + "in" + "break" + "continue" +] @keyword.repeat + +[ + "function" + "filter" + "workflow" + "exit" + "trap" + "param" + "inlinescript" +] @keyword.function + +"return" @keyword.return + +[ + "class" + "enum" +] @keyword.type + +[ + "data" + (class_attribute) +] @keyword.modifier + +[ + "throw" + "try" + "catch" + "finally" +] @keyword.exception + +[ + "parallel" + "sequence" +] @keyword.coroutine + +[ + "param" + "dynamicparam" + "begin" + "process" + "end" +] @keyword + +; Operators +;---------- +[ + "-and" + "-or" + "-xor" + "-band" + "-bor" + "-bxor" + "+" + "-" + "/" + "\\" + "%" + "*" + ".." + "-not" + "-bnot" + "!" + "=" + "|" + (pre_increment_expression) + (pre_decrement_expression) + (post_increment_expression) + (post_decrement_expression) + (comparison_operator) + (assignement_operator) +] @operator + +; Generic types +;-------------- +(string_literal) @string + +(integer_literal) @number + +(real_literal) @number.float + +(variable) @variable + +((variable) @variable.builtin + (#any-of? @variable.builtin + "$$" "$?" "$^" "$_" "$args" "$ConsoleFileName" "$EnabledExperimentalFeatures" "$Error" "$Event" + "$EventArgs" "$EventSubscriber" "$ExecutionContext" "$false" "$foreach" "$HOME" "$Host" "$input" + "$IsCoreCLR" "$IsLinux" "$IsMacOS" "$IsWindows" "$LASTEXITCODE" "$Matches" "$MyInvocation" + "$NestedPromptLevel" "$null" "$PID" "$PROFILE" "$PSBoundParameters" "$PSCmdlet" "$PSCommandPath" + "$PSCulture" "$PSDebugContext" "$PSEdition" "$PSHOME" "$PSItem" "$PSScriptRoot" "$PSSenderInfo" + "$PSUICulture" "$PSVersionTable" "$PWD" "$Sender" "ShellId" "$StackTrace" "$switch" "$this" + "$true")) + +((variable) @variable.builtin + (#lua-match? @variable.builtin "^\$env:")) + +(data_name + (simple_name) @constant) + +(comment) @comment @spell + +((program + . + (comment) @keyword.directive) + (#lua-match? @keyword.directive "^#!/")) + +; Booleans +;--------- +([ + (generic_token) + (command_name) + (variable) + (command) +] @boolean + (#any-of? @boolean "True" "False" "$true" "$false")) + +; switch -regex +;-------------- +(switch_statement + (switch_parameters + (switch_parameter) @_parameter) + (switch_body + (switch_clauses + (switch_clause + (switch_clause_condition + (string_literal) @string.regexp)))) + (#eq? @_parameter "-regex") + (#offset! @string.regexp 0 1 0 -1)) + +; Multiline strings +;------------------ +([ + (verbatim_here_string_characters) + (expandable_here_string_literal) +] @markup.raw.block + (#offset! @markup.raw.block 0 2 0 -2)) + +; Type references and definitions +;-------------------------------- +(type_spec + (type_name) @type) + +(class_statement + (simple_name) @type) + +(type_spec + (type_name) @type.builtin + (#any-of? @type.builtin + "bool" "Boolean" "System.Boolean" "char" "Char" "System.Char" "string" "String" "System.String" + "int" "Int32" "System.Int32" "long" "Int64" "System.Int64" "byte" "Byte" "System.Byte" "float" + "Single" "System.Single" "double" "Double" "System.Double" "decimal" "Decimal" "System.Decimal" + "array" "Array" "System.Array" "regex" "Regex" "System.Text.RegularExpressions.Regex" "ref" + "Management.Automation.PSReference" "System.Management.Automation.PSReference" "scriptblock" + "Management.Automation.ScriptBlock" "System.Management.Automation.ScriptBlock" "datetime" + "DateTime" "System.DateTime" "enum" "Enum" "System.Enum" "IO.DirectoryInfo" + "System.IO.DirectoryInfo" "IO.FileAttributes" "System.IO.FileAttributes" "IO.FileInfo" + "System.IO.FileInfo" "IO.Path" "System.IO.Path" "Text.RegularExpressions.RegexOptions" + "System.Text.RegularExpressions.RegexOptions" "Math" "System.Math" "PSObject" "System.PSObject" + "Object" "System.Object" "ValueType" "System.ValueType" "Hashtable" + "System.Collections.Hashtable" "Collections.Stack" "System.Collections.Generic.Stack" + "Collections.Dictionary" "System.Collections.Dictionary" "Collections.DictionaryEntry" + "System.Collections.DictionaryEntry" "Collections.ArrayList" "System.Collections.ArrayList" + "Management.Automation.SwitchParameter" "System.Management.Automation.SwitchParameter" + "Management.Automation.ActionPreference" "System.Management.Automation.ActionPreference" + "Management.Automation.ConfirmImpact" "System.Management.Automation.ConfirmImpact" + "Management.Automation.CommandInfo" "System.Management.Automation.CommandInfo" + "Management.Automation.ProviderInfo" "System.Management.Automation.ProviderInfo" + "Management.Automation.PSDriveInfo" "System.Management.Automation.PSDriveInfo" + "Management.Automation.PSVariable" "System.Management.Automation.PSVariable" + "Management.Automation.AliasInfo" "System.Management.Automation.AliasInfo" + "Management.Automation.PathInfo" "System.Management.Automation.PathInfo" + "Management.Automation.PathInfoStack" "System.Management.Automation.PathInfoStack" + "Management.Automation.ApplicationInfo" "System.Management.Automation.ApplicationInfo" + "Management.Automation.CmdletInfo" "System.Management.Automation.CmdletInfo" + "Management.Automation.ExternalScriptInfo" "System.Management.Automation.ExternalScriptInfo" + "Management.Automation.FunctionInfo" "System.Management.Automation.FunctionInfo" + "Management.Automation.CommandTypes" "System.Management.CommandTypes" + "Management.Automation.ScopedItemOptions" "System.Management.Automation.ScopedItemOptions" + "Management.Automation.PSTypeName" "System.Management.Automation.PSTypeName" + "Management.Automation.ParameterMetadata" "System.Management.Automation.ParameterMetadata" + "Management.Automation.CommandParameterSetInfo" + "System.Management.Automation.CommandParameterSetInfo" + "Management.Automation.SessionStateEntryVisibility" + "System.Management.Automation.SessionStateEntryVisibility" "Management.Automation.FilterInfo" + "System.Management.Automation.FilterInfo" "Management.Automation.ModuleType" + "System.Management.Automation.ModuleType" "Management.Automation.PSModuleInfo" + "System.Management.Automation.PSModuleInfo" "Management.Automation.PSCustomObject" + "System.Management.Automation.PSCustomObject" "Management.Automation.PSScriptCmdlet" + "System.Management.Automation.PSScriptCmdlet" "Management.Automation.ErrorRecord" + "System.Management.Automation.ErrorRecord" "Management.Automation.PSCredential" + "System.Management.Automation.PSCredential" "Management.Automation.PSMethod" + "System.Management.Automation.PSMethod")) + +; Function definitions +;--------------------- +(function_statement + (function_name) @function) + +; Classes, fields and methods definitions +;---------------------------------------- +(class_property_definition + (variable) @variable.member) + +(class_method_definition + (simple_name) @function.method) + +(class_statement + (simple_name) @_class_name + (class_method_definition + (simple_name) @constructor) + (#eq? @constructor @_class_name)) + +(key_expression) @property + +; Functions, methods calls and properties access +;-------------------------- +(command_invokation_operator) @operator + +(invokation_expression + (member_name) @function.call) + +(invokation_expression + (member_name) @constructor + (#eq? @constructor "new")) + +(member_access + (member_name + [ + (simple_name) + (variable) + ] @variable.member)) + +; Commands execution +;------------------- +(command + command_name: (command_name) @function.call) + +(command + command_name: (command_name) @function.builtin + (#any-of? @function.builtin + ; Locations & Paths + "cd" "cd.." "cd\\" "cd~" "help" "Get-Location" "Pop-Location" "Push-Location" "Set-Location" + "Convert-Path" "Join-Path" "Resolve-Path" "Split-Path" "Test-Path" + ; Files & Directories + "Clear-Item" "Clear-ItemProperty" "Copy-Item" "Copy-ItemProperty" "Get-Item" "Get-ItemProperty" + "Get-ItemPropertyValue" "Invoke-Item" "Move-Item" "Move-ItemProperty" "New-Item" + "New-ItemProperty" "Remove-Item" "Remove-ItemProperty" "Rename-Item" "Rename-ItemProperty" + "Set-Item" "Set-ItemProperty" + ; Aliases + "New-Alias" "Get-Alias" "Set-Alias" "Remove-Alias" "Import-Alias" "Export-Alias" + ; Host (prompt) + "prompt" "cls" "echo" "Clear-Host" "Get-Host" "Out-Host" "Read-Host" "Write-Host" "Out-String" + ; Expressions + "Invoke-Expression" + ; Objects + "Compare-Object" "ForEach-Object" "Group-Object" "Measure-Object" "New-Object" "Select-Object" + "Sort-Object" "Tee-Object" "Where-Object" + ; Modules + "Export-ModuleMember" "Find-Module" "Get-Module" "Import-Module" "Install-Module" "New-Module" + "New-ModuleManifest" "Publish-Module" "Remove-Module" "Save-Module" "Test-ModuleManifest" + "Uninstall-Module" "Update-Module" "Update-ModuleManifest")) + +; Parameters and call arguments +;------------------------------ +(command_elements + (generic_token) @variable.parameter) + +(switch_parameter) @variable.parameter.builtin + +(command_parameter) @variable.parameter.builtin + +(script_parameter + (variable) @variable.parameter) + +(class_method_parameter + (variable) @variable.parameter) + +; Document encoding +;------------------ +((program + . + (comment) @keyword.directive @nospell) + (#lua-match? @keyword.directive "Encoding$")) diff --git a/runtime/queries/powershell/indents.scm b/runtime/queries/powershell/indents.scm new file mode 100644 index 000000000..3be2ed161 --- /dev/null +++ b/runtime/queries/powershell/indents.scm @@ -0,0 +1,41 @@ +(function_statement + "}" @indent.branch) @indent.begin + +(param_block + [ + "param" + "(" + ")" + ] @indent.branch) @indent.begin + +(script_block_expression + "}" @indent.branch) @indent.begin + +(statement_block + "}" @indent.branch) @indent.begin + +(switch_body + "}" @indent.branch) @indent.begin + +(array_expression + ")" @indent.branch) @indent.begin + +(hash_literal_expression + "}" @indent.branch) @indent.begin + +(class_statement + "}" @indent.branch) @indent.begin + +(class_method_definition + "}" @indent.branch) @indent.begin + +[ + "}" + ")" +] @indent.end + +[ + (comment) + (string_literal) + (ERROR) +] @indent.auto diff --git a/runtime/queries/powershell/injections.scm b/runtime/queries/powershell/injections.scm new file mode 100644 index 000000000..677e8b267 --- /dev/null +++ b/runtime/queries/powershell/injections.scm @@ -0,0 +1,27 @@ +; comments and block-comments +((comment) @injection.content + (#set! injection.language "comment")) + +; dynamic invocation like & "$env:ChocolateyInstall\bin\choco.exe" +(command + (command_invokation_operator) @_operator + (command_name_expr + (string_literal) @injection.content) + (#eq? @_operator "&") + (#set! injection.language "powershell") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children)) + +; switch -regex +(switch_statement + (switch_parameters + (switch_parameter) @_parameter) + (switch_body + (switch_clauses + (switch_clause + (switch_clause_condition + (string_literal) @injection.content)))) + (#eq? @_parameter "-regex") + (#set! injection.language "regex") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children)) diff --git a/runtime/queries/powershell/locals.scm b/runtime/queries/powershell/locals.scm new file mode 100644 index 000000000..e98410992 --- /dev/null +++ b/runtime/queries/powershell/locals.scm @@ -0,0 +1,85 @@ +; Scopes +;------- +(class_statement) @local.scope + +(class_method_definition) @local.scope + +(statement_block) @local.scope + +(function_statement) @local.scope + +; Definitions +;------------ +(class_statement + (simple_name) @local.definition.type + (#set! definition.var.scope "parent")) + +(class_property_definition + (variable) @local.definition.field + (#set! definition.var.scope "parent")) + +(class_method_definition + (simple_name) @local.definition.method + (#set! definition.var.scope "parent")) + +(function_statement + (function_name) @local.definition.function + (#set! definition.var.scope "parent")) + +; function, script block parameters +(parameter_list + (script_parameter + (attribute_list + (attribute + (type_literal + (type_spec) @local.definition.associated))) + (variable) @local.definition.parameter)) + +; variable assignment +(assignment_expression + (left_assignment_expression + (logical_expression + (bitwise_expression + (comparison_expression + (additive_expression + (multiplicative_expression + (format_expression + (range_expression + (array_literal_expression + (unary_expression + (variable) @local.definition.var))))))))))) + +; variable with type assignment +(assignment_expression + (left_assignment_expression + (logical_expression + (bitwise_expression + (comparison_expression + (additive_expression + (multiplicative_expression + (format_expression + (range_expression + (array_literal_expression + (unary_expression + (expression_with_unary_operator + (cast_expression + (type_literal + (type_spec) @local.definition.associated) + (unary_expression + (variable) @local.definition.var)))))))))))))) + +; data sections +(data_name + (simple_name) @local.definition.var) + +; References +;----------- +(variable) @local.reference + +(command_name) @local.reference + +(invokation_expression + (variable) @_variable + (member_name + (simple_name) @local.reference) + (#eq? @_variable "$this")) diff --git a/runtime/queries/printf/highlights.scm b/runtime/queries/printf/highlights.scm new file mode 100644 index 000000000..db5ef9a3f --- /dev/null +++ b/runtime/queries/printf/highlights.scm @@ -0,0 +1 @@ +(format) @character diff --git a/runtime/queries/prisma/folds.scm b/runtime/queries/prisma/folds.scm new file mode 100644 index 000000000..73be36016 --- /dev/null +++ b/runtime/queries/prisma/folds.scm @@ -0,0 +1,7 @@ +[ + (generator_declaration) + (datasource_declaration) + (model_declaration) + (enum_declaration) + (view_declaration) +] @fold diff --git a/runtime/queries/prisma/highlights.scm b/runtime/queries/prisma/highlights.scm new file mode 100644 index 000000000..9d2d1934e --- /dev/null +++ b/runtime/queries/prisma/highlights.scm @@ -0,0 +1,47 @@ +(variable) @variable + +[ + "datasource" + "generator" + "model" + "view" +] @keyword + +[ + "type" + "enum" +] @keyword.type + +(comment) @comment @spell + +(developer_comment) @comment.documentation @spell + +[ + (attribute) + (call_expression) +] @function + +(arguments) @property + +(column_type) @type + +(enumeral) @constant + +(column_declaration + (identifier) @variable) + +(string) @string + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "=" + "@" +] @operator diff --git a/runtime/queries/prisma/injections.scm b/runtime/queries/prisma/injections.scm new file mode 100644 index 000000000..ac427dd68 --- /dev/null +++ b/runtime/queries/prisma/injections.scm @@ -0,0 +1,5 @@ +([ + (comment) + (developer_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/problog/folds.scm b/runtime/queries/problog/folds.scm new file mode 100644 index 000000000..768718207 --- /dev/null +++ b/runtime/queries/problog/folds.scm @@ -0,0 +1 @@ +; inherits: prolog diff --git a/runtime/queries/problog/highlights.scm b/runtime/queries/problog/highlights.scm new file mode 100644 index 000000000..de1715662 --- /dev/null +++ b/runtime/queries/problog/highlights.scm @@ -0,0 +1,4 @@ +; inherits: prolog + +(probability_label + _ @attribute) diff --git a/runtime/queries/problog/indents.scm b/runtime/queries/problog/indents.scm new file mode 100644 index 000000000..768718207 --- /dev/null +++ b/runtime/queries/problog/indents.scm @@ -0,0 +1 @@ +; inherits: prolog diff --git a/runtime/queries/problog/injections.scm b/runtime/queries/problog/injections.scm new file mode 100644 index 000000000..768718207 --- /dev/null +++ b/runtime/queries/problog/injections.scm @@ -0,0 +1 @@ +; inherits: prolog diff --git a/runtime/queries/prolog/folds.scm b/runtime/queries/prolog/folds.scm new file mode 100644 index 000000000..70a401511 --- /dev/null +++ b/runtime/queries/prolog/folds.scm @@ -0,0 +1,6 @@ +[ + (directive_term) + (clause_term) + (arg_list) + (list_notation) +] @fold diff --git a/runtime/queries/prolog/highlights.scm b/runtime/queries/prolog/highlights.scm new file mode 100644 index 000000000..fc89b6fef --- /dev/null +++ b/runtime/queries/prolog/highlights.scm @@ -0,0 +1,43 @@ +(comment) @comment @spell + +(atom) @constant + +((atom) @boolean + (#any-of? @boolean "true" "false")) + +(functional_notation + function: (atom) @function.call) + +(integer) @number + +(float_number) @number.float + +(directive_head) @operator + +(operator_notation + operator: _ @operator) + +[ + (open) + (open_ct) + (close) + (open_list) + "|" + (close_list) + (open_curly) + (close_curly) +] @punctuation.bracket + +[ + (arg_list_separator) + (comma) + (end) + (list_notation_separator) +] @punctuation.delimiter + +(operator_notation + operator: (semicolon) @punctuation.delimiter) + +(double_quoted_list_notation) @string + +(variable_term) @variable diff --git a/runtime/queries/prolog/indents.scm b/runtime/queries/prolog/indents.scm new file mode 100644 index 000000000..a7f9b0383 --- /dev/null +++ b/runtime/queries/prolog/indents.scm @@ -0,0 +1,16 @@ +(directive_term) @indent.zero + +(clause_term) @indent.zero + +(functional_notation + (atom) + (open_ct) @indent.begin + (close) @indent.end) + +(list_notation + (open_list) @indent.begin + (close_list) @indent.end) + +(curly_bracketed_notation + (open_curly) @indent.begin + (close_curly) @indent.end) diff --git a/runtime/queries/prolog/injections.scm b/runtime/queries/prolog/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/prolog/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/promql/highlights.scm b/runtime/queries/promql/highlights.scm new file mode 100644 index 000000000..a99fcdd05 --- /dev/null +++ b/runtime/queries/promql/highlights.scm @@ -0,0 +1,55 @@ +; highlights.scm +[ + "*" + "/" + "%" + "+" + "-" + ">" + ">=" + "<" + "<=" + "=" + "=~" + "!=" + "!~" +] @operator + +[ + "{" + "}" + "[" + "]" + "(" + ")" +] @punctuation.bracket + +(float_literal) @number.float + +(string_literal) @string + +(metric_name) @type + +(range_selection) @type + +(subquery_range_selection) @type + +(label_name) @variable.member + +((label_name) + [ + "=~" + "!~" + ] + (label_value) @string.regexp) + +((label_name) + [ + "=" + "!=" + ] + (label_value) @string) + +(function_name) @function.call + +(comment) @comment @spell diff --git a/runtime/queries/promql/injections.scm b/runtime/queries/promql/injections.scm new file mode 100644 index 000000000..791aba3d8 --- /dev/null +++ b/runtime/queries/promql/injections.scm @@ -0,0 +1,11 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((label_name) + [ + "=~" + "!~" + ] + (label_value) @injection.content + (#set! injection.language "regex") + (#offset! @injection.content 0 1 0 -1)) diff --git a/runtime/queries/properties/highlights.scm b/runtime/queries/properties/highlights.scm new file mode 100644 index 000000000..b9390be8c --- /dev/null +++ b/runtime/queries/properties/highlights.scm @@ -0,0 +1,50 @@ +(comment) @comment @spell + +(key) @property + +(value) @string + +(value + (escape) @string.escape) + +((value) @boolean + (#any-of? @boolean "true" "false")) + +((value) @number + (#lua-match? @number "^%d+$")) + +((index) @number + (#lua-match? @number "^%d+$")) + +((substitution + (key) @constant) + (#lua-match? @constant "^[A-Z_][A-Z0-9_]*$")) + +(substitution + (key) @function + "::" @punctuation.special + (secret) @constant.macro) + +(property + [ + "=" + ":" + ] @operator) + +[ + "${" + "}" +] @punctuation.special + +(substitution + ":" @punctuation.special) + +[ + "[" + "]" +] @punctuation.bracket + +[ + "." + "\\" +] @punctuation.delimiter diff --git a/runtime/queries/properties/injections.scm b/runtime/queries/properties/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/properties/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/properties/locals.scm b/runtime/queries/properties/locals.scm new file mode 100644 index 000000000..91a3b9a86 --- /dev/null +++ b/runtime/queries/properties/locals.scm @@ -0,0 +1,5 @@ +(property + (key) @local.definition) + +(substitution + (key) @local.reference) diff --git a/runtime/queries/proto/folds.scm b/runtime/queries/proto/folds.scm new file mode 100644 index 000000000..645ac1819 --- /dev/null +++ b/runtime/queries/proto/folds.scm @@ -0,0 +1,5 @@ +[ + (enum) + (message) + (service) +] @fold diff --git a/runtime/queries/proto/highlights.scm b/runtime/queries/proto/highlights.scm new file mode 100644 index 000000000..51f44a754 --- /dev/null +++ b/runtime/queries/proto/highlights.scm @@ -0,0 +1,82 @@ +[ + "extend" + "extensions" + "oneof" + "option" + "reserved" + "syntax" + "to" +] @keyword + +[ + "enum" + "service" + "message" +] @keyword.type + +"rpc" @keyword.function + +"returns" @keyword.return + +[ + "optional" + "repeated" + "required" +] @keyword.modifier + +[ + "package" + "import" +] @keyword.import + +[ + (key_type) + (type) + (message_name) + (enum_name) + (service_name) + (rpc_name) + (message_or_enum_type) +] @type + +(enum_field + (identifier) @constant) + +(string) @string + +[ + "\"proto3\"" + "\"proto2\"" +] @string.special + +(int_lit) @number + +(float_lit) @number.float + +[ + (true) + (false) +] @boolean + +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" +] @punctuation.bracket + +[ + ";" + "," +] @punctuation.delimiter + +"=" @operator diff --git a/runtime/queries/proto/indents.scm b/runtime/queries/proto/indents.scm new file mode 100644 index 000000000..4307b2a19 --- /dev/null +++ b/runtime/queries/proto/indents.scm @@ -0,0 +1,11 @@ +[ + (message_body) + (enum_body) +] @indent.begin + +"}" @indent.end @indent.branch + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/runtime/queries/proto/injections.scm b/runtime/queries/proto/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/proto/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/prql/highlights.scm b/runtime/queries/prql/highlights.scm new file mode 100644 index 000000000..d24777dc0 --- /dev/null +++ b/runtime/queries/prql/highlights.scm @@ -0,0 +1,135 @@ +[ + (keyword_from) + (keyword_filter) + (keyword_derive) + (keyword_group) + (keyword_aggregate) + (keyword_sort) + (keyword_take) + (keyword_window) + (keyword_join) + (keyword_select) + (keyword_append) + (keyword_remove) + (keyword_intersect) + (keyword_rolling) + (keyword_rows) + (keyword_expanding) + (keyword_let) + (keyword_prql) + (keyword_from_text) +] @keyword + +(keyword_loop) @keyword.repeat + +(keyword_case) @keyword.conditional + +[ + (literal_string) + (f_string) + (s_string) +] @string + +(assignment + alias: (field) @variable.member) + +alias: (identifier) @variable.member + +(comment) @comment @spell + +(function_call + (identifier) @function.call) + +[ + "+" + "-" + "*" + "/" + "=" + "==" + "<" + "<=" + "!=" + ">=" + ">" + "&&" + "||" + "//" + "~=" + (bang) +] @operator + +[ + "(" + ")" + "{" + "}" +] @punctuation.bracket + +[ + "," + "." + "->" +] @punctuation.delimiter + +(integer) @number + +(decimal_number) @number.float + +[ + (keyword_min) + (keyword_max) + (keyword_count) + (keyword_count_distinct) + (keyword_average) + (keyword_avg) + (keyword_sum) + (keyword_stddev) + (keyword_count) + (keyword_rank) +] @function + +[ + (keyword_side) + (keyword_format) +] @attribute + +[ + (keyword_version) + (keyword_target) +] @keyword.modifier + +(target) @function.builtin + +[ + (date) + (time) + (timestamp) +] @string.special + +[ + (keyword_left) + (keyword_inner) + (keyword_right) + (keyword_full) + (keyword_csv) + (keyword_json) +] @function.method.call + +[ + (keyword_true) + (keyword_false) +] @boolean + +(function_definition + (keyword_let) + name: (identifier) @function) + +(parameter + (identifier) @variable.parameter) + +(variable + (keyword_let) + name: (identifier) @constant) + +(keyword_null) @constant.builtin diff --git a/runtime/queries/prql/injections.scm b/runtime/queries/prql/injections.scm new file mode 100644 index 000000000..e6cbeda35 --- /dev/null +++ b/runtime/queries/prql/injections.scm @@ -0,0 +1,13 @@ +((s_string) @injection.content + (#set! injection.language "sql") + (#offset! @injection.content 0 2 0 -1)) + +(from_text + (keyword_from_text) + (keyword_json) + (literal) @injection.content + (#set! injection.language "json") + (#offset! @injection.content 0 3 0 -3)) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/psv/highlights.scm b/runtime/queries/psv/highlights.scm new file mode 100644 index 000000000..b7303fe0b --- /dev/null +++ b/runtime/queries/psv/highlights.scm @@ -0,0 +1,3 @@ +; inherits: tsv + +"|" @punctuation.delimiter diff --git a/runtime/queries/pug/highlights.scm b/runtime/queries/pug/highlights.scm new file mode 100644 index 000000000..e32cb21e1 --- /dev/null +++ b/runtime/queries/pug/highlights.scm @@ -0,0 +1,116 @@ +(comment) @comment @spell + +(tag_name) @tag + +((tag_name) @constant.builtin + ; https://www.script-example.com/html-tag-liste + (#any-of? @constant.builtin + "head" "title" "base" "link" "meta" "style" "body" "article" "section" "nav" "aside" "h1" "h2" + "h3" "h4" "h5" "h6" "hgroup" "header" "footer" "address" "p" "hr" "pre" "blockquote" "ol" "ul" + "menu" "li" "dl" "dt" "dd" "figure" "figcaption" "main" "div" "a" "em" "strong" "small" "s" + "cite" "q" "dfn" "abbr" "ruby" "rt" "rp" "data" "time" "code" "var" "samp" "kbd" "sub" "sup" "i" + "b" "u" "mark" "bdi" "bdo" "span" "br" "wbr" "ins" "del" "picture" "source" "img" "iframe" + "embed" "object" "param" "video" "audio" "track" "map" "area" "table" "caption" "colgroup" "col" + "tbody" "thead" "tfoot" "tr" "td" "th " "form" "label" "input" "button" "select" "datalist" + "optgroup" "option" "textarea" "output" "progress" "meter" "fieldset" "legend" "details" + "summary" "dialog" "script" "noscript" "template" "slot" "canvas")) + +(id) @constant + +(class) @type + +(doctype) @keyword.directive + +(content) @none + +(tag + (attributes + (attribute + (attribute_name) @tag.attribute + "=" @operator))) + +((tag + (attributes + (attribute + (attribute_name) @keyword))) + (#match? @keyword "^(:|v-bind|v-|\\@)")) + +(quoted_attribute_value) @string + +(include + (keyword) @keyword.import) + +(extends + (keyword) @keyword.import) + +(filename) @string.special.path + +(block_definition + (keyword) @keyword) + +(block_append + (keyword)+ @keyword) + +(block_prepend + (keyword)+ @keyword) + +(block_name) @module + +(conditional + (keyword) @keyword.conditional) + +(case + (keyword) @keyword.conditional + (when + (keyword) @keyword.conditional)+) + +(each + (keyword) @keyword.repeat) + +(while + (keyword) @keyword.repeat) + +(mixin_use + "+" @punctuation.delimiter + (mixin_name) @function.call) + +(mixin_definition + (keyword) @keyword.function + (mixin_name) @function) + +(mixin_attributes + (attribute_name) @variable.parameter) + +(filter + ":" @punctuation.delimiter + (filter_name) @function.method.call) + +(filter + (attributes + (attribute + (attribute_name) @variable.parameter))) + +[ + "(" + ")" + "#{" + "}" + ; unsupported + ; "!{" + ; "#[" "]" +] @punctuation.bracket + +[ + "," + "." + "|" +] @punctuation.delimiter + +(buffered_code + "=" @punctuation.delimiter) + +(unbuffered_code + "-" @punctuation.delimiter) + +(unescaped_buffered_code + "!=" @punctuation.delimiter) diff --git a/runtime/queries/pug/injections.scm b/runtime/queries/pug/injections.scm new file mode 100644 index 000000000..0c01e47eb --- /dev/null +++ b/runtime/queries/pug/injections.scm @@ -0,0 +1,11 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((javascript) @injection.content + (#set! injection.language "javascript")) + +((attribute_name) @_attribute_name + (quoted_attribute_value + (attribute_value) @injection.content + (#set! injection.language "javascript")) + (#match? @_attribute_name "^(:|v-bind|v-|\\@)")) diff --git a/runtime/queries/puppet/folds.scm b/runtime/queries/puppet/folds.scm new file mode 100644 index 000000000..78800fe4c --- /dev/null +++ b/runtime/queries/puppet/folds.scm @@ -0,0 +1,13 @@ +[ + (block) + (defined_resource_type) + (parameter_list) + (attribute_type_entry) + (resource_declaration) + (selector) + (iterator_statement) + (case_statement) + (hash) + (array) + (comment) +] @fold diff --git a/runtime/queries/puppet/highlights.scm b/runtime/queries/puppet/highlights.scm new file mode 100644 index 000000000..10621930f --- /dev/null +++ b/runtime/queries/puppet/highlights.scm @@ -0,0 +1,238 @@ +; Variables +(identifier) @variable + +; Includes +"include" @keyword.import + +(include_statement + (identifier) @type) + +(include_statement + (class_identifier + (identifier) @type .)) + +; Keywords +[ + "inherits" + "node" + "tag" + "require" +] @keyword + +[ + "type" + "class" +] @keyword.type + +[ + "define" + "function" +] @keyword.function + +[ + "if" + "elsif" + "else" + "unless" + "case" +] @keyword.conditional + +(default_case + "default" @keyword.conditional) + +; Attributes +(attribute + name: (identifier) @attribute) + +(attribute + name: (variable + (identifier) @attribute)) + +; Parameters +(lambda + (variable + (identifier) @variable.parameter)) + +(parameter + (variable + (identifier) @variable.parameter)) + +(function_call + (identifier) @variable.parameter) + +(iterator_statement + (variable) @variable.parameter) + +; Functions +(function_declaration + "function" + . + (identifier) @function) + +(function_call + (identifier) @function.call + "(") + +(defined_resource_type + "define" + . + (identifier) @function) + +; Methods +(function_declaration + "function" + . + (class_identifier + (identifier) @function.method .)) + +(function_call + (class_identifier + (identifier) @function.method.call .)) + +(defined_resource_type + "define" + . + (class_identifier + (identifier) @function.method .)) + +(function_call + (field_expression + "." + (identifier) @function.method.call) + "(") + +; Types +(type) @type + +(builtin_type) @type.builtin + +(class_definition + (identifier) @type) + +(class_definition + (class_identifier + (identifier) @type .)) + +(class_inherits + (identifier) @type) + +(class_inherits + (class_identifier + (identifier) @type .)) + +(resource_declaration + (identifier) @type) + +(resource_declaration + (class_identifier + (identifier) @type .)) + +(node_definition + (node_name + (identifier) @type)) + +((identifier) @type + (#lua-match? @type "^[A-Z]")) + +((identifier) @type.builtin + (#any-of? @type.builtin + "Boolean" "Integer" "Float" "String" "Array" "Hash" "Regexp" "Variant" "Data" "Undef" "Default" + "File")) + +; "Namespaces" +(class_identifier + . + (identifier) @module) + +; Operators +[ + "or" + "and" + "in" +] @keyword.operator + +[ + "=" + "+=" + "->" + "~>" + "<<|" + "<|" + "|>" + "|>>" + "?" + ">" + ">=" + "<=" + "<" + "==" + "!=" + "<<" + ">>" + "+" + "-" + "*" + "/" + "%" + "=~" + "!~" +] @operator + +; Punctuation +[ + "|" + "." + "," + ";" + ":" + "::" + "=>" +] @punctuation.delimiter + +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +(interpolation + [ + "${" + "}" + ] @punctuation.special) + +[ + "$" + "@" + "@@" +] @punctuation.special + +; Literals +(number) @number + +(float) @number.float + +(string) @string + +(escape_sequence) @string.escape + +(regex) @string.regexp + +(boolean) @boolean + +[ + (undef) + (default) +] @variable.builtin + +; Comments +(comment) @comment @spell diff --git a/runtime/queries/puppet/indents.scm b/runtime/queries/puppet/indents.scm new file mode 100644 index 000000000..71c882f33 --- /dev/null +++ b/runtime/queries/puppet/indents.scm @@ -0,0 +1,23 @@ +[ + (block) + (defined_resource_type) + (parameter_list) + (attribute_type_entry) + (resource_declaration) + (selector) + (case_statement) + (hash) + (array) +] @indent.begin + +[ + "}" + "]" + ")" +] @indent.branch @indent.end + +[ + (string) + (comment) + (ERROR) +] @indent.auto diff --git a/runtime/queries/puppet/injections.scm b/runtime/queries/puppet/injections.scm new file mode 100644 index 000000000..caa10a2b0 --- /dev/null +++ b/runtime/queries/puppet/injections.scm @@ -0,0 +1,6 @@ +((regex) @injection.content + (#set! injection.language "regex") + (#offset! @injection.content 0 1 0 -1)) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/puppet/locals.scm b/runtime/queries/puppet/locals.scm new file mode 100644 index 000000000..f145fffbc --- /dev/null +++ b/runtime/queries/puppet/locals.scm @@ -0,0 +1,64 @@ +; Scopes +[ + (block) + (defined_resource_type) + (parameter_list) + (attribute_type_entry) + (class_definition) + (node_definition) + (resource_declaration) + (selector) + (iterator_statement) + (case_statement) + (hash) + (array) +] @local.scope + +; References +[ + (identifier) + (class_identifier) + (variable) +] @local.reference + +; Definitions +(attribute + [ + (identifier) + (variable) + ] @local.definition.field) + +(function_declaration + [ + (identifier) + (class_identifier) + ] @local.definition.function) + +(include_statement + [ + (identifier) + (class_identifier) + ] @local.definition.import) + +(parameter + (variable) @local.definition.parameter) + +(class_definition + [ + (identifier) + (class_identifier) + ] @local.definition.type) + +(node_definition + (node_name + (identifier) @local.definition.type)) + +(resource_declaration + [ + (identifier) + (class_identifier) + ] @local.definition.type) + +(assignment + . + (variable) @local.definition.var) diff --git a/runtime/queries/purescript/highlights.scm b/runtime/queries/purescript/highlights.scm new file mode 100644 index 000000000..02426b0ab --- /dev/null +++ b/runtime/queries/purescript/highlights.scm @@ -0,0 +1,196 @@ +; ---------------------------------------------------------------------------- +; Literals and comments +[ + (integer) + (exp_negation) +] @number + +(exp_literal + (number)) @number.float + +(char) @character + +[ + (string) + (triple_quote_string) +] @string + +(comment) @comment @spell + +; ---------------------------------------------------------------------------- +; Punctuation +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + (comma) + ";" + (qualified_module) ; grabs the `.` (dot), ex: import System.IO + "." +] @punctuation.delimiter + +; ---------------------------------------------------------------------------- +; Keywords, operators, includes +[ + "if" + "then" + "else" + "case" + "of" +] @keyword.conditional + +[ + "import" + "module" +] @keyword.import + +[ + (operator) + (constructor_operator) + (type_operator) + (all_names) + "=" + "|" + "::" + "∷" + "=>" + "⇒" + "<=" + "⇐" + "->" + "→" + "<-" + "←" + "\\" + "`" + "@" +] @operator + +(qualified_module + (module) @constructor) + +(module) @module + +(qualified_type + (module) @module) + +(qualified_variable + (module) @module) + +(import + (module) @module) + +[ + (where) + "let" + "in" + "instance" + "derive" + "foreign" + "data" + "as" + "hiding" + "do" + "ado" + "forall" + "∀" + "infix" + "infixl" + "infixr" +] @keyword + +[ + "type" + "newtype" + "class" +] @keyword.type + +(class_instance + "else" @keyword) + +(type_role_declaration + "role" @keyword + role: (type_role) @keyword.modifier) + +; `_` wildcards in if-then-else and case-of expressions, +; as well as record updates and operator sections +[ + "_" + (hole) +] @character.special + +; ---------------------------------------------------------------------------- +; Functions and variables +(variable) @variable + +(exp_apply + . + (exp_name + (variable) @function)) + +(exp_apply + . + (exp_name + (qualified_variable + (variable) @function))) + +(row_field + (field_name) @variable.member) + +(record_field + (field_name) @variable.member) + +(record_accessor + (variable) @variable.member) + +(exp_record_access + (variable) @variable.member) + +(signature + name: (variable) @type) + +(kind_declaration + (class_name) @type) + +(function + name: (variable) @function) + +(foreign_import + (variable) @function) + +(class_instance + (instance_name) @function) + +(derive_declaration + (instance_name) @function) + +; true or false +((variable) @boolean + (#any-of? @boolean "true" "false")) + +; The former one works for `tree-sitter highlight` but not in Helix/Kakoune. +; The latter two work in Helix (but not Kakoune) and are a good compromise between not highlighting anything at all +; as an operator and leaving it to the child nodes, and highlighting everything as an operator. +(exp_ticked + (_) @operator) + +(exp_ticked + (exp_name + (variable) @operator)) + +(exp_ticked + (exp_name + (qualified_variable + (variable) @operator))) + +; ---------------------------------------------------------------------------- +; Types +(type) @type + +(constructor) @constructor diff --git a/runtime/queries/purescript/injections.scm b/runtime/queries/purescript/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/purescript/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/purescript/locals.scm b/runtime/queries/purescript/locals.scm new file mode 100644 index 000000000..16265231d --- /dev/null +++ b/runtime/queries/purescript/locals.scm @@ -0,0 +1,11 @@ +(signature + name: (variable)) @local.definition.type + +(function + name: (variable)) @local.definition.function + +(pat_name + (variable)) @local.definition + +(exp_name + (variable)) @local.reference diff --git a/runtime/queries/pymanifest/highlights.scm b/runtime/queries/pymanifest/highlights.scm new file mode 100644 index 000000000..11d8b605f --- /dev/null +++ b/runtime/queries/pymanifest/highlights.scm @@ -0,0 +1,25 @@ +(keyword) @keyword + +(dir_sep) @punctuation.delimiter + +(glob) @punctuation.special + +(linebreak) @character.special + +(char_sequence) @string.special + +(char_sequence + [ + "[" + "]" + ] @punctuation.bracket) + +(char_sequence + "!" @operator) + +(char_range + "-" @operator) + +(escaped_char) @string.escape + +(comment) @comment @spell diff --git a/runtime/queries/pymanifest/injections.scm b/runtime/queries/pymanifest/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/pymanifest/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/python/folds.scm b/runtime/queries/python/folds.scm new file mode 100644 index 000000000..ecb9352d7 --- /dev/null +++ b/runtime/queries/python/folds.scm @@ -0,0 +1,28 @@ +[ + (function_definition) + (class_definition) + (while_statement) + (for_statement) + (if_statement) + (with_statement) + (try_statement) + (match_statement) + (import_from_statement) + (parameters) + (argument_list) + (parenthesized_expression) + (generator_expression) + (list_comprehension) + (set_comprehension) + (dictionary_comprehension) + (tuple) + (list) + (set) + (dictionary) + (string) +] @fold + +[ + (import_statement) + (import_from_statement) +]+ @fold diff --git a/runtime/queries/python/highlights.scm b/runtime/queries/python/highlights.scm new file mode 100644 index 000000000..00250de1b --- /dev/null +++ b/runtime/queries/python/highlights.scm @@ -0,0 +1,443 @@ +; From tree-sitter-python licensed under MIT License +; Copyright (c) 2016 Max Brunsfeld +; Variables +(identifier) @variable + +; Reset highlighting in f-string interpolations +(interpolation) @none + +; Identifier naming conventions +((identifier) @type + (#lua-match? @type "^[A-Z].*[a-z]")) + +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + +((identifier) @constant.builtin + (#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$")) + +((identifier) @constant.builtin + (#any-of? @constant.builtin + ; https://docs.python.org/3/library/constants.html + "NotImplemented" "Ellipsis" "quit" "exit" "copyright" "credits" "license")) + +"_" @character.special ; match wildcard + +((assignment + left: (identifier) @type.definition + (type + (identifier) @_annotation)) + (#eq? @_annotation "TypeAlias")) + +((assignment + left: (identifier) @type.definition + right: (call + function: (identifier) @_func)) + (#any-of? @_func "TypeVar" "NewType")) + +; Function definitions +(function_definition + name: (identifier) @function) + +(type + (identifier) @type) + +(type + (subscript + (identifier) @type)) ; type subscript: Tuple[int] + +((call + function: (identifier) @_isinstance + arguments: (argument_list + (_) + (identifier) @type)) + (#eq? @_isinstance "isinstance")) + +; Literals +(none) @constant.builtin + +[ + (true) + (false) +] @boolean + +(integer) @number + +(float) @number.float + +(comment) @comment @spell + +((module + . + (comment) @keyword.directive @nospell) + (#lua-match? @keyword.directive "^#!/")) + +(string) @string + +[ + (escape_sequence) + (escape_interpolation) +] @string.escape + +; doc-strings +(expression_statement + (string + (string_content) @spell) @string.documentation) + +; Tokens +[ + "-" + "-=" + ":=" + "!=" + "*" + "**" + "**=" + "*=" + "/" + "//" + "//=" + "/=" + "&" + "&=" + "%" + "%=" + "^" + "^=" + "+" + "+=" + "<" + "<<" + "<<=" + "<=" + "<>" + "=" + "==" + ">" + ">=" + ">>" + ">>=" + "@" + "@=" + "|" + "|=" + "~" + "->" +] @operator + +; Keywords +[ + "and" + "in" + "is" + "not" + "or" + "is not" + "not in" + "del" +] @keyword.operator + +[ + "def" + "lambda" +] @keyword.function + +[ + "assert" + "exec" + "global" + "nonlocal" + "pass" + "print" + "with" + "as" +] @keyword + +[ + "type" + "class" +] @keyword.type + +[ + "async" + "await" +] @keyword.coroutine + +[ + "return" + "yield" +] @keyword.return + +(yield + "from" @keyword.return) + +(future_import_statement + "from" @keyword.import + "__future__" @module.builtin) + +(import_from_statement + "from" @keyword.import) + +"import" @keyword.import + +(aliased_import + "as" @keyword.import) + +(wildcard_import + "*" @character.special) + +(import_statement + name: (dotted_name + (identifier) @module)) + +(import_statement + name: (aliased_import + name: (dotted_name + (identifier) @module) + alias: (identifier) @module)) + +(import_from_statement + module_name: (dotted_name + (identifier) @module)) + +(import_from_statement + module_name: (relative_import + (dotted_name + (identifier) @module))) + +[ + "if" + "elif" + "else" + "match" + "case" +] @keyword.conditional + +[ + "for" + "while" + "break" + "continue" +] @keyword.repeat + +[ + "try" + "except" + "except*" + "raise" + "finally" +] @keyword.exception + +(raise_statement + "from" @keyword.exception) + +(try_statement + (else_clause + "else" @keyword.exception)) + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(interpolation + "{" @punctuation.special + "}" @punctuation.special) + +(type_conversion) @function.macro + +[ + "," + "." + ":" + ";" + (ellipsis) +] @punctuation.delimiter + +((identifier) @type.builtin + (#any-of? @type.builtin + ; https://docs.python.org/3/library/exceptions.html + "BaseException" "Exception" "ArithmeticError" "BufferError" "LookupError" "AssertionError" + "AttributeError" "EOFError" "FloatingPointError" "GeneratorExit" "ImportError" + "ModuleNotFoundError" "IndexError" "KeyError" "KeyboardInterrupt" "MemoryError" "NameError" + "NotImplementedError" "OSError" "OverflowError" "RecursionError" "ReferenceError" "RuntimeError" + "StopIteration" "StopAsyncIteration" "SyntaxError" "IndentationError" "TabError" "SystemError" + "SystemExit" "TypeError" "UnboundLocalError" "UnicodeError" "UnicodeEncodeError" + "UnicodeDecodeError" "UnicodeTranslateError" "ValueError" "ZeroDivisionError" "EnvironmentError" + "IOError" "WindowsError" "BlockingIOError" "ChildProcessError" "ConnectionError" + "BrokenPipeError" "ConnectionAbortedError" "ConnectionRefusedError" "ConnectionResetError" + "FileExistsError" "FileNotFoundError" "InterruptedError" "IsADirectoryError" + "NotADirectoryError" "PermissionError" "ProcessLookupError" "TimeoutError" "Warning" + "UserWarning" "DeprecationWarning" "PendingDeprecationWarning" "SyntaxWarning" "RuntimeWarning" + "FutureWarning" "ImportWarning" "UnicodeWarning" "BytesWarning" "ResourceWarning" + ; https://docs.python.org/3/library/stdtypes.html + "bool" "int" "float" "complex" "list" "tuple" "range" "str" "bytes" "bytearray" "memoryview" + "set" "frozenset" "dict" "type" "object")) + +; Normal parameters +(parameters + (identifier) @variable.parameter) + +; Lambda parameters +(lambda_parameters + (identifier) @variable.parameter) + +(lambda_parameters + (tuple_pattern + (identifier) @variable.parameter)) + +; Default parameters +(keyword_argument + name: (identifier) @variable.parameter) + +; Naming parameters on call-site +(default_parameter + name: (identifier) @variable.parameter) + +(typed_parameter + (identifier) @variable.parameter) + +(typed_default_parameter + name: (identifier) @variable.parameter) + +; Variadic parameters *args, **kwargs +(parameters + (list_splat_pattern ; *args + (identifier) @variable.parameter)) + +(parameters + (dictionary_splat_pattern ; **kwargs + (identifier) @variable.parameter)) + +; Typed variadic parameters +(parameters + (typed_parameter + (list_splat_pattern ; *args: type + (identifier) @variable.parameter))) + +(parameters + (typed_parameter + (dictionary_splat_pattern ; *kwargs: type + (identifier) @variable.parameter))) + +; Lambda parameters +(lambda_parameters + (list_splat_pattern + (identifier) @variable.parameter)) + +(lambda_parameters + (dictionary_splat_pattern + (identifier) @variable.parameter)) + +((identifier) @variable.builtin + (#eq? @variable.builtin "self")) + +((identifier) @variable.builtin + (#eq? @variable.builtin "cls")) + +; After @type.builtin bacause builtins (such as `type`) are valid as attribute name +((attribute + attribute: (identifier) @variable.member) + (#lua-match? @variable.member "^[%l_].*$")) + +; Class definitions +(class_definition + name: (identifier) @type) + +(class_definition + body: (block + (function_definition + name: (identifier) @function.method))) + +(class_definition + superclasses: (argument_list + (identifier) @type)) + +((class_definition + body: (block + (expression_statement + (assignment + left: (identifier) @variable.member)))) + (#lua-match? @variable.member "^[%l_].*$")) + +((class_definition + body: (block + (expression_statement + (assignment + left: (_ + (identifier) @variable.member))))) + (#lua-match? @variable.member "^[%l_].*$")) + +((class_definition + (block + (function_definition + name: (identifier) @constructor))) + (#any-of? @constructor "__new__" "__init__")) + +; Function calls +(call + function: (identifier) @function.call) + +(call + function: (attribute + attribute: (identifier) @function.method.call)) + +((call + function: (identifier) @constructor) + (#lua-match? @constructor "^%u")) + +((call + function: (attribute + attribute: (identifier) @constructor)) + (#lua-match? @constructor "^%u")) + +; Builtin functions +((call + function: (identifier) @function.builtin) + (#any-of? @function.builtin + "abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" "bytes" "callable" "chr" + "classmethod" "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "exec" + "filter" "float" "format" "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id" + "input" "int" "isinstance" "issubclass" "iter" "len" "list" "locals" "map" "max" "memoryview" + "min" "next" "object" "oct" "open" "ord" "pow" "print" "property" "range" "repr" "reversed" + "round" "set" "setattr" "slice" "sorted" "staticmethod" "str" "sum" "super" "tuple" "type" + "vars" "zip" "__import__")) + +; Regex from the `re` module +(call + function: (attribute + object: (identifier) @_re) + arguments: (argument_list + . + (string + (string_content) @string.regexp)) + (#eq? @_re "re")) + +; Decorators +((decorator + "@" @attribute) + (#set! priority 101)) + +(decorator + (identifier) @attribute) + +(decorator + (attribute + attribute: (identifier) @attribute)) + +(decorator + (call + (identifier) @attribute)) + +(decorator + (call + (attribute + attribute: (identifier) @attribute))) + +((decorator + (identifier) @attribute.builtin) + (#any-of? @attribute.builtin "classmethod" "property" "staticmethod")) diff --git a/runtime/queries/python/indents.scm b/runtime/queries/python/indents.scm new file mode 100644 index 000000000..2414812a7 --- /dev/null +++ b/runtime/queries/python/indents.scm @@ -0,0 +1,213 @@ +[ + (import_from_statement) + (generator_expression) + (list_comprehension) + (set_comprehension) + (dictionary_comprehension) + (tuple_pattern) + (list_pattern) + (binary_operator) + (lambda) + (concatenated_string) +] @indent.begin + +((list) @indent.align + (#set! indent.open_delimiter "[") + (#set! indent.close_delimiter "]")) + +((dictionary) @indent.align + (#set! indent.open_delimiter "{") + (#set! indent.close_delimiter "}")) + +((set) @indent.align + (#set! indent.open_delimiter "{") + (#set! indent.close_delimiter "}")) + +((parenthesized_expression) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +((for_statement) @indent.begin + (#set! indent.immediate 1)) + +((if_statement) @indent.begin + (#set! indent.immediate 1)) + +((while_statement) @indent.begin + (#set! indent.immediate 1)) + +((try_statement) @indent.begin + (#set! indent.immediate 1)) + +(ERROR + "try" + . + ":" + (#set! indent.immediate 1)) @indent.begin + +(ERROR + "try" + . + ":" + (ERROR + (block + (expression_statement + (identifier) @_except) @indent.branch)) + (#eq? @_except "except")) + +((function_definition) @indent.begin + (#set! indent.immediate 1)) + +((class_definition) @indent.begin + (#set! indent.immediate 1)) + +((with_statement) @indent.begin + (#set! indent.immediate 1)) + +((match_statement) @indent.begin + (#set! indent.immediate 1)) + +((case_clause) @indent.begin + (#set! indent.immediate 1)) + +; if (cond1 +; or cond2 +; or cond3): +; pass +; +(if_statement + condition: (parenthesized_expression) @indent.align + (#lua-match? @indent.align "^%([^\n]") + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")") + (#set! indent.avoid_last_matching_next 1)) + +; while ( +; cond1 +; or cond2 +; or cond3): +; pass +; +(while_statement + condition: (parenthesized_expression) @indent.align + (#lua-match? @indent.align "[^\n ]%)$") + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")") + (#set! indent.avoid_last_matching_next 1)) + +; if ( +; cond1 +; or cond2 +; or cond3): +; pass +; +(if_statement + condition: (parenthesized_expression) @indent.align + (#lua-match? @indent.align "[^\n ]%)$") + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")") + (#set! indent.avoid_last_matching_next 1)) + +(ERROR + "(" @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")") + . + (_)) + +((argument_list) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +((parameters) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +((parameters) @indent.align + (#lua-match? @indent.align "[^\n ]%)$") + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")") + (#set! indent.avoid_last_matching_next 1)) + +((tuple) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +(ERROR + "[" @indent.align + (#set! indent.open_delimiter "[") + (#set! indent.close_delimiter "]") + . + (_)) + +(ERROR + "{" @indent.align + (#set! indent.open_delimiter "{") + (#set! indent.close_delimiter "}") + . + (_)) + +[ + (break_statement) + (continue_statement) +] @indent.dedent + +(ERROR + (_) @indent.branch + ":" + . + (#lua-match? @indent.branch "^else")) + +(ERROR + (_) @indent.branch @indent.dedent + ":" + . + (#lua-match? @indent.branch "^elif")) + +(generator_expression + ")" @indent.end) + +(list_comprehension + "]" @indent.end) + +(set_comprehension + "}" @indent.end) + +(dictionary_comprehension + "}" @indent.end) + +(tuple_pattern + ")" @indent.end) + +(list_pattern + "]" @indent.end) + +(return_statement + [ + (_) @indent.end + (_ + [ + (_) + ")" + "}" + "]" + ] @indent.end .) + (attribute + attribute: (_) @indent.end) + (call + arguments: (_ + ")" @indent.end)) + "return" @indent.end + ] .) + +[ + ")" + "]" + "}" + (elif_clause) + (else_clause) + (except_clause) + (finally_clause) +] @indent.branch + +(string) @indent.auto diff --git a/runtime/queries/python/injections.scm b/runtime/queries/python/injections.scm new file mode 100644 index 000000000..bbc924be4 --- /dev/null +++ b/runtime/queries/python/injections.scm @@ -0,0 +1,18 @@ +(call + function: (attribute + object: (identifier) @_re) + arguments: (argument_list + . + (string + (string_content) @injection.content)) + (#eq? @_re "re") + (#set! injection.language "regex")) + +((binary_operator + left: (string + (string_content) @injection.content) + operator: "%") + (#set! injection.language "printf")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/python/locals.scm b/runtime/queries/python/locals.scm new file mode 100644 index 000000000..b012e9eee --- /dev/null +++ b/runtime/queries/python/locals.scm @@ -0,0 +1,124 @@ +; Program structure +(module) @local.scope + +(class_definition + body: (block + (expression_statement + (assignment + left: (identifier) @local.definition.field)))) @local.scope + +(class_definition + body: (block + (expression_statement + (assignment + left: (_ + (identifier) @local.definition.field))))) @local.scope + +; Imports +(aliased_import + alias: (identifier) @local.definition.import) @local.scope + +(import_statement + name: (dotted_name + (identifier) @local.definition.import)) @local.scope + +(import_from_statement + name: (dotted_name + (identifier) @local.definition.import)) @local.scope + +; Function with parameters, defines parameters +(parameters + (identifier) @local.definition.parameter) + +(default_parameter + (identifier) @local.definition.parameter) + +(typed_parameter + (identifier) @local.definition.parameter) + +(typed_default_parameter + (identifier) @local.definition.parameter) + +; *args parameter +(parameters + (list_splat_pattern + (identifier) @local.definition.parameter)) + +; **kwargs parameter +(parameters + (dictionary_splat_pattern + (identifier) @local.definition.parameter)) + +; Function defines function and scope +((function_definition + name: (identifier) @local.definition.function) @local.scope + (#set! definition.function.scope "parent")) + +((class_definition + name: (identifier) @local.definition.type) @local.scope + (#set! definition.type.scope "parent")) + +(class_definition + body: (block + (function_definition + name: (identifier) @local.definition.method))) + +; Loops +; not a scope! +(for_statement + left: (pattern_list + (identifier) @local.definition.var)) + +(for_statement + left: (tuple_pattern + (identifier) @local.definition.var)) + +(for_statement + left: (identifier) @local.definition.var) + +; not a scope! +;(while_statement) @local.scope +; for in list comprehension +(for_in_clause + left: (identifier) @local.definition.var) + +(for_in_clause + left: (tuple_pattern + (identifier) @local.definition.var)) + +(for_in_clause + left: (pattern_list + (identifier) @local.definition.var)) + +(dictionary_comprehension) @local.scope + +(list_comprehension) @local.scope + +(set_comprehension) @local.scope + +; Assignments +(assignment + left: (identifier) @local.definition.var) + +(assignment + left: (pattern_list + (identifier) @local.definition.var)) + +(assignment + left: (tuple_pattern + (identifier) @local.definition.var)) + +(assignment + left: (attribute + (identifier) + (identifier) @local.definition.field)) + +; Walrus operator x := 1 +(named_expression + (identifier) @local.definition.var) + +(as_pattern + alias: (as_pattern_target) @local.definition.var) + +; REFERENCES +(identifier) @local.reference diff --git a/runtime/queries/ql/folds.scm b/runtime/queries/ql/folds.scm new file mode 100644 index 000000000..eb7f27273 --- /dev/null +++ b/runtime/queries/ql/folds.scm @@ -0,0 +1,7 @@ +[ + (module) + (classlessPredicate) + (dataclass) + (charpred) + (memberPredicate) +] @fold diff --git a/runtime/queries/ql/highlights.scm b/runtime/queries/ql/highlights.scm new file mode 100644 index 000000000..f42812068 --- /dev/null +++ b/runtime/queries/ql/highlights.scm @@ -0,0 +1,154 @@ +[ + "as" + "by" + "extends" + "from" + "implies" + "in" + "module" + "order" + "select" + "where" + (predicate) + (result) + (specialId) +] @keyword + +[ + "newtype" + "class" +] @keyword.type + +[ + "and" + "not" + "or" +] @keyword.operator + +[ + "avg" + "any" + "count" + "concat" + "exists" + "max" + "min" + "instanceof" + "rank" + "sum" + "strictconcat" + "strictcount" + "strictsum" +] @function.builtin + +"import" @keyword.import + +[ + "if" + "then" + "else" +] @keyword.conditional + +[ + "forall" + "forex" +] @keyword.repeat + +[ + "asc" + "desc" +] @keyword.modifier + +[ + (true) + (false) +] @boolean + +[ + (this) + (super) +] @variable.builtin + +[ + "boolean" + "float" + "int" + "date" + "string" +] @type.builtin + +(annotName) @attribute + +[ + "<" + "<=" + "=" + ">" + ">=" + "-" + "!=" + "/" + "*" + "%" + "+" + "::" +] @operator + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + "," + "|" +] @punctuation.delimiter + +(moduleExpr + (simpleId) @module) + +(module + name: (moduleName) @module) + +(dataclass + name: (className) @type) + +(typeExpr + name: (className) @type) + +(datatype + name: (className) @type.definition) + +(importModuleExpr + qualName: (simpleId) @variable) + +(varName) @variable + +(integer) @number + +(float) @number.float + +(string) @string + +(aritylessPredicateExpr + (literalId) @function) + +(memberPredicate + name: (predicateName) @function) + +(classlessPredicate + name: (predicateName) @function) + +(charpred + (className) @function) + +[ + (line_comment) + (block_comment) +] @comment @spell + +(qldoc) @comment.documentation diff --git a/runtime/queries/ql/indents.scm b/runtime/queries/ql/indents.scm new file mode 100644 index 000000000..1a4a1bdea --- /dev/null +++ b/runtime/queries/ql/indents.scm @@ -0,0 +1,23 @@ +[ + (module) + (dataclass) + (classMember) + (classlessPredicate) + (quantified) +] @indent.begin + +[ + ")" + "}" +] @indent.end + +[ + ")" + "}" +] @indent.branch + +[ + (block_comment) + (line_comment) + (qldoc) +] @indent.ignore diff --git a/runtime/queries/ql/injections.scm b/runtime/queries/ql/injections.scm new file mode 100644 index 000000000..090116c89 --- /dev/null +++ b/runtime/queries/ql/injections.scm @@ -0,0 +1,6 @@ +([ + (line_comment) + (block_comment) + (qldoc) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/ql/locals.scm b/runtime/queries/ql/locals.scm new file mode 100644 index 000000000..239420151 --- /dev/null +++ b/runtime/queries/ql/locals.scm @@ -0,0 +1,49 @@ +; SCOPES +(module) @local.scope + +(dataclass) @local.scope + +(datatype) @local.scope + +; TODO does not work +;(classMember (body) @local.scope) +(memberPredicate + (body) @local.scope) + +(classlessPredicate + (body) @local.scope) + +(quantified + (conjunction) @local.scope) + +(select) @local.scope + +; DEFINITIONS +; module +(module + name: (moduleName) @local.definition.namespace) + +; classes +(dataclass + name: (className) @local.definition.type) + +(datatype + name: (className) @local.definition.type) + +; predicates +(charpred + (className) @local.definition.method) + +(memberPredicate + name: (predicateName) @local.definition.method) + +(classlessPredicate + name: (predicateName) @local.definition.function) + +; variables +(varDecl + (varName + (simpleId) @local.definition.var)) + +; REFERENCES +(simpleId) @local.reference diff --git a/runtime/queries/qmldir/highlights.scm b/runtime/queries/qmldir/highlights.scm new file mode 100644 index 000000000..780dbb3d4 --- /dev/null +++ b/runtime/queries/qmldir/highlights.scm @@ -0,0 +1,20 @@ +; Preproc +(command + (identifier) @keyword.directive) + +; Keywords +(keyword) @keyword + +; Literals +(number) @number + +(float) @number.float + +; Variables +[ + (identifier) + (unit) +] @variable + +; Comments +(comment) @comment @spell diff --git a/runtime/queries/qmldir/injections.scm b/runtime/queries/qmldir/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/qmldir/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/qmljs/folds.scm b/runtime/queries/qmljs/folds.scm new file mode 100644 index 000000000..9b917993e --- /dev/null +++ b/runtime/queries/qmljs/folds.scm @@ -0,0 +1,8 @@ +[ + (ui_object_definition) + (function_declaration) + (statement_block) + (if_statement) + (ui_binding) + (comment) +] @fold diff --git a/runtime/queries/qmljs/highlights.scm b/runtime/queries/qmljs/highlights.scm new file mode 100644 index 000000000..27f332028 --- /dev/null +++ b/runtime/queries/qmljs/highlights.scm @@ -0,0 +1,116 @@ +; inherits: ecma + +"pragma" @keyword.import + +; Annotations +(ui_annotation + "@" @operator + type_name: [ + (identifier) @attribute + (nested_identifier + (identifier) @attribute) + ]) + +; type +(ui_property + type: (type_identifier) @type) + +; Properties +(ui_object_definition_binding + name: [ + (identifier) @property + (nested_identifier + (identifier) @property) + ]) + +(ui_binding + name: [ + (identifier) @property + (nested_identifier + (identifier) @property) + ]) + +; locals query appears not working unless id: <ref> isn't a parameter. +(ui_binding + name: (identifier) @property + (#eq? @property "id") + value: (expression_statement + (identifier) @variable)) + +(ui_property + name: (identifier) @property) + +(ui_required + name: (identifier) @property) + +(ui_list_property_type + [ + "<" + ">" + ] @punctuation.bracket) + +; Signals +(ui_signal + name: (identifier) @function) + +(ui_signal_parameter + (identifier) @variable) + +; ui_object_definition +(ui_object_definition + type_name: (identifier) @type) + +(ui_object_definition + type_name: (nested_identifier) @type) + +; namespace +(nested_identifier + (nested_identifier + (identifier) @module)) + +; Tokens +;------- +[ + "abstract" + "private" + "protected" + "public" + "default" + "readonly" + "required" +] @keyword.modifier + +; from typescript +(type_identifier) @type + +(predefined_type) @type.builtin + +(type_arguments + "<" @punctuation.bracket + ">" @punctuation.bracket) + +; Variables +(required_parameter + (identifier) @variable) + +(optional_parameter + (identifier) @variable) + +; Keywords +[ + "on" + "property" + "signal" + "declare" + "implements" + "override" +] @keyword + +[ + "interface" + "type" + "enum" + "namespace" +] @keyword.type + +"keyof" @keyword.operator diff --git a/runtime/queries/qmljs/injections.scm b/runtime/queries/qmljs/injections.scm new file mode 100644 index 000000000..04328f099 --- /dev/null +++ b/runtime/queries/qmljs/injections.scm @@ -0,0 +1 @@ +; inherits: ecma diff --git a/runtime/queries/query/folds.scm b/runtime/queries/query/folds.scm new file mode 100644 index 000000000..47dd96512 --- /dev/null +++ b/runtime/queries/query/folds.scm @@ -0,0 +1,6 @@ +[ + (named_node) + (predicate) + (grouping) + (list) +] @fold diff --git a/runtime/queries/query/highlights.scm b/runtime/queries/query/highlights.scm new file mode 100644 index 000000000..cbd192a8f --- /dev/null +++ b/runtime/queries/query/highlights.scm @@ -0,0 +1,102 @@ +(string) @string + +(escape_sequence) @string.escape + +(capture + (identifier) @type) + +(predicate + name: (identifier) @function.call) + +(named_node + name: (identifier) @variable) + +(missing_node + name: (identifier) @variable) + +(field_definition + name: (identifier) @variable.member) + +(negated_field + "!" @operator + (identifier) @property) + +(comment) @comment @spell + +(quantifier) @operator + +(predicate_type) @punctuation.special + +"." @operator + +[ + "[" + "]" + "(" + ")" +] @punctuation.bracket + +[ + ":" + "/" +] @punctuation.delimiter + +[ + "@" + "#" +] @punctuation.special + +(predicate + "." @punctuation.special) + +"_" @character.special + +"MISSING" @keyword + +((parameters + (identifier) @number) + (#match? @number "^[-+]?[0-9]+(.[0-9]+)?$")) + +((program + . + (comment)* + . + (comment) @keyword.import @nospell) + (#lua-match? @keyword.import "^;+ *inherits *:")) + +((program + . + (comment)* + . + (comment) @keyword.directive @nospell) + (#lua-match? @keyword.directive "^;+ *extends *$")) + +((comment) @keyword.directive @nospell + (#lua-match? @keyword.directive "^;+%s*format%-ignore%s*$")) + +((predicate + name: (identifier) @_name + parameters: (parameters + . + (capture)? + . + (identifier) @property)) + (#eq? @_name "set")) + +((predicate + name: (identifier) @_name + parameters: (parameters + (string + "\"" @string + "\"" @string) @string.regexp)) + (#any-of? @_name "match" "not-match" "vim-match" "not-vim-match" "lua-match" "not-lua-match")) + +((predicate + name: (identifier) @_name + parameters: (parameters + (string + "\"" @string + "\"" @string) @string.regexp + . + (string) .)) + (#any-of? @_name "gsub" "not-gsub")) diff --git a/runtime/queries/query/indents.scm b/runtime/queries/query/indents.scm new file mode 100644 index 000000000..5cea97e1e --- /dev/null +++ b/runtime/queries/query/indents.scm @@ -0,0 +1,25 @@ +[ + (list) + (named_node) + (grouping) + (predicate) + "[" +] @indent.begin + +; ERROR node indents +(ERROR + "(") @indent.begin + +"]" @indent.branch @indent.end + +[ + ")" + "?" + "*" + "+" +] @indent.end + +; Captures always mark the end of a node +; Because of that, mark it as indent.end +(capture + name: (identifier) @indent.end) diff --git a/runtime/queries/query/injections.scm b/runtime/queries/query/injections.scm new file mode 100644 index 000000000..759f9b2e2 --- /dev/null +++ b/runtime/queries/query/injections.scm @@ -0,0 +1,28 @@ +((predicate + name: (identifier) @_name + parameters: (parameters + (string + (string_content) @injection.content))) + (#any-of? @_name "match" "not-match" "any-match" "vim-match" "not-vim-match" "any-vim-match") + (#set! injection.language "regex")) + +((predicate + name: (identifier) @_name + parameters: (parameters + (string + (string_content) @injection.content))) + (#any-of? @_name "lua-match" "not-lua-match" "any-lua-match") + (#set! injection.language "luap")) + +((predicate + name: (identifier) @_name + parameters: (parameters + (string + (string_content) @injection.content) + . + (string) .)) + (#any-of? @_name "gsub" "not-gsub") + (#set! injection.language "luap")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/query/locals.scm b/runtime/queries/query/locals.scm new file mode 100644 index 000000000..eca196aba --- /dev/null +++ b/runtime/queries/query/locals.scm @@ -0,0 +1,21 @@ +(program) @local.scope + +(program + (named_node) @local.scope) + +(program + (anonymous_node) @local.scope) + +(program + (grouping) @local.scope) + +(identifier) @local.reference + +(named_node + (capture) @local.definition.var) + +(anonymous_node + (capture) @local.definition.var) + +(grouping + (capture) @local.definition.var) diff --git a/runtime/queries/r/highlights.scm b/runtime/queries/r/highlights.scm new file mode 100644 index 000000000..c849dd838 --- /dev/null +++ b/runtime/queries/r/highlights.scm @@ -0,0 +1,148 @@ +; Literals +(integer) @number + +(float) @number.float + +(complex) @number + +(string) @string + +(string + (string_content + (escape_sequence) @string.escape)) + +; Comments +(comment) @comment @spell + +((program + . + (comment) @keyword.directive @nospell) + (#lua-match? @keyword.directive "^#!/")) + +; Operators +[ + "?" + ":=" + "=" + "<-" + "<<-" + "->" + "->>" + "~" + "|>" + "||" + "|" + "&&" + "&" + "<" + "<=" + ">" + ">=" + "==" + "!=" + "+" + "-" + "*" + "/" + "::" + ":::" + "**" + "^" + "$" + "@" + ":" + "!" + "special" +] @operator + +; Punctuation +[ + "(" + ")" + "{" + "}" + "[" + "]" + "[[" + "]]" +] @punctuation.bracket + +(comma) @punctuation.delimiter + +; Variables +(identifier) @variable + +; Functions +(binary_operator + lhs: (identifier) @function + operator: "<-" + rhs: (function_definition)) + +(binary_operator + lhs: (identifier) @function + operator: "=" + rhs: (function_definition)) + +; Calls +(call + function: (identifier) @function.call) + +(extract_operator + rhs: (identifier) @variable.member) + +function: (extract_operator + rhs: (identifier) @function.method.call) + +; Parameters +(parameters + (parameter + name: (identifier) @variable.parameter)) + +(arguments + (argument + name: (identifier) @variable.parameter)) + +; Namespace +(namespace_operator + lhs: (identifier) @module) + +(call + function: (namespace_operator + rhs: (identifier) @function)) + +; Keywords +(function_definition + name: "function" @keyword.function) + +(function_definition + name: "\\" @operator) + +(return) @keyword.return + +[ + "if" + "else" +] @keyword.conditional + +[ + "while" + "repeat" + "for" + "in" + (break) + (next) +] @keyword.repeat + +[ + (true) + (false) +] @boolean + +[ + (null) + (inf) + (nan) + (na) + (dots) + (dot_dot_i) +] @constant.builtin diff --git a/runtime/queries/r/indents.scm b/runtime/queries/r/indents.scm new file mode 100644 index 000000000..79dbe5167 --- /dev/null +++ b/runtime/queries/r/indents.scm @@ -0,0 +1,33 @@ +[ + (braced_expression) + (parenthesized_expression) + (call) + "if" + "else" + "while" + "repeat" + "for" +] @indent.begin + +(binary_operator + rhs: (_) @_no_indent + (#not-kind-eq? @_no_indent function_definition)) @indent.begin + +[ + "}" + ")" +] @indent.branch + +((parameters + . + (parameter + name: (identifier))) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +[ + ")" + "}" +] @indent.end + +(comment) @indent.ignore diff --git a/runtime/queries/r/injections.scm b/runtime/queries/r/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/r/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/r/locals.scm b/runtime/queries/r/locals.scm new file mode 100644 index 000000000..3377552c8 --- /dev/null +++ b/runtime/queries/r/locals.scm @@ -0,0 +1,22 @@ +; locals.scm +(function_definition) @local.scope + +(argument + name: (identifier) @local.definition) + +(parameter + name: (identifier) @local.definition) + +(binary_operator + lhs: (identifier) @local.definition + operator: "<-") + +(binary_operator + lhs: (identifier) @local.definition + operator: "=") + +(binary_operator + operator: "->" + rhs: (identifier) @local.definition) + +(identifier) @local.reference diff --git a/runtime/queries/racket/folds.scm b/runtime/queries/racket/folds.scm new file mode 100644 index 000000000..115809a77 --- /dev/null +++ b/runtime/queries/racket/folds.scm @@ -0,0 +1,2 @@ +(program + (list) @fold) diff --git a/runtime/queries/racket/highlights.scm b/runtime/queries/racket/highlights.scm new file mode 100644 index 000000000..9e3066743 --- /dev/null +++ b/runtime/queries/racket/highlights.scm @@ -0,0 +1,685 @@ +; A highlight query can override the highlights queries before it. +; So the order is important. +; We should highlight general rules, then highlight special forms. +;------------------------------------------------------------------;; +; Basic highlights ;; +;------------------------------------------------------------------;; +; basic ;; +(number) @number + +(character) @character + +(boolean) @boolean + +(keyword) @string.special.symbol + +; string ;; +[ + (string) + (here_string) + (byte_string) +] @string + +(escape_sequence) @string.escape + +(regex) @string.regexp + +; comment ;; +[ + (comment) + (block_comment) + (sexp_comment) +] @comment + +[ + (comment) + (block_comment) +] @spell + +; symbol ;; +(symbol) @variable + +((symbol) @comment + (#lua-match? @comment "^#[cC][iIsS]$")) + +; extension ;; +(extension) @keyword + +(lang_name) @variable.builtin + +; quote ;; +(quote) @string.special.symbol + +; list ;; +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; procedure ;; +(list + . + (symbol) @function) + +;------------------------------------------------------------------;; +; Builtin highlights ;; +;------------------------------------------------------------------;; +; The following lists are generated by a racket script: +; https://gist.github.com/6cdh/65619e761753eb4166d15185a6236040 +; Don't edit them directly. +; keyword ;; +(list + . + (symbol) @keyword + (#any-of? @keyword + "#%app" "#%datum" "#%declare" "#%expression" "#%module-begin" "#%plain-app" "#%plain-lambda" + "#%plain-module-begin" "#%printing-module-begin" "#%provide" "#%require" "#%stratified-body" + "#%top" "#%top-interaction" "#%variable-reference" "->" "->*" "->*m" "->d" "->dm" "->i" "->m" + "..." ":do-in" "==" "=>" "_" "absent" "abstract" "all-defined-out" "all-from-out" "and" "any" + "augment" "augment*" "augment-final" "augment-final*" "augride" "augride*" "begin" + "begin-for-syntax" "begin0" "case" "case->" "case->m" "case-lambda" "class" "class*" + "class-field-accessor" "class-field-mutator" "class/c" "class/derived" "combine-in" + "combine-out" "command-line" "compound-unit" "compound-unit/infer" "cond" "cons/dc" "contract" + "contract-out" "contract-pos/neg-doubling" "contract-struct" "contracted" + "current-contract-region" "define" "define-compound-unit" "define-compound-unit/infer" + "define-contract-struct" "define-custom-hash-types" "define-custom-set-types" + "define-for-syntax" "define-local-member-name" "define-logger" "define-match-expander" + "define-member-name" "define-module-boundary-contract" "define-namespace-anchor" "define-opt/c" + "define-sequence-syntax" "define-serializable-class" "define-serializable-class*" + "define-signature" "define-signature-form" "define-splicing-for-clause-syntax" "define-struct" + "define-struct/contract" "define-struct/derived" "define-syntax" "define-syntax-rule" + "define-syntaxes" "define-unit" "define-unit-binding" "define-unit-from-context" + "define-unit/contract" "define-unit/new-import-export" "define-unit/s" "define-values" + "define-values-for-export" "define-values-for-syntax" "define-values/invoke-unit" + "define-values/invoke-unit/infer" "define/augment" "define/augment-final" "define/augride" + "define/contract" "define/final-prop" "define/match" "define/overment" "define/override" + "define/override-final" "define/private" "define/public" "define/public-final" "define/pubment" + "define/subexpression-pos-prop" "define/subexpression-pos-prop/name" "delay" "delay/idle" + "delay/name" "delay/strict" "delay/sync" "delay/thread" "do" "else" "except" "except-in" + "except-out" "export" "extends" "failure-cont" "field" "field-bound?" "file" + "flat-murec-contract" "flat-rec-contract" "for" "for*" "for*/and" "for*/async" "for*/first" + "for*/fold" "for*/fold/derived" "for*/foldr" "for*/foldr/derived" "for*/hash" "for*/hasheq" + "for*/hasheqv" "for*/last" "for*/list" "for*/lists" "for*/mutable-set" "for*/mutable-seteq" + "for*/mutable-seteqv" "for*/or" "for*/product" "for*/set" "for*/seteq" "for*/seteqv" + "for*/stream" "for*/sum" "for*/vector" "for*/weak-set" "for*/weak-seteq" "for*/weak-seteqv" + "for-label" "for-meta" "for-space" "for-syntax" "for-template" "for/and" "for/async" "for/first" + "for/fold" "for/fold/derived" "for/foldr" "for/foldr/derived" "for/hash" "for/hasheq" + "for/hasheqv" "for/last" "for/list" "for/lists" "for/mutable-set" "for/mutable-seteq" + "for/mutable-seteqv" "for/or" "for/product" "for/set" "for/seteq" "for/seteqv" "for/stream" + "for/sum" "for/vector" "for/weak-set" "for/weak-seteq" "for/weak-seteqv" "gen:custom-write" + "gen:dict" "gen:equal+hash" "gen:set" "gen:stream" "generic" "get-field" "hash/dc" "if" + "implies" "import" "include" "include-at/relative-to" "include-at/relative-to/reader" + "include/reader" "inherit" "inherit-field" "inherit/inner" "inherit/super" "init" "init-depend" + "init-field" "init-rest" "inner" "inspect" "instantiate" "interface" "interface*" + "invariant-assertion" "invoke-unit" "invoke-unit/infer" "lambda" "lazy" "let" "let*" + "let*-values" "let-syntax" "let-syntaxes" "let-values" "let/cc" "let/ec" "letrec" + "letrec-syntax" "letrec-syntaxes" "letrec-syntaxes+values" "letrec-values" "lib" "link" "local" + "local-require" "log-debug" "log-error" "log-fatal" "log-info" "log-warning" "match" "match*" + "match*/derived" "match-define" "match-define-values" "match-lambda" "match-lambda*" + "match-lambda**" "match-let" "match-let*" "match-let*-values" "match-let-values" "match-letrec" + "match-letrec-values" "match/derived" "match/values" "member-name-key" "mixin" "module" + "module*" "module+" "nand" "new" "nor" "object-contract" "object/c" "only" "only-in" + "only-meta-in" "only-space-in" "open" "opt/c" "or" "overment" "overment*" "override" "override*" + "override-final" "override-final*" "parameterize" "parameterize*" "parameterize-break" + "parametric->/c" "place" "place*" "place/context" "planet" "prefix" "prefix-in" "prefix-out" + "private" "private*" "prompt-tag/c" "prop:dict/contract" "protect-out" "provide" + "provide-signature-elements" "provide/contract" "public" "public*" "public-final" + "public-final*" "pubment" "pubment*" "quasiquote" "quasisyntax" "quasisyntax/loc" "quote" + "quote-syntax" "quote-syntax/prune" "recontract-out" "recursive-contract" "relative-in" "rename" + "rename-in" "rename-inner" "rename-out" "rename-super" "require" "send" "send*" "send+" + "send-generic" "send/apply" "send/keyword-apply" "set!" "set!-values" "set-field!" "shared" + "stream" "stream*" "stream-cons" "stream-lazy" "struct" "struct*" "struct-copy" + "struct-field-index" "struct-guard/c" "struct-out" "struct/c" "struct/contract" "struct/ctc" + "struct/dc" "struct/derived" "submod" "super" "super-instantiate" "super-make-object" + "super-new" "syntax" "syntax-case" "syntax-case*" "syntax-id-rules" "syntax-rules" "syntax/loc" + "tag" "this" "this%" "thunk" "thunk*" "time" "unconstrained-domain->" "unit" "unit-from-context" + "unit/c" "unit/new-import-export" "unit/s" "unless" "unquote" "unquote-splicing" "unsyntax" + "unsyntax-splicing" "values/drop" "when" "with-continuation-mark" "with-contract" + "with-contract-continuation-mark" "with-handlers" "with-handlers*" "with-method" "with-syntax" + "~?" "~@" "λ") + ) + +; builtin procedures +((symbol) @function.builtin + (#any-of? @function.builtin + "*" "*list/c" "+" "-" "/" "<" "</c" "<=" "<=/c" "=" "=/c" ">" ">/c" ">=" ">=/c" + "abort-current-continuation" "abs" "absolute-path?" "acos" "add-between" "add1" "alarm-evt" + "and/c" "andmap" "angle" "any/c" "append" "append*" "append-map" "apply" "argmax" "argmin" + "arithmetic-shift" "arity-at-least" "arity-at-least-value" "arity-at-least?" + "arity-checking-wrapper" "arity-includes?" "arity=?" "arrow-contract-info" + "arrow-contract-info-accepts-arglist" "arrow-contract-info-chaperone-procedure" + "arrow-contract-info-check-first-order" "arrow-contract-info?" "asin" "assert-unreachable" + "assf" "assoc" "assq" "assv" "atan" "bad-number-of-results" "banner" "base->-doms/c" + "base->-rngs/c" "base->?" "between/c" "bitwise-and" "bitwise-bit-field" "bitwise-bit-set?" + "bitwise-ior" "bitwise-not" "bitwise-xor" "blame-add-car-context" "blame-add-cdr-context" + "blame-add-context" "blame-add-missing-party" "blame-add-nth-arg-context" + "blame-add-range-context" "blame-add-unknown-context" "blame-context" "blame-contract" + "blame-fmt->-string" "blame-missing-party?" "blame-negative" "blame-original?" "blame-positive" + "blame-replace-negative" "blame-replaced-negative?" "blame-source" "blame-swap" "blame-swapped?" + "blame-update" "blame-value" "blame?" "boolean=?" "boolean?" "bound-identifier=?" "box" + "box-cas!" "box-immutable" "box-immutable/c" "box/c" "box?" "break-enabled" + "break-parameterization?" "break-thread" "build-chaperone-contract-property" + "build-compound-type-name" "build-contract-property" "build-flat-contract-property" "build-list" + "build-path" "build-path/convention-type" "build-string" "build-vector" "byte-pregexp" + "byte-pregexp?" "byte-ready?" "byte-regexp" "byte-regexp?" "byte?" "bytes" + "bytes->immutable-bytes" "bytes->list" "bytes->path" "bytes->path-element" + "bytes->string/latin-1" "bytes->string/locale" "bytes->string/utf-8" "bytes-append" + "bytes-append*" "bytes-close-converter" "bytes-convert" "bytes-convert-end" "bytes-converter?" + "bytes-copy" "bytes-copy!" "bytes-environment-variable-name?" "bytes-fill!" "bytes-join" + "bytes-length" "bytes-no-nuls?" "bytes-open-converter" "bytes-ref" "bytes-set!" + "bytes-utf-8-index" "bytes-utf-8-length" "bytes-utf-8-ref" "bytes<?" "bytes=?" "bytes>?" + "bytes?" "caaaar" "caaadr" "caaar" "caadar" "caaddr" "caadr" "caar" "cadaar" "cadadr" "cadar" + "caddar" "cadddr" "caddr" "cadr" "call-in-continuation" "call-in-nested-thread" + "call-with-atomic-output-file" "call-with-break-parameterization" + "call-with-composable-continuation" "call-with-continuation-barrier" + "call-with-continuation-prompt" "call-with-current-continuation" + "call-with-default-reading-parameterization" "call-with-escape-continuation" + "call-with-exception-handler" "call-with-file-lock/timeout" + "call-with-immediate-continuation-mark" "call-with-input-bytes" "call-with-input-file" + "call-with-input-file*" "call-with-input-string" "call-with-output-bytes" + "call-with-output-file" "call-with-output-file*" "call-with-output-string" + "call-with-parameterization" "call-with-semaphore" "call-with-semaphore/enable-break" + "call-with-values" "call/cc" "call/ec" "car" "cartesian-product" "cdaaar" "cdaadr" "cdaar" + "cdadar" "cdaddr" "cdadr" "cdar" "cddaar" "cddadr" "cddar" "cdddar" "cddddr" "cdddr" "cddr" + "cdr" "ceiling" "channel-get" "channel-put" "channel-put-evt" "channel-put-evt?" + "channel-try-get" "channel/c" "channel?" "chaperone-box" "chaperone-channel" + "chaperone-continuation-mark-key" "chaperone-contract-property?" "chaperone-contract?" + "chaperone-evt" "chaperone-hash" "chaperone-hash-set" "chaperone-of?" "chaperone-procedure" + "chaperone-procedure*" "chaperone-prompt-tag" "chaperone-struct" "chaperone-struct-type" + "chaperone-vector" "chaperone-vector*" "chaperone?" "char->integer" "char-alphabetic?" + "char-blank?" "char-ci<=?" "char-ci<?" "char-ci=?" "char-ci>=?" "char-ci>?" "char-downcase" + "char-foldcase" "char-general-category" "char-graphic?" "char-in" "char-in/c" + "char-iso-control?" "char-lower-case?" "char-numeric?" "char-punctuation?" "char-ready?" + "char-symbolic?" "char-title-case?" "char-titlecase" "char-upcase" "char-upper-case?" + "char-utf-8-length" "char-whitespace?" "char<=?" "char<?" "char=?" "char>=?" "char>?" "char?" + "check-duplicate-identifier" "check-duplicates" "checked-procedure-check-and-extract" + "choice-evt" "class->interface" "class-info" "class-seal" "class-unseal" "class?" "cleanse-path" + "close-input-port" "close-output-port" "coerce-chaperone-contract" "coerce-chaperone-contracts" + "coerce-contract" "coerce-contract/f" "coerce-contracts" "coerce-flat-contract" + "coerce-flat-contracts" "collect-garbage" "collection-file-path" "collection-path" + "combinations" "combine-output" "compile" "compile-allow-set!-undefined" + "compile-context-preservation-enabled" "compile-enforce-module-constants" "compile-syntax" + "compile-target-machine?" "compiled-expression-recompile" "compiled-expression?" + "compiled-module-expression?" "complete-path?" "complex?" "compose" "compose1" "conjoin" + "conjugate" "cons" "cons/c" "cons?" "const" "continuation-mark-key/c" "continuation-mark-key?" + "continuation-mark-set->context" "continuation-mark-set->iterator" "continuation-mark-set->list" + "continuation-mark-set->list*" "continuation-mark-set-first" "continuation-mark-set?" + "continuation-marks" "continuation-prompt-available?" "continuation-prompt-tag?" "continuation?" + "contract-custom-write-property-proc" "contract-equivalent?" "contract-exercise" + "contract-first-order" "contract-first-order-passes?" "contract-late-neg-projection" + "contract-name" "contract-proc" "contract-projection" "contract-property?" + "contract-random-generate" "contract-random-generate-env?" "contract-random-generate-fail?" + "contract-random-generate-get-current-environment" "contract-random-generate-stash" + "contract-random-generate/choose" "contract-stronger?" "contract-struct-exercise" + "contract-struct-generate" "contract-struct-late-neg-projection" + "contract-struct-list-contract?" "contract-val-first-projection" "contract?" "convert-stream" + "copy-directory/files" "copy-file" "copy-port" "cos" "cosh" "count" "current-blame-format" + "current-break-parameterization" "current-code-inspector" "current-command-line-arguments" + "current-compile" "current-compile-realm" "current-compile-target-machine" + "current-compiled-file-roots" "current-continuation-marks" "current-custodian" + "current-directory" "current-directory-for-user" "current-drive" "current-environment-variables" + "current-error-message-adjuster" "current-error-port" "current-eval" + "current-evt-pseudo-random-generator" "current-force-delete-permissions" "current-future" + "current-gc-milliseconds" "current-get-interaction-evt" "current-get-interaction-input-port" + "current-inexact-milliseconds" "current-inexact-monotonic-milliseconds" "current-input-port" + "current-inspector" "current-library-collection-links" "current-library-collection-paths" + "current-load" "current-load-extension" "current-load-relative-directory" + "current-load/use-compiled" "current-locale" "current-logger" "current-memory-use" + "current-milliseconds" "current-module-declare-name" "current-module-declare-source" + "current-module-name-resolver" "current-module-path-for-load" "current-namespace" + "current-output-port" "current-parameterization" "current-plumber" + "current-preserved-thread-cell-values" "current-print" "current-process-milliseconds" + "current-prompt-read" "current-pseudo-random-generator" "current-read-interaction" + "current-reader-guard" "current-readtable" "current-seconds" "current-security-guard" + "current-subprocess-custodian-mode" "current-subprocess-keep-file-descriptors" "current-thread" + "current-thread-group" "current-thread-initial-stack-size" "current-write-relative-directory" + "curry" "curryr" "custodian-box-value" "custodian-box?" "custodian-limit-memory" + "custodian-managed-list" "custodian-memory-accounting-available?" "custodian-require-memory" + "custodian-shut-down?" "custodian-shutdown-all" "custodian?" "custom-print-quotable-accessor" + "custom-print-quotable?" "custom-write-accessor" "custom-write-property-proc" "custom-write?" + "date" "date*" "date*-nanosecond" "date*-time-zone-name" "date*?" "date-day" "date-dst?" + "date-hour" "date-minute" "date-month" "date-second" "date-time-zone-offset" "date-week-day" + "date-year" "date-year-day" "date?" "datum->syntax" "datum-intern-literal" + "default-continuation-prompt-tag" "degrees->radians" "delete-directory" "delete-directory/files" + "delete-file" "denominator" "dict->list" "dict-can-functional-set?" "dict-can-remove-keys?" + "dict-clear" "dict-clear!" "dict-copy" "dict-count" "dict-empty?" "dict-for-each" + "dict-has-key?" "dict-implements/c" "dict-implements?" "dict-iter-contract" "dict-iterate-first" + "dict-iterate-key" "dict-iterate-next" "dict-iterate-value" "dict-key-contract" "dict-keys" + "dict-map" "dict-mutable?" "dict-ref" "dict-ref!" "dict-remove" "dict-remove!" "dict-set" + "dict-set!" "dict-set*" "dict-set*!" "dict-update" "dict-update!" "dict-value-contract" + "dict-values" "dict?" "directory-exists?" "directory-list" "disjoin" "display" "display-lines" + "display-lines-to-file" "display-to-file" "displayln" "double-flonum?" "drop" + "drop-common-prefix" "drop-right" "dropf" "dropf-right" "dump-memory-stats" "dup-input-port" + "dup-output-port" "dynamic->*" "dynamic-get-field" "dynamic-object/c" "dynamic-place" + "dynamic-place*" "dynamic-require" "dynamic-require-for-syntax" "dynamic-send" + "dynamic-set-field!" "dynamic-wind" "eighth" "empty?" "environment-variables-copy" + "environment-variables-names" "environment-variables-ref" "environment-variables-set!" + "environment-variables?" "eof-evt" "eof-object?" "ephemeron-value" "ephemeron?" "eprintf" + "eq-contract-val" "eq-contract?" "eq-hash-code" "eq?" "equal-contract-val" "equal-contract?" + "equal-hash-code" "equal-secondary-hash-code" "equal?" "equal?/recur" "eqv-hash-code" "eqv?" + "error" "error-contract->adjusted-string" "error-display-handler" "error-escape-handler" + "error-message->adjusted-string" "error-print-context-length" "error-print-source-location" + "error-print-width" "error-syntax->string-handler" "error-value->string-handler" "eval" + "eval-jit-enabled" "eval-syntax" "even?" "evt/c" "evt?" "exact->inexact" "exact-ceiling" + "exact-floor" "exact-integer?" "exact-nonnegative-integer?" "exact-positive-integer?" + "exact-round" "exact-truncate" "exact?" "executable-yield-handler" "exit" "exit-handler" "exn" + "exn-continuation-marks" "exn-message" "exn:break" "exn:break-continuation" "exn:break:hang-up" + "exn:break:hang-up?" "exn:break:terminate" "exn:break:terminate?" "exn:break?" "exn:fail" + "exn:fail:contract" "exn:fail:contract:arity" "exn:fail:contract:arity?" + "exn:fail:contract:blame" "exn:fail:contract:blame-object" "exn:fail:contract:blame?" + "exn:fail:contract:continuation" "exn:fail:contract:continuation?" + "exn:fail:contract:divide-by-zero" "exn:fail:contract:divide-by-zero?" + "exn:fail:contract:non-fixnum-result" "exn:fail:contract:non-fixnum-result?" + "exn:fail:contract:variable" "exn:fail:contract:variable-id" "exn:fail:contract:variable?" + "exn:fail:contract?" "exn:fail:filesystem" "exn:fail:filesystem:errno" + "exn:fail:filesystem:errno-errno" "exn:fail:filesystem:errno?" "exn:fail:filesystem:exists" + "exn:fail:filesystem:exists?" "exn:fail:filesystem:missing-module" + "exn:fail:filesystem:missing-module-path" "exn:fail:filesystem:missing-module?" + "exn:fail:filesystem:version" "exn:fail:filesystem:version?" "exn:fail:filesystem?" + "exn:fail:network" "exn:fail:network:errno" "exn:fail:network:errno-errno" + "exn:fail:network:errno?" "exn:fail:network?" "exn:fail:object" "exn:fail:object?" + "exn:fail:out-of-memory" "exn:fail:out-of-memory?" "exn:fail:read" "exn:fail:read-srclocs" + "exn:fail:read:eof" "exn:fail:read:eof?" "exn:fail:read:non-char" "exn:fail:read:non-char?" + "exn:fail:read?" "exn:fail:syntax" "exn:fail:syntax-exprs" "exn:fail:syntax:missing-module" + "exn:fail:syntax:missing-module-path" "exn:fail:syntax:missing-module?" + "exn:fail:syntax:unbound" "exn:fail:syntax:unbound?" "exn:fail:syntax?" "exn:fail:unsupported" + "exn:fail:unsupported?" "exn:fail:user" "exn:fail:user?" "exn:fail?" "exn:misc:match?" + "exn:missing-module-accessor" "exn:missing-module?" "exn:srclocs-accessor" "exn:srclocs?" "exn?" + "exp" "expand" "expand-once" "expand-syntax" "expand-syntax-once" "expand-syntax-to-top-form" + "expand-to-top-form" "expand-user-path" "explode-path" "expt" "false?" "field-names" "fifth" + "file->bytes" "file->bytes-lines" "file->lines" "file->list" "file->string" "file->value" + "file-exists?" "file-name-from-path" "file-or-directory-identity" + "file-or-directory-modify-seconds" "file-or-directory-permissions" "file-or-directory-stat" + "file-or-directory-type" "file-position" "file-position*" "file-size" "file-stream-buffer-mode" + "file-stream-port?" "file-truncate" "filename-extension" "filesystem-change-evt" + "filesystem-change-evt-cancel" "filesystem-change-evt?" "filesystem-root-list" "filter" + "filter-map" "filter-not" "filter-read-input-port" "find-compiled-file-roots" + "find-executable-path" "find-files" "find-library-collection-links" + "find-library-collection-paths" "find-relative-path" "find-system-path" "findf" "first" + "first-or/c" "fixnum?" "flat-contract" "flat-contract-predicate" "flat-contract-property?" + "flat-contract-with-explanation" "flat-contract?" "flat-named-contract" "flatten" + "floating-point-bytes->real" "flonum?" "floor" "flush-output" "fold-files" "foldl" "foldr" + "for-each" "force" "format" "fourth" "fprintf" "free-identifier=?" "free-label-identifier=?" + "free-template-identifier=?" "free-transformer-identifier=?" "fsemaphore-count" + "fsemaphore-post" "fsemaphore-try-wait?" "fsemaphore-wait" "fsemaphore?" "future" "future?" + "futures-enabled?" "gcd" "generate-member-key" "generate-temporaries" "generic-set?" "generic?" + "gensym" "get-output-bytes" "get-output-string" "get-preference" "get/build-late-neg-projection" + "get/build-val-first-projection" "getenv" "global-port-print-handler" "group-by" "guard-evt" + "handle-evt" "handle-evt?" "has-blame?" "has-contract?" "hash" "hash->list" "hash-clear" + "hash-clear!" "hash-copy" "hash-copy-clear" "hash-count" "hash-empty?" "hash-ephemeron?" + "hash-eq?" "hash-equal?" "hash-eqv?" "hash-for-each" "hash-has-key?" "hash-iterate-first" + "hash-iterate-key" "hash-iterate-key+value" "hash-iterate-next" "hash-iterate-pair" + "hash-iterate-value" "hash-keys" "hash-keys-subset?" "hash-map" "hash-placeholder?" "hash-ref" + "hash-ref!" "hash-ref-key" "hash-remove" "hash-remove!" "hash-set" "hash-set!" "hash-set*" + "hash-set*!" "hash-strong?" "hash-update" "hash-update!" "hash-values" "hash-weak?" "hash/c" + "hash?" "hasheq" "hasheqv" "identifier-binding" "identifier-binding-portal-syntax" + "identifier-binding-symbol" "identifier-distinct-binding" "identifier-label-binding" + "identifier-prune-lexical-context" "identifier-prune-to-source-module" + "identifier-remove-from-definition-context" "identifier-template-binding" + "identifier-transformer-binding" "identifier?" "identity" "if/c" "imag-part" "immutable?" + "impersonate-box" "impersonate-channel" "impersonate-continuation-mark-key" "impersonate-hash" + "impersonate-hash-set" "impersonate-procedure" "impersonate-procedure*" "impersonate-prompt-tag" + "impersonate-struct" "impersonate-vector" "impersonate-vector*" "impersonator-contract?" + "impersonator-ephemeron" "impersonator-of?" "impersonator-property-accessor-procedure?" + "impersonator-property?" "impersonator?" "implementation?" "implementation?/c" "in-bytes" + "in-bytes-lines" "in-combinations" "in-cycle" "in-dict" "in-dict-keys" "in-dict-pairs" + "in-dict-values" "in-directory" "in-ephemeron-hash" "in-ephemeron-hash-keys" + "in-ephemeron-hash-pairs" "in-ephemeron-hash-values" "in-hash" "in-hash-keys" "in-hash-pairs" + "in-hash-values" "in-immutable-hash" "in-immutable-hash-keys" "in-immutable-hash-pairs" + "in-immutable-hash-values" "in-immutable-set" "in-inclusive-range" "in-indexed" + "in-input-port-bytes" "in-input-port-chars" "in-lines" "in-list" "in-mlist" "in-mutable-hash" + "in-mutable-hash-keys" "in-mutable-hash-pairs" "in-mutable-hash-values" "in-mutable-set" + "in-naturals" "in-parallel" "in-permutations" "in-port" "in-producer" "in-range" "in-sequences" + "in-set" "in-slice" "in-stream" "in-string" "in-syntax" "in-value" "in-values*-sequence" + "in-values-sequence" "in-vector" "in-weak-hash" "in-weak-hash-keys" "in-weak-hash-pairs" + "in-weak-hash-values" "in-weak-set" "inclusive-range" "index-of" "index-where" "indexes-of" + "indexes-where" "inexact->exact" "inexact-real?" "inexact?" "infinite?" "input-port-append" + "input-port?" "inspector-superior?" "inspector?" "instanceof/c" "integer->char" + "integer->integer-bytes" "integer-bytes->integer" "integer-in" "integer-length" "integer-sqrt" + "integer-sqrt/remainder" "integer?" "interface->method-names" "interface-extension?" + "interface?" "internal-definition-context-add-scopes" + "internal-definition-context-binding-identifiers" "internal-definition-context-introduce" + "internal-definition-context-seal" "internal-definition-context-splice-binding-identifier" + "internal-definition-context?" "is-a?" "is-a?/c" "keyword->string" "keyword-apply" + "keyword-apply/dict" "keyword<?" "keyword?" "keywords-match" "kill-thread" "last" "last-pair" + "lcm" "length" "liberal-define-context?" "link-exists?" "list" "list*" "list*of" "list->bytes" + "list->mutable-set" "list->mutable-seteq" "list->mutable-seteqv" "list->set" "list->seteq" + "list->seteqv" "list->string" "list->vector" "list->weak-set" "list->weak-seteq" + "list->weak-seteqv" "list-contract?" "list-prefix?" "list-ref" "list-set" "list-tail" + "list-update" "list/c" "list?" "listen-port-number?" "listof" "load" "load-extension" + "load-on-demand-enabled" "load-relative" "load-relative-extension" "load/cd" "load/use-compiled" + "local-expand" "local-expand/capture-lifts" "local-transformer-expand" + "local-transformer-expand/capture-lifts" "locale-string-encoding" "log" "log-all-levels" + "log-level-evt" "log-level?" "log-max-level" "log-message" "log-receiver?" "logger-name" + "logger?" "magnitude" "make-arity-at-least" "make-base-empty-namespace" "make-base-namespace" + "make-bytes" "make-channel" "make-chaperone-contract" "make-continuation-mark-key" + "make-continuation-prompt-tag" "make-contract" "make-custodian" "make-custodian-box" + "make-custom-hash" "make-custom-hash-types" "make-custom-set" "make-custom-set-types" + "make-date" "make-date*" "make-derived-parameter" "make-directory" "make-directory*" + "make-do-sequence" "make-empty-namespace" "make-environment-variables" "make-ephemeron" + "make-ephemeron-hash" "make-ephemeron-hasheq" "make-ephemeron-hasheqv" "make-exn" + "make-exn:break" "make-exn:break:hang-up" "make-exn:break:terminate" "make-exn:fail" + "make-exn:fail:contract" "make-exn:fail:contract:arity" "make-exn:fail:contract:blame" + "make-exn:fail:contract:continuation" "make-exn:fail:contract:divide-by-zero" + "make-exn:fail:contract:non-fixnum-result" "make-exn:fail:contract:variable" + "make-exn:fail:filesystem" "make-exn:fail:filesystem:errno" "make-exn:fail:filesystem:exists" + "make-exn:fail:filesystem:missing-module" "make-exn:fail:filesystem:version" + "make-exn:fail:network" "make-exn:fail:network:errno" "make-exn:fail:object" + "make-exn:fail:out-of-memory" "make-exn:fail:read" "make-exn:fail:read:eof" + "make-exn:fail:read:non-char" "make-exn:fail:syntax" "make-exn:fail:syntax:missing-module" + "make-exn:fail:syntax:unbound" "make-exn:fail:unsupported" "make-exn:fail:user" + "make-file-or-directory-link" "make-flat-contract" "make-fsemaphore" "make-generic" + "make-handle-get-preference-locked" "make-hash" "make-hash-placeholder" "make-hasheq" + "make-hasheq-placeholder" "make-hasheqv" "make-hasheqv-placeholder" "make-immutable-custom-hash" + "make-immutable-hash" "make-immutable-hasheq" "make-immutable-hasheqv" + "make-impersonator-property" "make-input-port" "make-input-port/read-to-peek" "make-inspector" + "make-interned-syntax-introducer" "make-keyword-procedure" "make-known-char-range-list" + "make-limited-input-port" "make-list" "make-lock-file-name" "make-log-receiver" "make-logger" + "make-mixin-contract" "make-mutable-custom-set" "make-none/c" "make-object" "make-output-port" + "make-parameter" "make-parent-directory*" "make-phantom-bytes" "make-pipe" + "make-pipe-with-specials" "make-placeholder" "make-plumber" "make-polar" "make-portal-syntax" + "make-prefab-struct" "make-primitive-class" "make-proj-contract" "make-pseudo-random-generator" + "make-reader-graph" "make-readtable" "make-rectangular" "make-rename-transformer" + "make-resolved-module-path" "make-security-guard" "make-semaphore" "make-set!-transformer" + "make-shared-bytes" "make-sibling-inspector" "make-special-comment" "make-srcloc" "make-string" + "make-struct-field-accessor" "make-struct-field-mutator" "make-struct-type" + "make-struct-type-property" "make-syntax-delta-introducer" "make-syntax-introducer" + "make-temporary-directory" "make-temporary-directory*" "make-temporary-file" + "make-temporary-file*" "make-tentative-pretty-print-output-port" "make-thread-cell" + "make-thread-group" "make-vector" "make-weak-box" "make-weak-custom-hash" "make-weak-custom-set" + "make-weak-hash" "make-weak-hasheq" "make-weak-hasheqv" "make-will-executor" "map" + "match-equality-test" "matches-arity-exactly?" "max" "mcar" "mcdr" "mcons" "member" + "member-name-key-hash-code" "member-name-key=?" "member-name-key?" "memf" "memory-order-acquire" + "memory-order-release" "memq" "memv" "merge-input" "method-in-interface?" "min" + "module->exports" "module->imports" "module->indirect-exports" "module->language-info" + "module->namespace" "module->realm" "module-compiled-cross-phase-persistent?" + "module-compiled-exports" "module-compiled-imports" "module-compiled-indirect-exports" + "module-compiled-language-info" "module-compiled-name" "module-compiled-realm" + "module-compiled-submodules" "module-declared?" "module-path-index-join" + "module-path-index-resolve" "module-path-index-split" "module-path-index-submodule" + "module-path-index?" "module-path?" "module-predefined?" "module-provide-protected?" "modulo" + "mpair?" "mutable-set" "mutable-seteq" "mutable-seteqv" "n->th" "nack-guard-evt" + "namespace-anchor->empty-namespace" "namespace-anchor->namespace" "namespace-anchor?" + "namespace-attach-module" "namespace-attach-module-declaration" "namespace-base-phase" + "namespace-call-with-registry-lock" "namespace-mapped-symbols" "namespace-module-identifier" + "namespace-module-registry" "namespace-require" "namespace-require/constant" + "namespace-require/copy" "namespace-require/expansion-time" "namespace-set-variable-value!" + "namespace-symbol->identifier" "namespace-syntax-introduce" "namespace-undefine-variable!" + "namespace-unprotect-module" "namespace-variable-value" "namespace?" "nan?" "natural-number/c" + "natural?" "negate" "negative-integer?" "negative?" "new-∀/c" "new-∃/c" "newline" "ninth" + "non-empty-listof" "non-empty-string?" "none/c" "nonnegative-integer?" "nonpositive-integer?" + "normal-case-path" "normalize-arity" "normalize-path" "normalized-arity?" "not" "not/c" "null?" + "number->string" "number?" "numerator" "object->vector" "object-info" "object-interface" + "object-method-arity-includes?" "object-name" "object-or-false=?" "object=-hash-code" "object=?" + "object?" "odd?" "one-of/c" "open-input-bytes" "open-input-file" "open-input-output-file" + "open-input-string" "open-output-bytes" "open-output-file" "open-output-nowhere" + "open-output-string" "or/c" "order-of-magnitude" "ormap" "output-port?" "pair?" + "parameter-procedure=?" "parameter/c" "parameter?" "parameterization?" "parse-command-line" + "partition" "path->bytes" "path->complete-path" "path->directory-path" "path->string" + "path-add-extension" "path-add-suffix" "path-convention-type" "path-element->bytes" + "path-element->string" "path-element?" "path-for-some-system?" "path-get-extension" + "path-has-extension?" "path-list-string->path-list" "path-only" "path-replace-extension" + "path-replace-suffix" "path-string?" "path<?" "path?" "pathlist-closure" "peek-byte" + "peek-byte-or-special" "peek-bytes" "peek-bytes!" "peek-bytes!-evt" "peek-bytes-avail!" + "peek-bytes-avail!*" "peek-bytes-avail!-evt" "peek-bytes-avail!/enable-break" "peek-bytes-evt" + "peek-char" "peek-char-or-special" "peek-string" "peek-string!" "peek-string!-evt" + "peek-string-evt" "peeking-input-port" "permutations" "phantom-bytes?" "pipe-content-length" + "place-break" "place-channel" "place-channel-get" "place-channel-put" "place-channel-put/get" + "place-channel?" "place-dead-evt" "place-enabled?" "place-kill" "place-location?" + "place-message-allowed?" "place-wait" "place?" "placeholder-get" "placeholder-set!" + "placeholder?" "plumber-add-flush!" "plumber-flush-all" "plumber-flush-handle-remove!" + "plumber-flush-handle?" "plumber?" "poll-guard-evt" "port->bytes" "port->bytes-lines" + "port->lines" "port->list" "port->string" "port-closed-evt" "port-closed?" "port-commit-peeked" + "port-count-lines!" "port-count-lines-enabled" "port-counts-lines?" "port-display-handler" + "port-file-identity" "port-file-unlock" "port-next-location" "port-number?" "port-print-handler" + "port-progress-evt" "port-provides-progress-evts?" "port-read-handler" "port-try-file-lock?" + "port-waiting-peer?" "port-write-handler" "port-writes-atomic?" "port-writes-special?" "port?" + "portal-syntax-content" "portal-syntax?" "positive-integer?" "positive?" + "prefab-key->struct-type" "prefab-key?" "prefab-struct-key" "preferences-lock-file-mode" + "pregexp" "pregexp?" "pretty-display" "pretty-format" "pretty-print" + "pretty-print-.-symbol-without-bars" "pretty-print-abbreviate-read-macros" + "pretty-print-columns" "pretty-print-current-style-table" "pretty-print-depth" + "pretty-print-exact-as-decimal" "pretty-print-extend-style-table" "pretty-print-handler" + "pretty-print-newline" "pretty-print-post-print-hook" "pretty-print-pre-print-hook" + "pretty-print-print-hook" "pretty-print-print-line" "pretty-print-remap-stylable" + "pretty-print-show-inexactness" "pretty-print-size-hook" "pretty-print-style-table?" + "pretty-printing" "pretty-write" "primitive-closure?" "primitive-result-arity" "primitive?" + "print" "print-as-expression" "print-boolean-long-form" "print-box" "print-graph" + "print-hash-table" "print-mpair-curly-braces" "print-pair-curly-braces" + "print-reader-abbreviations" "print-struct" "print-syntax-width" "print-unreadable" + "print-value-columns" "print-vector-length" "printable/c" "printf" "println" "procedure->method" + "procedure-arity" "procedure-arity-includes/c" "procedure-arity-includes?" + "procedure-arity-mask" "procedure-arity?" "procedure-closure-contents-eq?" + "procedure-extract-target" "procedure-impersonator*?" "procedure-keywords" "procedure-realm" + "procedure-reduce-arity" "procedure-reduce-arity-mask" "procedure-reduce-keyword-arity" + "procedure-reduce-keyword-arity-mask" "procedure-rename" "procedure-result-arity" + "procedure-specialize" "procedure-struct-type?" "procedure?" "process" "process*" + "process*/ports" "process/ports" "processor-count" "progress-evt?" "promise-forced?" + "promise-running?" "promise/c" "promise/name?" "promise?" "prop:arrow-contract-get-info" + "prop:arrow-contract?" "prop:orc-contract-get-subcontracts" "prop:orc-contract?" + "prop:recursive-contract-unroll" "prop:recursive-contract?" "proper-subset?" "property/c" + "pseudo-random-generator->vector" "pseudo-random-generator-vector?" "pseudo-random-generator?" + "put-preferences" "putenv" "quotient" "quotient/remainder" "radians->degrees" "raise" + "raise-argument-error" "raise-argument-error*" "raise-arguments-error" "raise-arguments-error*" + "raise-arity-error" "raise-arity-error*" "raise-arity-mask-error" "raise-arity-mask-error*" + "raise-blame-error" "raise-contract-error" "raise-mismatch-error" "raise-not-cons-blame-error" + "raise-range-error" "raise-range-error*" "raise-result-arity-error" "raise-result-arity-error*" + "raise-result-error" "raise-result-error*" "raise-syntax-error" "raise-type-error" + "raise-user-error" "random" "random-seed" "range" "rational?" "rationalize" "read" + "read-accept-bar-quote" "read-accept-box" "read-accept-compiled" "read-accept-dot" + "read-accept-graph" "read-accept-infix-dot" "read-accept-lang" "read-accept-quasiquote" + "read-accept-reader" "read-byte" "read-byte-or-special" "read-bytes" "read-bytes!" + "read-bytes!-evt" "read-bytes-avail!" "read-bytes-avail!*" "read-bytes-avail!-evt" + "read-bytes-avail!/enable-break" "read-bytes-evt" "read-bytes-line" "read-bytes-line-evt" + "read-case-sensitive" "read-cdot" "read-char" "read-char-or-special" "read-curly-brace-as-paren" + "read-curly-brace-with-tag" "read-decimal-as-inexact" "read-eval-print-loop" + "read-installation-configuration-table" "read-language" "read-line" "read-line-evt" + "read-on-demand-source" "read-single-flonum" "read-square-bracket-as-paren" + "read-square-bracket-with-tag" "read-string" "read-string!" "read-string!-evt" "read-string-evt" + "read-syntax" "read-syntax-accept-graph" "read-syntax/recursive" "read/recursive" + "readtable-mapping" "readtable?" "real->decimal-string" "real->double-flonum" + "real->floating-point-bytes" "real->single-flonum" "real-in" "real-part" "real?" + "reencode-input-port" "reencode-output-port" "regexp" "regexp-match" "regexp-match*" + "regexp-match-evt" "regexp-match-exact?" "regexp-match-peek" "regexp-match-peek-immediate" + "regexp-match-peek-positions" "regexp-match-peek-positions*" + "regexp-match-peek-positions-immediate" "regexp-match-peek-positions-immediate/end" + "regexp-match-peek-positions/end" "regexp-match-positions" "regexp-match-positions*" + "regexp-match-positions/end" "regexp-match/end" "regexp-match?" "regexp-max-lookbehind" + "regexp-quote" "regexp-replace" "regexp-replace*" "regexp-replace-quote" "regexp-replaces" + "regexp-split" "regexp-try-match" "regexp?" "relative-path?" "relocate-input-port" + "relocate-output-port" "remainder" "remf" "remf*" "remove" "remove*" "remove-duplicates" "remq" + "remq*" "remv" "remv*" "rename-contract" "rename-file-or-directory" "rename-transformer-target" + "rename-transformer?" "replace-evt" "reroot-path" "resolve-path" "resolved-module-path-name" + "resolved-module-path?" "rest" "reverse" "round" "second" "seconds->date" "security-guard?" + "semaphore-peek-evt" "semaphore-peek-evt?" "semaphore-post" "semaphore-try-wait?" + "semaphore-wait" "semaphore-wait/enable-break" "semaphore?" "sequence->list" "sequence->stream" + "sequence-add-between" "sequence-andmap" "sequence-append" "sequence-count" "sequence-filter" + "sequence-fold" "sequence-for-each" "sequence-generate" "sequence-generate*" "sequence-length" + "sequence-map" "sequence-ormap" "sequence-ref" "sequence-tail" "sequence/c" "sequence?" "set" + "set!-transformer-procedure" "set!-transformer?" "set->list" "set->stream" "set-add" "set-add!" + "set-box!" "set-box*!" "set-clear" "set-clear!" "set-copy" "set-copy-clear" "set-count" + "set-empty?" "set-eq?" "set-equal?" "set-eqv?" "set-first" "set-for-each" "set-implements/c" + "set-implements?" "set-intersect" "set-intersect!" "set-map" "set-mcar!" "set-mcdr!" + "set-member?" "set-mutable?" "set-phantom-bytes!" "set-port-next-location!" "set-remove" + "set-remove!" "set-rest" "set-subtract" "set-subtract!" "set-symmetric-difference" + "set-symmetric-difference!" "set-union" "set-union!" "set-weak?" "set/c" "set=?" "set?" "seteq" + "seteqv" "seventh" "sgn" "sha1-bytes" "sha224-bytes" "sha256-bytes" "shared-bytes" + "shell-execute" "shrink-path-wrt" "shuffle" "simple-form-path" "simplify-path" "sin" + "single-flonum-available?" "single-flonum?" "sinh" "sixth" "skip-projection-wrapper?" "sleep" + "some-system-path->string" "sort" "special-comment-value" "special-comment?" + "special-filter-input-port" "split-at" "split-at-right" "split-common-prefix" "split-path" + "splitf-at" "splitf-at-right" "sqr" "sqrt" "srcloc" "srcloc->string" "srcloc-column" + "srcloc-line" "srcloc-position" "srcloc-source" "srcloc-span" "srcloc?" "stop-after" + "stop-before" "stream->list" "stream-add-between" "stream-andmap" "stream-append" "stream-count" + "stream-empty?" "stream-filter" "stream-first" "stream-fold" "stream-for-each" "stream-force" + "stream-length" "stream-map" "stream-ormap" "stream-ref" "stream-rest" "stream-tail" + "stream-take" "stream/c" "stream?" "string" "string->bytes/latin-1" "string->bytes/locale" + "string->bytes/utf-8" "string->immutable-string" "string->keyword" "string->list" + "string->number" "string->path" "string->path-element" "string->some-system-path" + "string->symbol" "string->uninterned-symbol" "string->unreadable-symbol" "string-append" + "string-append*" "string-append-immutable" "string-ci<=?" "string-ci<?" "string-ci=?" + "string-ci>=?" "string-ci>?" "string-contains?" "string-copy" "string-copy!" "string-downcase" + "string-environment-variable-name?" "string-fill!" "string-foldcase" "string-join" + "string-len/c" "string-length" "string-locale-ci<?" "string-locale-ci=?" "string-locale-ci>?" + "string-locale-downcase" "string-locale-upcase" "string-locale<?" "string-locale=?" + "string-locale>?" "string-no-nuls?" "string-normalize-nfc" "string-normalize-nfd" + "string-normalize-nfkc" "string-normalize-nfkd" "string-normalize-spaces" "string-port?" + "string-prefix?" "string-ref" "string-replace" "string-set!" "string-split" "string-suffix?" + "string-titlecase" "string-trim" "string-upcase" "string-utf-8-length" "string<=?" "string<?" + "string=?" "string>=?" "string>?" "string?" "struct->vector" "struct-accessor-procedure?" + "struct-constructor-procedure?" "struct-info" "struct-mutator-procedure?" + "struct-predicate-procedure?" "struct-type-authentic?" "struct-type-info" + "struct-type-make-constructor" "struct-type-make-predicate" + "struct-type-property-accessor-procedure?" "struct-type-property-predicate-procedure?" + "struct-type-property/c" "struct-type-property?" "struct-type-sealed?" "struct-type?" "struct?" + "sub1" "subbytes" "subclass?" "subclass?/c" "subprocess" "subprocess-group-enabled" + "subprocess-kill" "subprocess-pid" "subprocess-status" "subprocess-wait" "subprocess?" "subset?" + "substring" "suggest/c" "symbol->string" "symbol-interned?" "symbol-unreadable?" "symbol<?" + "symbol=?" "symbol?" "symbols" "sync" "sync/enable-break" "sync/timeout" + "sync/timeout/enable-break" "syntax->datum" "syntax->list" "syntax-arm" "syntax-binding-set" + "syntax-binding-set->syntax" "syntax-binding-set-extend" "syntax-binding-set?" "syntax-column" + "syntax-debug-info" "syntax-deserialize" "syntax-disarm" "syntax-e" "syntax-line" + "syntax-local-apply-transformer" "syntax-local-bind-syntaxes" "syntax-local-certifier" + "syntax-local-context" "syntax-local-expand-expression" "syntax-local-get-shadower" + "syntax-local-identifier-as-binding" "syntax-local-introduce" "syntax-local-lift-context" + "syntax-local-lift-expression" "syntax-local-lift-module" + "syntax-local-lift-module-end-declaration" "syntax-local-lift-provide" + "syntax-local-lift-require" "syntax-local-lift-values-expression" + "syntax-local-make-definition-context" "syntax-local-make-delta-introducer" + "syntax-local-module-defined-identifiers" "syntax-local-module-exports" + "syntax-local-module-interned-scope-symbols" "syntax-local-module-required-identifiers" + "syntax-local-name" "syntax-local-phase-level" "syntax-local-submodules" + "syntax-local-transforming-module-provides?" "syntax-local-value" "syntax-local-value/immediate" + "syntax-original?" "syntax-position" "syntax-property" "syntax-property-preserved?" + "syntax-property-remove" "syntax-property-symbol-keys" "syntax-protect" "syntax-rearm" + "syntax-recertify" "syntax-serialize" "syntax-shift-phase-level" "syntax-source" + "syntax-source-module" "syntax-span" "syntax-taint" "syntax-tainted?" "syntax-track-origin" + "syntax-transforming-module-expression?" "syntax-transforming-with-lifts?" + "syntax-transforming?" "syntax/c" "syntax?" "system" "system*" "system*/exit-code" + "system-big-endian?" "system-idle-evt" "system-language+country" "system-library-subpath" + "system-path-convention-type" "system-type" "system/exit-code" "tail-marks-match?" "take" + "take-common-prefix" "take-right" "takef" "takef-right" "tan" "tanh" "tcp-abandon-port" + "tcp-accept" "tcp-accept-evt" "tcp-accept-ready?" "tcp-accept/enable-break" "tcp-addresses" + "tcp-close" "tcp-connect" "tcp-connect/enable-break" "tcp-listen" "tcp-listener?" "tcp-port?" + "tentative-pretty-print-port-cancel" "tentative-pretty-print-port-transfer" "tenth" + "terminal-port?" "third" "thread" "thread-cell-ref" "thread-cell-set!" "thread-cell-values?" + "thread-cell?" "thread-dead-evt" "thread-dead?" "thread-group?" "thread-receive" + "thread-receive-evt" "thread-resume" "thread-resume-evt" "thread-rewind-receive" + "thread-running?" "thread-send" "thread-suspend" "thread-suspend-evt" "thread-try-receive" + "thread-wait" "thread/suspend-to-kill" "thread?" "time-apply" "touch" "transplant-input-port" + "transplant-output-port" "truncate" "udp-addresses" "udp-bind!" "udp-bound?" "udp-close" + "udp-connect!" "udp-connected?" "udp-multicast-interface" "udp-multicast-join-group!" + "udp-multicast-leave-group!" "udp-multicast-loopback?" "udp-multicast-set-interface!" + "udp-multicast-set-loopback!" "udp-multicast-set-ttl!" "udp-multicast-ttl" "udp-open-socket" + "udp-receive!" "udp-receive!*" "udp-receive!-evt" "udp-receive!/enable-break" + "udp-receive-ready-evt" "udp-send" "udp-send*" "udp-send-evt" "udp-send-ready-evt" "udp-send-to" + "udp-send-to*" "udp-send-to-evt" "udp-send-to/enable-break" "udp-send/enable-break" + "udp-set-receive-buffer-size!" "udp-set-ttl!" "udp-ttl" "udp?" "unbox" "unbox*" + "uncaught-exception-handler" "unit?" "unquoted-printing-string" "unquoted-printing-string-value" + "unquoted-printing-string?" "unsupplied-arg?" "use-collection-link-paths" + "use-compiled-file-check" "use-compiled-file-paths" "use-user-specific-search-paths" + "value-blame" "value-contract" "values" "variable-reference->empty-namespace" + "variable-reference->module-base-phase" "variable-reference->module-declaration-inspector" + "variable-reference->module-path-index" "variable-reference->module-source" + "variable-reference->namespace" "variable-reference->phase" + "variable-reference->resolved-module-path" "variable-reference-constant?" + "variable-reference-from-unsafe?" "variable-reference?" "vector" "vector*-length" "vector*-ref" + "vector*-set!" "vector->immutable-vector" "vector->list" "vector->pseudo-random-generator" + "vector->pseudo-random-generator!" "vector->values" "vector-append" "vector-argmax" + "vector-argmin" "vector-cas!" "vector-copy" "vector-copy!" "vector-count" "vector-drop" + "vector-drop-right" "vector-empty?" "vector-fill!" "vector-filter" "vector-filter-not" + "vector-immutable" "vector-immutable/c" "vector-immutableof" "vector-length" "vector-map" + "vector-map!" "vector-member" "vector-memq" "vector-memv" "vector-ref" "vector-set!" + "vector-set*!" "vector-set-performance-stats!" "vector-sort" "vector-sort!" "vector-split-at" + "vector-split-at-right" "vector-take" "vector-take-right" "vector/c" "vector?" "vectorof" + "version" "void" "void?" "weak-box-value" "weak-box?" "weak-set" "weak-seteq" "weak-seteqv" + "will-execute" "will-executor?" "will-register" "will-try-execute" "with-input-from-bytes" + "with-input-from-file" "with-input-from-string" "with-output-to-bytes" "with-output-to-file" + "with-output-to-string" "would-be-future" "wrap-evt" "write" "write-byte" "write-bytes" + "write-bytes-avail" "write-bytes-avail*" "write-bytes-avail-evt" + "write-bytes-avail/enable-break" "write-char" "write-special" "write-special-avail*" + "write-special-evt" "write-string" "write-to-file" "writeln" "xor" "zero?" "~.a" "~.s" "~.v" + "~a" "~e" "~r" "~s" "~v")) + +; operators ;; +((symbol) @operator + (#any-of? @operator "+" "-" "*" "/" "=" "<=" ">=" "<" ">")) + +; builtin variables ;; +((symbol) @variable.builtin + (#any-of? @variable.builtin + "always-evt" "block-device-type-bits" "character-device-type-bits" "check-tail-contract" + "contract-continuation-mark-key" "contract-random-generate-fail" "directory-type-bits" "empty" + "empty-sequence" "empty-stream" "eof" "equal<%>" "error-message-adjuster-key" + "externalizable<%>" "failure-result/c" "false" "false/c" "fifo-type-bits" "file-type-bits" + "for-clause-syntax-protect" "group-execute-bit" "group-permission-bits" "group-read-bit" + "group-write-bit" "impersonator-prop:application-mark" "impersonator-prop:blame" + "impersonator-prop:contracted" "legacy-match-expander?" "match-...-nesting" "match-expander?" + "mixin-contract" "never-evt" "null" "object%" "other-execute-bit" "other-permission-bits" + "other-read-bit" "other-write-bit" "pi" "pi.f" "predicate/c" "printable<%>" "prop:arity-string" + "prop:arrow-contract" "prop:authentic" "prop:blame" "prop:chaperone-contract" + "prop:checked-procedure" "prop:contract" "prop:contracted" "prop:custom-print-quotable" + "prop:custom-write" "prop:dict" "prop:equal+hash" "prop:evt" "prop:exn:missing-module" + "prop:exn:srclocs" "prop:expansion-contexts" "prop:flat-contract" "prop:impersonator-of" + "prop:input-port" "prop:legacy-match-expander" "prop:liberal-define-context" + "prop:match-expander" "prop:object-name" "prop:orc-contract" "prop:output-port" + "prop:place-location" "prop:procedure" "prop:recursive-contract" "prop:rename-transformer" + "prop:sealed" "prop:sequence" "prop:set!-transformer" "prop:stream" "regular-file-type-bits" + "set-group-id-bit" "set-user-id-bit" "socket-type-bits" "sticky-bit" "struct:arity-at-least" + "struct:arrow-contract-info" "struct:date" "struct:date*" "struct:exn" "struct:exn:break" + "struct:exn:break:hang-up" "struct:exn:break:terminate" "struct:exn:fail" + "struct:exn:fail:contract" "struct:exn:fail:contract:arity" "struct:exn:fail:contract:blame" + "struct:exn:fail:contract:continuation" "struct:exn:fail:contract:divide-by-zero" + "struct:exn:fail:contract:non-fixnum-result" "struct:exn:fail:contract:variable" + "struct:exn:fail:filesystem" "struct:exn:fail:filesystem:errno" + "struct:exn:fail:filesystem:exists" "struct:exn:fail:filesystem:missing-module" + "struct:exn:fail:filesystem:version" "struct:exn:fail:network" "struct:exn:fail:network:errno" + "struct:exn:fail:object" "struct:exn:fail:out-of-memory" "struct:exn:fail:read" + "struct:exn:fail:read:eof" "struct:exn:fail:read:non-char" "struct:exn:fail:syntax" + "struct:exn:fail:syntax:missing-module" "struct:exn:fail:syntax:unbound" + "struct:exn:fail:unsupported" "struct:exn:fail:user" "struct:srcloc" "symbolic-link-type-bits" + "syntax-local-match-introduce" "syntax-pattern-variable?" "the-unsupplied-arg" "true" + "unspecified-dom" "user-execute-bit" "user-permission-bits" "user-read-bit" "user-write-bit" + "writable<%>")) + +(dot) @variable.builtin + +;------------------------------------------------------------------;; +; Special cases ;; +;------------------------------------------------------------------;; +(list + "[" + (symbol) @variable + "]") + +(list + . + (symbol) @_p + . + (list + (symbol) @variable) + (#any-of? @_p + "lambda" "λ" "define-values" "define-syntaxes" "define-values-for-export" + "define-values-for-syntax")) + +;------------------------------------------------------------------;; +; Solve conflicts ;; +;------------------------------------------------------------------;; +; See `:h treesitter`, and search `priority` +(list + . + (symbol) @keyword.import + (#eq? @keyword.import "require") + (#set! priority 101)) + +(quote + . + (symbol) + (#set! priority 105)) @string.special.symbol + +((sexp_comment) @comment + (#set! priority 110)) diff --git a/runtime/queries/racket/injections.scm b/runtime/queries/racket/injections.scm new file mode 100644 index 000000000..dc8982053 --- /dev/null +++ b/runtime/queries/racket/injections.scm @@ -0,0 +1,5 @@ +([ + (comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/ralph/highlights.scm b/runtime/queries/ralph/highlights.scm new file mode 100644 index 000000000..e56ffa5a2 --- /dev/null +++ b/runtime/queries/ralph/highlights.scm @@ -0,0 +1,137 @@ +(type_identifier) @type + +(identifier) @variable + +[ + (primitive_type) + (alph_token_id) +] @type.builtin + +(var_declaration) @variable + +(struct_field + (identifier) @variable.member) + +(arg_def + (identifier) @variable.parameter) + +(event_field + (identifier) @variable.parameter) + +(struct_constructor_field + (identifier) @variable.parameter) + +[ + (hex_num) + (integer) + (typed_num) +] @number + +[ + (bool) + (bytes) + (address) +] @constant.builtin + +(func_id + [ + (identifier) + "!" + ] @function) + +(annotation + [ + "@" + (identifier) + ] @attribute) + +(map_def + (identifier) @variable.parameter) + +"fn" @keyword.function + +[ + "Contract" + "TxScript" + "Interface" + "AssetScript" + "struct" + "enum" + "event" + "mapping" +] @keyword.type + +[ + "pub" + "Abstract" + (mutable) +] @keyword.modifier + +[ + "while" + "for" +] @keyword.repeat + +"return" @keyword.return + +[ + "if" + "else" +] @keyword.conditional + +[ + "const" + "let" + "emit" + "extends" + "embeds" + "implements" +] @keyword + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "." + "," + ":" + ";" +] @punctuation.delimiter + +[ + "=" + "->" + (op_byte_vec_add) + (op_add) + (op_sub) + (op_mul) + (op_exp) + (op_mod_exp) + (op_div) + (op_mod) + (op_mod_add) + (op_mod_sub) + (op_mod_mul) + (op_shl) + (op_shr) + (op_bit_and) + (op_xor) + (op_bit_or) + (op_eq) + (op_ne) + (op_lt) + (op_le) + (op_gt) + (op_ge) + (op_and) + (op_or) + (op_not) +] @operator + +(line_comment) @comment @spell diff --git a/runtime/queries/ralph/injections.scm b/runtime/queries/ralph/injections.scm new file mode 100644 index 000000000..36849c873 --- /dev/null +++ b/runtime/queries/ralph/injections.scm @@ -0,0 +1,2 @@ +((line_comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/rasi/folds.scm b/runtime/queries/rasi/folds.scm new file mode 100644 index 000000000..2fd6c9fa7 --- /dev/null +++ b/runtime/queries/rasi/folds.scm @@ -0,0 +1,5 @@ +[ + (rule_set) + (list_value) + (distance_calc) +] @fold diff --git a/runtime/queries/rasi/highlights.scm b/runtime/queries/rasi/highlights.scm new file mode 100644 index 000000000..d095cef63 --- /dev/null +++ b/runtime/queries/rasi/highlights.scm @@ -0,0 +1,138 @@ +(comment) @comment @spell + +"@media" @keyword + +"@import" @keyword.import + +"@theme" @keyword.import + +(string_value) @string + +[ + (integer_value) + (float_value) + "0" +] @number + +(boolean_value) @boolean + +[ + (feature_name) + (url_image_scale) + (direction) + (text_style_value) + (line_style_value) + (position_value) + (orientation_value) + (cursor_value) + "inherit" +] @keyword + +(url_image + "url" @function.builtin) + +(gradient_image + "linear-gradient" @function.builtin) + +(distance_calc + "calc" @function.builtin) + +(rgb_color + [ + "rgb" + "rgba" + ] @function.builtin) + +(hsl_color + [ + "hsl" + "hsla" + ] @function.builtin) + +(hwb_color + [ + "hwb" + "hwba" + ] @function.builtin) + +(cmyk_color + "cmyk" @function.builtin) + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +(distance_op) @operator + +[ + ";" + "," + ":" + "." +] @punctuation.delimiter + +[ + (angle_unit) + (integer_distance_unit) + (float_distance_unit) +] @string + +(percentage) @number + +(percentage + "%" @string) + +(global_selector) @character.special + +(id_selector) @constant + +(id_selector_view + [ + "normal" + "selected" + "alternate" + ] @attribute) + +(id_selector_state + [ + "normal" + "urgent" + "active" + ] @keyword.modifier) + +(hex_color) @number + +(hex_color + "#" @punctuation.special) + +(named_color + (identifier) @string.special) + +(named_color + "/" @operator) + +(reference_value + "@" @punctuation.special + (identifier) @variable) + +(reference_value + "var" @function.builtin + (identifier) @variable) + +(list_value + (identifier) @variable) + +(environ_value + "$" @punctuation.special + (identifier) @variable) + +(environ_value + "env" @function.builtin + (identifier) @variable) + +(property_name) @property diff --git a/runtime/queries/rasi/indents.scm b/runtime/queries/rasi/indents.scm new file mode 100644 index 000000000..849d8aeac --- /dev/null +++ b/runtime/queries/rasi/indents.scm @@ -0,0 +1,6 @@ +(rule_set) @indent.begin + +(block + "}" @indent.branch) + +(comment) @indent.ignore diff --git a/runtime/queries/rasi/injections.scm b/runtime/queries/rasi/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/rasi/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/rasi/locals.scm b/runtime/queries/rasi/locals.scm new file mode 100644 index 000000000..9210de6ea --- /dev/null +++ b/runtime/queries/rasi/locals.scm @@ -0,0 +1,10 @@ +(rule_set + (selectors + (id_selector))) @local.scope + +(block + (declaration + (property_name) @local.definition.var)) + +(reference_value + name: (identifier) @local.reference) diff --git a/runtime/queries/razor/folds.scm b/runtime/queries/razor/folds.scm new file mode 100644 index 000000000..f026cb8ec --- /dev/null +++ b/runtime/queries/razor/folds.scm @@ -0,0 +1,14 @@ +[ + (razor_if) + (razor_switch) + (razor_for) + (razor_foreach) + (razor_while) + (razor_do_while) + (razor_try) + (razor_catch) + (razor_finally) + (razor_compound_using) + (razor_section) + (razor_block) +] @fold diff --git a/runtime/queries/razor/highlights.scm b/runtime/queries/razor/highlights.scm new file mode 100644 index 000000000..2050bde9c --- /dev/null +++ b/runtime/queries/razor/highlights.scm @@ -0,0 +1,58 @@ +; inherits: c_sharp + +[ + (razor_comment) + (html_comment) +] @comment @spell + +[ + "at_page" + "at_using" + "at_model" + "at_rendermode" + "at_inject" + "at_implements" + "at_layout" + "at_inherits" + "at_attribute" + "at_typeparam" + "at_namespace" + "at_preservewhitespace" + "at_block" + "at_at_escape" + "at_colon_transition" +] @constant.macro + +[ + "at_lock" + "at_section" +] @keyword + +[ + "at_if" + "at_switch" +] @keyword.conditional + +[ + "at_for" + "at_foreach" + "at_while" + "at_do" +] @keyword.repeat + +[ + "at_try" + "catch" + "finally" +] @keyword.exception + +[ + "at_implicit" + "at_explicit" +] @variable + +"at_await" @keyword.coroutine + +(razor_rendermode) @property + +(razor_attribute_name) @function diff --git a/runtime/queries/razor/injections.scm b/runtime/queries/razor/injections.scm new file mode 100644 index 000000000..f73839bd6 --- /dev/null +++ b/runtime/queries/razor/injections.scm @@ -0,0 +1,11 @@ +; inherits: c_sharp + +([ + (html_comment) + (razor_comment) +] @injection.content + (#set! injection.language "comment")) + +((element) @injection.content + (#set! injection.language "html") + (#set! injection.combined)) diff --git a/runtime/queries/rbs/folds.scm b/runtime/queries/rbs/folds.scm new file mode 100644 index 000000000..ff8e7c588 --- /dev/null +++ b/runtime/queries/rbs/folds.scm @@ -0,0 +1,5 @@ +[ + (class_decl) + (module_decl) + (interface_decl) +] @fold diff --git a/runtime/queries/rbs/highlights.scm b/runtime/queries/rbs/highlights.scm new file mode 100644 index 000000000..9de9c427d --- /dev/null +++ b/runtime/queries/rbs/highlights.scm @@ -0,0 +1,162 @@ +; Use directive +(use_clause + [ + (type_name) + (simple_type_name) + ] @type) + +; Builtin constants and Keywords +[ + "true" + "false" +] @boolean + +"nil" @constant.builtin + +[ + "use" + "as" + "module" + "def" + "attr_reader" + "attr_writer" + "attr_accessor" + "end" + "alias" +] @keyword + +[ + "interface" + "type" + "class" +] @keyword.type + +(class_decl + "end" @keyword.type) + +(interface_decl + "end" @keyword.type) + +"def" @keyword.function + +; Members of declaration +[ + "include" + "extend" + "prepend" +] @function.method + +(visibility) @keyword.modifier + +(comment) @comment @spell + +(method_member + (method_name + [ + (identifier) + (identifier_suffix) + (constant) + (constant_suffix) + (operator) + (setter) + (constant_setter) + ] @function.method)) + +(attribute_member + (method_name + [ + (identifier) + (identifier_suffix) + (constant) + (constant_suffix) + (operator) + (setter) + (constant_setter) + ] @function.method)) + +[ + (ivar_name) + (cvar_name) +] @variable.member + +(alias_member + (method_name) @function) + +(class_name + (constant) @type) + +(module_name + (constant) @type) + +(interface_name + (interface) @type) + +(alias_name + (identifier) @type) + +(type_variable) @constant + +(namespace + (constant) @module) + +(builtin_type) @type.builtin + +(const_name + (constant) @constant) + +(global_name) @variable + +; Standard Arguments +(parameter + (var_name) @variable.parameter) + +; Keyword Arguments +(keyword) @variable.parameter + +; Self +(self) @variable.builtin + +; Literal +(type + (symbol_literal) @string.special.symbol) + +(type + (string_literal + (escape_sequence) @string.escape)) + +(type + (string_literal) @string) + +(type + (integer_literal) @number) + +(type + (record_type + key: (record_key) @string.special.symbol)) + +; Operators +[ + "=" + "->" + "<" + "**" + "*" + "&" + "|" + "^" +] @operator + +; Punctuation +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "," + "." +] @punctuation.delimiter diff --git a/runtime/queries/rbs/indents.scm b/runtime/queries/rbs/indents.scm new file mode 100644 index 000000000..f6da5b10b --- /dev/null +++ b/runtime/queries/rbs/indents.scm @@ -0,0 +1,24 @@ +[ + (class_decl) + (module_decl) + (interface_decl) + (parameters) + (tuple_type) + (record_type) +] @indent.begin + +[ + "end" + ")" + "]" + "}" +] @indent.end + +[ + "end" + ")" + "}" + "]" +] @indent.branch + +(comment) @indent.auto diff --git a/runtime/queries/rbs/injections.scm b/runtime/queries/rbs/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/rbs/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/re2c/folds.scm b/runtime/queries/re2c/folds.scm new file mode 100644 index 000000000..b4cf5f24e --- /dev/null +++ b/runtime/queries/re2c/folds.scm @@ -0,0 +1,4 @@ +[ + (body) + (action) +] @fold diff --git a/runtime/queries/re2c/highlights.scm b/runtime/queries/re2c/highlights.scm new file mode 100644 index 000000000..c89c30745 --- /dev/null +++ b/runtime/queries/re2c/highlights.scm @@ -0,0 +1,183 @@ +; Namespaces +[ + "re2c" + "re2c" + "local" + "rules" +] @module + +; Includes +[ + "!use" + "!include" +] @keyword.import + +; Keywords +[ + "flags" + "define" + "cond" + "label" + "variable" + "yych" + "state" + "yybm" + "cgoto" + "api" + "tags" + "indent" + "yyfill" + "eof" + "sentinel" + "condprefix" + "condenumprefix" + "startlabel" + "posix-captures" + "max" + "maxnmatch" + "mtags" + "stags" + "header" + "getstate" +] @keyword + +[ + "*" + "+" + "?" +] @keyword.repeat + +; Constants +[ + "ignore" + "substitute" + "fail" + "default" + "custom" + "match-empty" + "match-none" + "error" + "functions" + "free-form" + "format" + "separator" +] @constant.builtin + +(linedir) @constant.macro + +; Operators +[ + "=" + "=>" + ":=>" + "/" + "|" + "\\" + "->" + "^" +] @operator + +[ + "." + (default) + (end_of_input) +] @constant.macro + +(field_expression + "." @operator) + +(condition + (any) @constant.macro) + +; Names +(name) @type + +(block_name) @constant + +(label) @label + +(option_name) @constant.builtin + +((option_name) @constant.macro + (#match? @constant.macro "^YY")) + +(field_expression + argument: (identifier) @variable) + +(field_identifier) @property + +; Literals +(regex) @string.regexp + +[ + (dstring) ; case sensitive + (sstring) ; case insensitive +] @string + +[ + (quote) + (ctrl_code) + (code_unit) +] @string.escape + +(number) @number + +[ + "on" + "off" +] @boolean + +[ + (stag) + (mtag) +] @property + +; Configurations +(define + option: (option_name) @_yy + value: (dstring) @type + (#eq? @_yy "YYCTYPE") + (#offset! @type 0 1 0 -1)) + +(set_header + value: (dstring) @string.special) + +(host_lang) @none + +; Punctuation +[ + ":" + ";" + "," + "-" +] @punctuation.delimiter + +[ + "{" + "}" + "[" + "]" + "(" + ")" + "<" + ">" +] @punctuation.bracket + +(repetition + (limits + [ + "{" + "}" + ] @punctuation.bracket)) + +[ + "!" + "@" + "#" +] @punctuation.special + +; Comments and error +[ + (comment) + (ignore_block) +] @comment @spell diff --git a/runtime/queries/re2c/indents.scm b/runtime/queries/re2c/indents.scm new file mode 100644 index 000000000..31ccf2a0f --- /dev/null +++ b/runtime/queries/re2c/indents.scm @@ -0,0 +1,11 @@ +[ + (re2c) + (action) +] @indent.begin + +"}" @indent.branch @indent.end + +[ + (comment) + (linedir) +] @indent.ignore diff --git a/runtime/queries/re2c/injections.scm b/runtime/queries/re2c/injections.scm new file mode 100644 index 000000000..f0cb1a989 --- /dev/null +++ b/runtime/queries/re2c/injections.scm @@ -0,0 +1,13 @@ +((host_lang) @injection.content + (#set! injection.parent)) + +((define + option: (option_name) @_yy + value: (dstring) @injection.content) + (#any-of? @_yy + "YYPEEK" "YYSKIP" "YYBACKUP" "YYBACKUPCTX" "YYRESTORE" "YYRESTORECTX" "YYFILL" "YYSHIFT") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.parent)) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/re2c/locals.scm b/runtime/queries/re2c/locals.scm new file mode 100644 index 000000000..eea1ede89 --- /dev/null +++ b/runtime/queries/re2c/locals.scm @@ -0,0 +1 @@ +(body) @local.scope diff --git a/runtime/queries/readline/folds.scm b/runtime/queries/readline/folds.scm new file mode 100644 index 000000000..57c9bc7da --- /dev/null +++ b/runtime/queries/readline/folds.scm @@ -0,0 +1 @@ +(conditional_construct) @fold diff --git a/runtime/queries/readline/highlights.scm b/runtime/queries/readline/highlights.scm new file mode 100644 index 000000000..570e55b3d --- /dev/null +++ b/runtime/queries/readline/highlights.scm @@ -0,0 +1,69 @@ +(comment) @comment @spell + +"set" @keyword + +[ + "$if" + "$else" + "$endif" +] @keyword.conditional + +"$include" @keyword.import + +[ + "=" + "==" + "!=" + ">=" + "<=" + ">" + "<" +] @operator + +[ + ":" + "-" +] @punctuation.delimiter + +[ + (application_name) + (keyname) + (keyseq) + (macro) + (string_value) + (term_name) +] @string + +(file_path) @string.special.path + +(escape_sequence) @string.escape + +(symbolic_character_name) @character.special + +(key_literal) @character + +(function_name) @function + +[ + (bell_variable) + (bool_variable) + (edit_mode_variable) + (keymap_variable) + (number_variable) + (string_variable) +] @variable.builtin + +[ + (bell_value) + (edit_mode_value) + (keymap_value) + "version" + "term" + "mode" +] @constant.builtin + +(number_value) @number + +(version_number) @number.float + +(bool_value) @boolean diff --git a/runtime/queries/readline/indents.scm b/runtime/queries/readline/indents.scm new file mode 100644 index 000000000..d7dc67421 --- /dev/null +++ b/runtime/queries/readline/indents.scm @@ -0,0 +1,11 @@ +(conditional_construct) @indent.begin + +(ERROR + "$if") @indent.begin + +[ + "$else" + "$endif" +] @indent.branch + +"$endif" @indent.end diff --git a/runtime/queries/readline/injections.scm b/runtime/queries/readline/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/readline/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/regex/highlights.scm b/runtime/queries/regex/highlights.scm new file mode 100644 index 000000000..350d1d0f3 --- /dev/null +++ b/runtime/queries/regex/highlights.scm @@ -0,0 +1,53 @@ +; Forked from tree-sitter-regex +; The MIT License (MIT) Copyright (c) 2014 Max Brunsfeld +[ + "(" + ")" + "(?" + "(?:" + "(?<" + "<" + ">" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(group_name) @property + +; These are escaped special characters that lost their special meaning +; -> no special highlighting +(identity_escape) @string.regexp + +(class_character) @constant + +(decimal_digits) @number + +[ + (control_letter_escape) + (character_class_escape) + (control_escape) + (boundary_assertion) + (non_boundary_assertion) +] @string.escape + +[ + "*" + "+" + "?" + "|" + "=" + "!" + "-" + "\\k" + (lazy) +] @operator + +[ + (start_assertion) + (end_assertion) + "," +] @punctuation.delimiter + +(any_character) @variable.builtin diff --git a/runtime/queries/rego/highlights.scm b/runtime/queries/rego/highlights.scm new file mode 100644 index 000000000..3cc32949d --- /dev/null +++ b/runtime/queries/rego/highlights.scm @@ -0,0 +1,84 @@ +; highlights.scm +[ + (import) + (package) +] @keyword.import + +[ + (with) + (as) + (every) + (some) + (in) + (not) + (if) + (contains) + (else) + (default) + "null" +] @keyword + +[ + "true" + "false" +] @boolean + +[ + (assignment_operator) + (bool_operator) + (arith_operator) + (bin_operator) +] @operator + +[ + (string) + (raw_string) +] @string + +(term + (ref + (var))) @variable + +(comment) @comment @spell + +(number) @number + +(expr_call + func_name: (fn_name + (var) @function .)) + +(expr_call + func_arguments: (fn_args + (expr) @variable.parameter)) + +(rule_args + (term) @variable.parameter) + +[ + (open_paren) + (close_paren) + (open_bracket) + (close_bracket) + (open_curly) + (close_curly) +] @punctuation.bracket + +(rule + (rule_head + (var) @function.method)) + +(rule + (rule_head + (term + (ref + (var) @module))) + (rule_body + (query + (literal + (expr + (expr_infix + (expr + (term + (ref + (var)) @_output)))))) + (#eq? @_output @module))) diff --git a/runtime/queries/rego/injections.scm b/runtime/queries/rego/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/rego/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/requirements/highlights.scm b/runtime/queries/requirements/highlights.scm new file mode 100644 index 000000000..a04922a26 --- /dev/null +++ b/runtime/queries/requirements/highlights.scm @@ -0,0 +1,52 @@ +; packages +(package) @variable + +(extras + (package) @variable.parameter) + +(path) @string.special.path + +(url) @string.special.url + +; versions +(version_cmp) @operator + +(version) @number + +; markers +(marker_var) @attribute + +(marker_op) @keyword.operator + +; options +(option) @function + +"=" @operator + +; punctuation +[ + "[" + "]" + "(" + ")" +] @punctuation.bracket + +[ + "," + ";" + "@" +] @punctuation.delimiter + +[ + "${" + "}" +] @punctuation.special + +; misc +(env_var) @constant + +(quoted_string) @string + +(linebreak) @character.special + +(comment) @comment @spell diff --git a/runtime/queries/requirements/injections.scm b/runtime/queries/requirements/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/requirements/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/rescript/folds.scm b/runtime/queries/rescript/folds.scm new file mode 100644 index 000000000..4e658a57c --- /dev/null +++ b/runtime/queries/rescript/folds.scm @@ -0,0 +1,12 @@ +[ + (block) + (function) + (module_declaration) + (type_declaration) + (external_declaration) + (call_expression) + (switch_expression) + (parenthesized_expression) + (record) + (include_statement)+ +] @fold diff --git a/runtime/queries/rescript/highlights.scm b/runtime/queries/rescript/highlights.scm new file mode 100644 index 000000000..e7cba9be8 --- /dev/null +++ b/runtime/queries/rescript/highlights.scm @@ -0,0 +1,335 @@ +(comment) @comment @spell + +; Identifiers +;------------ +; Escaped identifiers like \"+." +((value_identifier) @constant.macro + (#lua-match? @constant.macro "^%.*$")) + +(value_identifier) @variable + +[ + (type_identifier) + (unit_type) + (list) + (list_pattern) +] @type + +((type_identifier) @type.builtin + (#any-of? @type.builtin "int" "char" "string" "float" "bool" "unit")) + +[ + (variant_identifier) + (polyvar_identifier) +] @constructor + +(record_type_field + (property_identifier) @property) + +(record_field + (property_identifier) @property) + +(object + (field + (property_identifier) @property)) + +(object_type + (field + (property_identifier) @property)) + +(module_identifier) @module + +(member_expression + (property_identifier) @variable.member) + +(value_identifier_path + (module_identifier) + (value_identifier) @variable) + +(record_pattern + (value_identifier_path + (value_identifier) @variable.member)) + +(record_pattern + (value_identifier) @variable) + +(labeled_argument + label: (value_identifier) @variable.parameter) + +; Parameters +;---------------- +(list_pattern + (value_identifier) @variable.parameter) + +(spread_pattern + (value_identifier) @variable.parameter) + +; String literals +;---------------- +[ + (string) + (template_string) +] @string + +(character) @character + +(escape_sequence) @string.escape + +; Other literals +;--------------- +[ + (true) + (false) +] @boolean + +(number) @number + +(polyvar) @constructor + +(polyvar_string) @constructor + +; Functions +;---------- +; parameter(s) in parens +(parameter + (value_identifier) @variable.parameter) + +(labeled_parameter + (value_identifier) @variable.parameter) + +; single parameter with no parens +(function + parameter: (value_identifier) @variable.parameter) + +(parameter + (tuple_pattern + (tuple_item_pattern + (value_identifier) @variable.parameter))) + +(parameter + (array_pattern + (value_identifier) @variable.parameter)) + +(parameter + (record_pattern + (value_identifier) @variable.parameter)) + +; function identifier in let binding +(let_binding + pattern: (value_identifier) @function + body: (function)) + +; function calls +(call_expression + function: (value_identifier_path + (value_identifier) @function.method.call .)) + +(call_expression + function: (value_identifier) @function.call) + +; highlight the right-hand side of a pipe operator as a function call +(pipe_expression + (value_identifier) @function.call .) + +(pipe_expression + (value_identifier_path + (value_identifier) @function.method.call .) .) + +; Meta +;----- +(decorator_identifier) @attribute + +(extension_identifier) @keyword + +"%" @keyword + +; Misc +;----- +(polyvar_type_pattern + "#" @constructor) + +[ + "include" + "open" +] @keyword.import + +[ + "private" + "mutable" + "rec" +] @keyword.modifier + +"type" @keyword.type + +[ + "and" + "with" + "as" +] @keyword.operator + +[ + "export" + "external" + "let" + "module" + "assert" + "await" + "lazy" + "constraint" +] @keyword + +"await" @keyword.coroutine + +(function + "async" @keyword.coroutine) + +(module_unpack + "unpack" @keyword) + +[ + "if" + "else" + "switch" + "when" +] @keyword.conditional + +[ + "exception" + "try" + "catch" +] @keyword.exception + +(call_expression + function: (value_identifier) @keyword.exception + (#eq? @keyword.exception "raise")) + +[ + "for" + "in" + "to" + "downto" + "while" +] @keyword.repeat + +[ + "." + "," + "|" + ":" +] @punctuation.delimiter + +[ + "++" + "+" + "+." + "-" + "-." + "*" + "**" + "*." + "/." + "<=" + "==" + "===" + "!" + "!=" + "!==" + ">=" + "&&" + "||" + "=" + ":=" + "->" + "|>" + ":>" + "+=" + "=>" + (uncurry) +] @operator + +; Explicitly enclose these operators with binary_expression +; to avoid confusion with JSX tag delimiters +(binary_expression + [ + "<" + ">" + "/" + ] @operator) + +[ + "(" + ")" + "{" + "}" + "[" + "]" + "<" + ">" +] @punctuation.bracket + +(unit + [ + "(" + ")" + ] @constant.builtin) + +(template_substitution + "${" @punctuation.special + "}" @punctuation.special) @none + +(polyvar_type + [ + "[" + "[>" + "[<" + "]" + ] @punctuation.bracket) + +[ + "~" + "?" + ".." + "..." +] @punctuation.special + +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +; JSX +;---------- +(jsx_identifier) @tag + +(jsx_element + open_tag: (jsx_opening_element + [ + "<" + ">" + ] @tag.delimiter)) + +(jsx_element + close_tag: (jsx_closing_element + [ + "<" + "/" + ">" + ] @tag.delimiter)) + +(jsx_self_closing_element + [ + "/" + ">" + "<" + ] @tag.delimiter) + +(jsx_fragment + [ + ">" + "<" + "/" + ] @tag.delimiter) + +(jsx_attribute + (property_identifier) @tag.attribute) diff --git a/runtime/queries/rescript/indents.scm b/runtime/queries/rescript/indents.scm new file mode 100644 index 000000000..0b635dd4d --- /dev/null +++ b/runtime/queries/rescript/indents.scm @@ -0,0 +1,36 @@ +[ + (block) + (record_type) + (record) + (parenthesized_expression) + (call_expression) + (function_type_parameters) + (function) + (switch_match) + (let_declaration) + (jsx_element) + (jsx_fragment) + (jsx_self_closing_element) + (object_type) +] @indent.begin + +[ + "}" + ")" + (jsx_closing_element) +] @indent.branch @indent.end + +(jsx_self_closing_element + "/" @indent.branch + ">"? @indent.end) + +; </> is captured as 3 different anonymous nodes +(jsx_fragment + "<" + "<" @indent.branch) + +(jsx_fragment + ">" + ">" @indent.end) + +(comment) @indent.auto diff --git a/runtime/queries/rescript/injections.scm b/runtime/queries/rescript/injections.scm new file mode 100644 index 000000000..434404bef --- /dev/null +++ b/runtime/queries/rescript/injections.scm @@ -0,0 +1,33 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +(extension_expression + (extension_identifier) @_name + (#eq? @_name "re") + (expression_statement + (_) @injection.content + (#set! injection.language "regex"))) + +(extension_expression + (extension_identifier) @_name + (#eq? @_name "raw") + (expression_statement + (_ + (_) @injection.content + (#set! injection.language "javascript")))) + +(extension_expression + (extension_identifier) @_name + (#eq? @_name "graphql") + (expression_statement + (_ + (_) @injection.content + (#set! injection.language "graphql")))) + +(extension_expression + (extension_identifier) @_name + (#eq? @_name "relay") + (expression_statement + (_ + (_) @injection.content + (#set! injection.language "graphql")))) diff --git a/runtime/queries/rescript/locals.scm b/runtime/queries/rescript/locals.scm new file mode 100644 index 000000000..10a663bd7 --- /dev/null +++ b/runtime/queries/rescript/locals.scm @@ -0,0 +1,9 @@ +(switch_expression) @local.scope + +; Definitions +;------------ +(type_declaration) @local.definition.type + +(let_binding) @local.definition.var + +(module_declaration) @local.definition.namespace diff --git a/runtime/queries/rnoweb/folds.scm b/runtime/queries/rnoweb/folds.scm new file mode 100644 index 000000000..893758ccd --- /dev/null +++ b/runtime/queries/rnoweb/folds.scm @@ -0,0 +1 @@ +(rchunk) @fold diff --git a/runtime/queries/rnoweb/highlights.scm b/runtime/queries/rnoweb/highlights.scm new file mode 100644 index 000000000..81afaf101 --- /dev/null +++ b/runtime/queries/rnoweb/highlights.scm @@ -0,0 +1 @@ +; This file is a placeholder to enable the highlighting of injected languages. diff --git a/runtime/queries/rnoweb/injections.scm b/runtime/queries/rnoweb/injections.scm new file mode 100644 index 000000000..123cfb8a3 --- /dev/null +++ b/runtime/queries/rnoweb/injections.scm @@ -0,0 +1,12 @@ +((latex) @injection.content + (#set! injection.language "latex") + (#set! injection.combined)) + +(rchunk + (renv_content) @injection.content + (#set! injection.language "r") + (#set! injection.combined)) + +(rinline + (renv_content) @injection.content + (#set! injection.language "r")) diff --git a/runtime/queries/robot/folds.scm b/runtime/queries/robot/folds.scm new file mode 100644 index 000000000..948f8a17d --- /dev/null +++ b/runtime/queries/robot/folds.scm @@ -0,0 +1,5 @@ +[ + (section) + (keyword_definition) + (test_case_definition) +] @fold diff --git a/runtime/queries/robot/highlights.scm b/runtime/queries/robot/highlights.scm new file mode 100644 index 000000000..a9c545b8a --- /dev/null +++ b/runtime/queries/robot/highlights.scm @@ -0,0 +1,129 @@ +[ + (comment) + (extra_text) +] @comment @spell + +[ + (section_header) + (setting_statement) + (keyword_setting) + (test_case_setting) +] @keyword + +(variable_definition + (variable_name) @variable) + +(keyword_definition + (name) @function) + +(test_case_definition + (name) @function) + +(keyword_invocation + (keyword) @function.call) + +(ellipses) @punctuation.delimiter + +(text_chunk) @string + +(inline_python_expression) @string.special + +[ + (scalar_variable) + (list_variable) + (dictionary_variable) +] @variable + +; Control structures +[ + "FOR" + "IN" + "IN RANGE" + "IN ENUMERATE" + "IN ZIP" + (break_statement) + (continue_statement) +] @keyword.repeat + +(for_statement + "END" @keyword.repeat) + +"WHILE" @keyword.repeat + +(while_statement + "END" @keyword.repeat) + +[ + "IF" + "ELSE IF" +] @keyword.conditional + +(if_statement + "END" @keyword.conditional) + +(if_statement + (else_statement + "ELSE" @keyword.conditional)) + +(inline_if_statement + (inline_else_statement + "ELSE" @keyword.conditional)) + +[ + "TRY" + "EXCEPT" + "FINALLY" +] @keyword.exception + +(try_statement + "END" @keyword.exception) + +(try_statement + (else_statement + "ELSE" @keyword.exception)) + +; Extra captures for "Documentation" settings +(setting_statement + name: (setting_name) @_name + (arguments + (argument + (text_chunk) @spell @string.documentation)) + (#any-of? @_name "Documentation" "documentation" "DOCUMENTATION")) + +(setting_statement + name: (setting_name) @_name + (arguments + (continuation + (argument + (text_chunk) @spell @string.documentation))) + (#any-of? @_name "Documentation" "documentation" "DOCUMENTATION")) + +(keyword_setting + name: (keyword_setting_name) @_name + (arguments + (argument + (text_chunk) @spell @string.documentation)) + (#any-of? @_name "Documentation" "documentation" "DOCUMENTATION")) + +(keyword_setting + name: (keyword_setting_name) @_name + (arguments + (continuation + (argument + (text_chunk) @spell @string.documentation))) + (#any-of? @_name "Documentation" "documentation" "DOCUMENTATION")) + +(test_case_setting + name: (test_case_setting_name) @_name + (arguments + (argument + (text_chunk) @spell @string.documentation)) + (#any-of? @_name "Documentation" "documentation" "DOCUMENTATION")) + +(test_case_setting + name: (test_case_setting_name) @_name + (arguments + (continuation + (argument + (text_chunk) @spell @string.documentation))) + (#any-of? @_name "Documentation" "documentation" "DOCUMENTATION")) diff --git a/runtime/queries/robot/indents.scm b/runtime/queries/robot/indents.scm new file mode 100644 index 000000000..457fbff66 --- /dev/null +++ b/runtime/queries/robot/indents.scm @@ -0,0 +1,44 @@ +(keyword_definition) @indent.begin + +(test_case_definition) @indent.begin + +(for_statement) @indent.begin + +(for_statement + "END" @indent.branch) + +(for_statement + right: (_ + (arguments + (continuation + (ellipses) @indent.branch)))) + +(while_statement) @indent.begin + +(while_statement + "END" @indent.branch) + +(if_statement) @indent.begin + +(if_statement + (elseif_statement) @indent.branch) + +(if_statement + (else_statement) @indent.branch) + +(if_statement + "END" @indent.branch) + +(try_statement) @indent.begin + +(try_statement + (except_statement) @indent.branch) + +(try_statement + (finally_statement) @indent.branch) + +(try_statement + (else_statement) @indent.branch) + +(try_statement + "END" @indent.branch) diff --git a/runtime/queries/robot/injections.scm b/runtime/queries/robot/injections.scm new file mode 100644 index 000000000..56e37005e --- /dev/null +++ b/runtime/queries/robot/injections.scm @@ -0,0 +1,5 @@ +([ + (comment) + (extra_text) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/robots/highlights.scm b/runtime/queries/robots/highlights.scm new file mode 100644 index 000000000..a2c55c74f --- /dev/null +++ b/runtime/queries/robots/highlights.scm @@ -0,0 +1,7 @@ +(comment) @comment @spell + +(directive) @property + +(value) @string + +":" @punctuation.delimiter diff --git a/runtime/queries/robots/injections.scm b/runtime/queries/robots/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/robots/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/roc/highlights.scm b/runtime/queries/roc/highlights.scm new file mode 100644 index 000000000..4993017dc --- /dev/null +++ b/runtime/queries/roc/highlights.scm @@ -0,0 +1,175 @@ +;---Most generic types--- +(module) @module + +(identifier) @variable + +(concrete_type) @type + +;---annotations---- +(annotation_type_def + (annotation_pre_colon + (identifier) @type)) + +(annotation_type_def + (annotation_pre_colon + (identifier) @function) + (function_type)) + +;----decleration types---- +(value_declaration + (decl_left + (identifier_pattern + (identifier) @variable.parameter))) + +;---records---- +(field_name) @variable.member + +(record_field_pattern + (_ + (identifier) @variable)) + +;matches the second identifier and all subsequent ones +(field_access_expr + (identifier) @variable.member) + +;highlight module members as records instead of free variables +; avoids highlighting them as out-of-scope vars +(variable_expr + (module) + (identifier) @variable.member) + +;----comments---- +(line_comment) @comment @spell + +(doc_comment) @comment.documentation @spell + +;-----Punctuation---- +[ + "?" + (arrow) + (fat_arrow) + "|" + "," + ":" +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + "|" + "&" + "<-" + ".." + (operator) +] @operator + +(wildcard_pattern) @character.special + +[ + "if" + "then" + "else" +] @keyword.conditional + +[ + (implements) + (when) + (is) + (as) + "as" + (to) +] @keyword + +;----headers----- +[ + "app" + "expect" + "module" + "package" +] @keyword + +"import" @keyword.import + +(value_declaration + (decl_left + (identifier_pattern + (identifier) @function)) + (expr_body + (anon_fun_expr))) + +;----tags---- +(tags_type + (tag_type) @constructor) + +[ + (tag) + (opaque_tag) +] @constructor + +;-----builtins---- +(variable_expr + (module) @module + (identifier) @boolean + (#any-of? @boolean "true" "false") + (#eq? @module "Bool")) + +"dbg" @keyword.debug + +;----function invocations ---- +(function_call_pnc_expr + caller: (variable_expr + (identifier) @function.call)) + +(function_call_pnc_expr + caller: (field_access_expr + (identifier) @function.call .)) + +(bin_op_expr + (operator + "|>") @operator + (variable_expr + (identifier) @function)) + +;----function arguments---- +(argument_patterns + (identifier_pattern + (identifier) @variable.parameter)) + +(argument_patterns + (_ + (identifier_pattern + (identifier) @variable.parameter))) + +(argument_patterns + (_ + (_ + (identifier_pattern + (identifier) @variable.parameter)))) + +;-----consts----- +[ + (int) + (uint) + (iint) + (xint) + (natural) +] @number + +[ + (decimal) + (float) +] @number.float + +[ + (string) + (multiline_string) +] @string + +(char) @character diff --git a/runtime/queries/roc/indents.scm b/runtime/queries/roc/indents.scm new file mode 100644 index 000000000..9a08f2074 --- /dev/null +++ b/runtime/queries/roc/indents.scm @@ -0,0 +1,60 @@ +; (value_declaration(expr_body(anon_fun_expr)))@indent.ignore +[ + (when_is_expr) + (when_is_branch) + (record_expr) + (anon_fun_expr) + (list_expr) + (parenthesized_expr) + (function_call_pnc_expr) + (tuple_expr) + "import" + (exposes) + (exposes_list) + (exposing) + ;patterns + (record_pattern) + (tuple_pattern) + (list_pattern) + ;ability stuff + (ability_implementation) + (opaque_type_def) + ;types + (record_type) + (tags_type) + (record_expr) + (implements_implementation) + "{" + "(" + "[" +] @indent.begin + +; ((record_type) +; @indent.align +; (#set! indent.open_delimiter "{") +; (#set! indent.close_delimiter "}")) +; ((record_expr) +; @indent.align +; (#set! indent.open_delimiter "{") +; (#set! indent.close_delimiter "}")) +; ((tags_type) @indent.align +; (#set! indent.open_delimiter "[") +; (#set! indent.close_delimiter "]")) +; ((implements_implementation) @indent.align +; (#set! indent.open_delimiter "[") +; (#set! indent.close_delimiter "]")) +(expr_body) @indent.begin + +(ERROR + "=") @indent.begin + +(then) @indent.begin + +(else) @indent.begin + +[ + ; result:(_) + "]" + "}" + ")" +] @indent.branch diff --git a/runtime/queries/roc/injections.scm b/runtime/queries/roc/injections.scm new file mode 100644 index 000000000..5bc7576f8 --- /dev/null +++ b/runtime/queries/roc/injections.scm @@ -0,0 +1,30 @@ +;injection from function calls +(function_call_pnc_expr + (variable_expr + (identifier) @injection.language) + (const + [ + (multiline_string) + (string) + ] @injection.content) + (#any-of? @injection.language + "json" "toml" "yaml" "xml" "sql" "lua" "js" "html" "css" "http" "jq" "latex" "md" "nix" "regex")) + +;injection from piping function calls +(bin_op_expr + part: (const + [ + (multiline_string) + (string) + ] @injection.content) + part: (operator) + part: (variable_expr + (identifier) @injection.language) + (#any-of? @injection.language + "json" "toml" "yaml" "xml" "sql" "lua" "js" "html" "css" "http" "jq" "latex" "md" "nix" "regex")) + +([ + (line_comment) + (doc_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/roc/locals.scm b/runtime/queries/roc/locals.scm new file mode 100644 index 000000000..29f04e990 --- /dev/null +++ b/runtime/queries/roc/locals.scm @@ -0,0 +1,49 @@ +(expr_body) @local.scope + +(argument_patterns + (identifier_pattern + (identifier) @local.definition)) + +; (argument_patterns(long_identifier)@local.definition) +(exposes_list + (ident) @local.reference) + +(import_expr + (as) + (module) @local.definition) + +(opaque_type_def + (apply_type + (concrete_type) @local.definition.type)) + +(alias_type_def + (apply_type + (concrete_type) @local.definition.type)) + +(value_declaration + (decl_left + (identifier_pattern + (identifier) @local.definition.function)) + (expr_body + (anon_fun_expr))) + +(value_declaration + (decl_left + (identifier_pattern + (identifier) @local.definition.var))) + +(identifier_pattern + (identifier) @local.definition) + +(when_is_branch + pattern: (_ + (identifier_pattern + (identifier) @local.definition))) + +(spread_pattern + (identifier) @local.definition) + +(identifier) @local.reference + +(tag_expr + (tag)) @local.reference diff --git a/runtime/queries/ron/folds.scm b/runtime/queries/ron/folds.scm new file mode 100644 index 000000000..ae79583ea --- /dev/null +++ b/runtime/queries/ron/folds.scm @@ -0,0 +1,7 @@ +[ + (array) + (map) + (tuple) + (struct) + (block_comment) +] @fold diff --git a/runtime/queries/ron/highlights.scm b/runtime/queries/ron/highlights.scm new file mode 100644 index 000000000..96507323b --- /dev/null +++ b/runtime/queries/ron/highlights.scm @@ -0,0 +1,62 @@ +; Structs +;------------ +(enum_variant) @constant + +(struct_entry + (identifier) @variable.member) + +(struct_entry + (enum_variant + (identifier) @constant)) + +(struct_name + (identifier)) @type + +(unit_struct) @type.builtin + +; Literals +;------------ +(string) @string + +(boolean) @boolean + +(integer) @number + +(float) @number.float + +(char) @character + +; Comments +;------------ +[ + (line_comment) + (block_comment) +] @comment @spell + +; Punctuation +;------------ +[ + "{" + "}" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "," + ":" +] @punctuation.delimiter + +"-" @operator + +; Special +;------------ +(escape_sequence) @string.escape diff --git a/runtime/queries/ron/indents.scm b/runtime/queries/ron/indents.scm new file mode 100644 index 000000000..689d01fac --- /dev/null +++ b/runtime/queries/ron/indents.scm @@ -0,0 +1,21 @@ +[ + (array) + (map) + (tuple) + (struct) +] @indent.begin + +[ + "{" + "}" +] @indent.branch + +[ + "(" + ")" +] @indent.branch + +[ + "[" + "]" +] @indent.branch diff --git a/runtime/queries/ron/injections.scm b/runtime/queries/ron/injections.scm new file mode 100644 index 000000000..3cd6aac8e --- /dev/null +++ b/runtime/queries/ron/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/ron/locals.scm b/runtime/queries/ron/locals.scm new file mode 100644 index 000000000..81e38d5ed --- /dev/null +++ b/runtime/queries/ron/locals.scm @@ -0,0 +1,25 @@ +(source_file) @local.scope + +(source_file + (array) @local.scope) + +(source_file + (map) @local.scope) + +(source_file + (struct) @local.scope) + +(source_file + (tuple) @local.scope) + +(identifier) @local.reference + +(struct_entry + (identifier) @local.definition.field) + +(struct_entry + (identifier) @local.definition.enum + (enum_variant)) + +(struct + (struct_name) @local.definition.type) diff --git a/runtime/queries/rst/highlights.scm b/runtime/queries/rst/highlights.scm new file mode 100644 index 000000000..21e3825c0 --- /dev/null +++ b/runtime/queries/rst/highlights.scm @@ -0,0 +1,149 @@ +; Marks +[ + ".." + "|" + "--" + "__" + ":" + "::" + (transition) +] @punctuation.special + +"bullet" @markup.list + +; Resets for injection +(doctest_block) @none + +; Directives +(directive + name: (type) @function) + +(directive + body: (body + (arguments) @variable.parameter)) + +((directive + name: (type) @keyword.import) + (#eq? @keyword.import "include")) + +(directive + name: (type) @function.builtin + (#any-of? @function.builtin + ; https://docutils.sourceforge.io/docs/ref/rst/directives.html + "attention" "caution" "danger" "error" "hint" "important" "note" "tip" "warning" "admonition" + "image" "figure" "topic" "sidebar" "line-block" "parsed-literal" "code" "math" "rubric" + "epigraph" "highlights" "pull-quote" "compound" "container" "table" "csv-table" "list-table" + "contents" "sectnum" "section-numbering" "header" "footer" "target-notes" "meta" "replace" + "unicode" "date" "raw" "class" "role" "default-role" "title" "restructuredtext-test-directive")) + +; Blocks +[ + (literal_block) + (line_block) +] @markup.raw.block + +(block_quote + (attribution)? @markup.italic) @markup.quote + +(substitution_definition + name: (substitution) @constant) + +(footnote + name: (label) @constant) + +(citation + name: (label) @constant) + +(target + name: (name)? @markup.link.label + link: (_)? @markup.link) + +; Lists +; Definition lists +(list_item + (term) @markup.strong + (classifier)? @markup.italic) + +; Field lists +(field + (field_name) @constant) + +; Inline markup +(emphasis) @markup.italic + +(strong) @markup.strong + +(standalone_hyperlink) @string.special.url @nospell + +(role) @function + +((role) @function.builtin + (#any-of? @function.builtin + ; https://docutils.sourceforge.io/docs/ref/rst/roles.html + ":emphasis:" ":literal:" ":code:" ":math:" ":pep-reference:" ":PEP:" ":rfc-reference:" ":RFC:" + ":strong:" ":subscript:" ":sub:" ":superscript:" ":sup:" ":title-reference:" ":title:" ":t:" + ":raw:")) + +[ + "interpreted_text" + (literal) +] @markup.raw + +; Prefix role +((interpreted_text + (role) @_role + "interpreted_text" @markup.italic) + (#eq? @_role ":emphasis:")) + +((interpreted_text + (role) @_role + "interpreted_text" @markup.strong) + (#eq? @_role ":strong:")) + +((interpreted_text + (role) @_role + "interpreted_text" @none) + (#eq? @_role ":math:")) + +; Suffix role +((interpreted_text + "interpreted_text" @markup.italic + (role) @_role) + (#eq? @_role ":emphasis:")) + +((interpreted_text + "interpreted_text" @markup.strong + (role) @_role) + (#eq? @_role ":strong:")) + +((interpreted_text + "interpreted_text" @none + (role) @_role) + (#eq? @_role ":math:")) + +[ + (inline_target) + (substitution_reference) + (footnote_reference) + (citation_reference) + (reference) +] @markup.link @nospell + +; Others +[ + (title) + "adornment" +] @markup.heading + +(comment) @comment @spell + +(comment + "..") @comment + +(directive + name: (type) @_directive + body: (body + (content) @spell + (#not-any-of? @_directive "code" "code-block" "sourcecode"))) + +(paragraph) @spell diff --git a/runtime/queries/rst/injections.scm b/runtime/queries/rst/injections.scm new file mode 100644 index 000000000..7178de9da --- /dev/null +++ b/runtime/queries/rst/injections.scm @@ -0,0 +1,72 @@ +((doctest_block) @injection.content + (#set! injection.language "python")) + +; Directives with nested content without arguments nor options +((directive + name: (type) @_type + body: (body) @injection.content) + (#set! injection.language "rst") + (#any-of? @_type + "attention" "caution" "danger" "error" "hint" "important" "note" "tip" "warning" "admonition" + "line-block" "parsed-literal" "epigraph" "highlights" "pull-quote" "compound" "header" "footer" + "meta" "replace")) + +; Directives with nested content without arguments, but with options +((directive + name: (type) @_type + body: (body + (options) + (content) @injection.content)) + (#set! injection.language "rst") + (#any-of? @_type + "attention" "caution" "danger" "error" "hint" "important" "note" "tip" "warning" "admonition" + "line-block" "parsed-literal" "compound")) + +; Directives with nested content with arguments and options +((directive + name: (type) @_type + body: (body + (content) @injection.content)) + (#set! injection.language "rst") + (#any-of? @_type + "figure" "topic" "sidebar" "container" "table" "list-table" "class" "role" + "restructuredtext-test-directive")) + +; Special directives +((directive + name: (type) @_type + body: (body + (arguments) @injection.language + (content) @injection.content)) + (#any-of? @_type "raw" "code" "code-block" "sourcecode")) + +((directive + name: (type) @_type + body: (body + (content) @injection.content)) + (#set! injection.language "latex") + (#eq? @_type "math")) + +((directive + name: (type) @_type + body: (body + (content) @injection.content)) + (#set! injection.language "csv") + (#eq? @_type "csv-table")) + +; Special roles - prefix +((interpreted_text + (role) @_role + "interpreted_text" @injection.content) + (#eq? @_role ":math:") + (#set! injection.language "latex")) + +; Special roles - suffix +((interpreted_text + "interpreted_text" @injection.content + (role) @_role) + (#eq? @_role ":math:") + (#set! injection.language "latex")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/rst/locals.scm b/runtime/queries/rst/locals.scm new file mode 100644 index 000000000..ce4235b43 --- /dev/null +++ b/runtime/queries/rst/locals.scm @@ -0,0 +1,38 @@ +; Scopes +(document) @local.scope + +(directive) @local.scope + +; Definitions +(title) @local.definition + +(substitution_definition + name: (substitution) @local.definition) + +(footnote + name: (label) @local.definition) + +(citation + name: (label) @local.definition) + +(target + name: (name) @local.definition) + +; Inline targets +(inline_target) @local.definition + +; The role directive can define a new role +((directive + name: (type) @_type + body: (body + (arguments) @local.definition)) + (#eq? @_type "role")) + +; References +[ + (substitution_reference) + (footnote_reference) + (citation_reference) + (reference) + (role) +] @local.reference diff --git a/runtime/queries/ruby/folds.scm b/runtime/queries/ruby/folds.scm new file mode 100644 index 000000000..3a497b31b --- /dev/null +++ b/runtime/queries/ruby/folds.scm @@ -0,0 +1,12 @@ +[ + (method) + (singleton_method) + (class) + (module) + (if) + (else) + (case) + (do_block) + (singleton_class) + (lambda) +] @fold diff --git a/runtime/queries/ruby/highlights.scm b/runtime/queries/ruby/highlights.scm new file mode 100644 index 000000000..a1a2c250d --- /dev/null +++ b/runtime/queries/ruby/highlights.scm @@ -0,0 +1,306 @@ +; Variables +[ + (identifier) + (global_variable) +] @variable + +; Keywords +[ + "alias" + "begin" + "do" + "end" + "ensure" + "module" + "rescue" + "then" +] @keyword + +"class" @keyword.type + +[ + "return" + "yield" +] @keyword.return + +[ + "and" + "or" + "in" + "not" +] @keyword.operator + +[ + "def" + "undef" +] @keyword.function + +(method + "end" @keyword.function) + +[ + "case" + "else" + "elsif" + "if" + "unless" + "when" + "then" +] @keyword.conditional + +(if + "end" @keyword.conditional) + +[ + "for" + "until" + "while" + "break" + "redo" + "retry" + "next" +] @keyword.repeat + +(constant) @constant + +((identifier) @keyword.modifier + (#any-of? @keyword.modifier "private" "protected" "public")) + +[ + "rescue" + "ensure" +] @keyword.exception + +; Function calls +"defined?" @function + +(call + receiver: (constant)? @type + method: [ + (identifier) + (constant) + ] @function.call) + +(program + (call + (identifier) @keyword.import) + (#any-of? @keyword.import "require" "require_relative" "load")) + +; Function definitions +(alias + (identifier) @function) + +(setter + (identifier) @function) + +(method + name: [ + (identifier) @function + (constant) @type + ]) + +(singleton_method + name: [ + (identifier) @function + (constant) @type + ]) + +(class + name: (constant) @type) + +(module + name: (constant) @type) + +(superclass + (constant) @type) + +; Identifiers +[ + (class_variable) + (instance_variable) +] @variable.member + +((identifier) @constant.builtin + (#any-of? @constant.builtin + "__callee__" "__dir__" "__id__" "__method__" "__send__" "__ENCODING__" "__FILE__" "__LINE__")) + +((identifier) @function.builtin + (#any-of? @function.builtin "attr_reader" "attr_writer" "attr_accessor" "module_function")) + +((call + !receiver + method: (identifier) @function.builtin) + (#any-of? @function.builtin "include" "extend" "prepend" "refine" "using")) + +((identifier) @keyword.exception + (#any-of? @keyword.exception "raise" "fail" "catch" "throw")) + +((constant) @type + (#not-lua-match? @type "^[A-Z0-9_]+$")) + +[ + (self) + (super) +] @variable.builtin + +(method_parameters + (identifier) @variable.parameter) + +(lambda_parameters + (identifier) @variable.parameter) + +(block_parameters + (identifier) @variable.parameter) + +(splat_parameter + (identifier) @variable.parameter) + +(hash_splat_parameter + (identifier) @variable.parameter) + +(optional_parameter + (identifier) @variable.parameter) + +(destructured_parameter + (identifier) @variable.parameter) + +(block_parameter + (identifier) @variable.parameter) + +(keyword_parameter + (identifier) @variable.parameter) + +; Literals +[ + (string_content) + (heredoc_content) + "\"" + "`" +] @string + +[ + (heredoc_beginning) + (heredoc_end) +] @label + +[ + (bare_symbol) + (simple_symbol) + (delimited_symbol) + (hash_key_symbol) +] @string.special.symbol + +(regex + (string_content) @string.regexp) + +(escape_sequence) @string.escape + +(integer) @number + +(float) @number.float + +[ + (true) + (false) +] @boolean + +(nil) @constant.builtin + +(comment) @comment @spell + +((program + . + (comment) @keyword.directive @nospell) + (#lua-match? @keyword.directive "^#!/")) + +(program + (comment)+ @comment.documentation + (class)) + +(module + (comment)+ @comment.documentation + (body_statement + (class))) + +(class + (comment)+ @comment.documentation + (body_statement + (method))) + +(body_statement + (comment)+ @comment.documentation + (method)) + +; Operators +[ + "!" + "=" + "==" + "===" + "<=>" + "=>" + "->" + ">>" + "<<" + ">" + "<" + ">=" + "<=" + "**" + "*" + "/" + "%" + "+" + "-" + "&" + "|" + "^" + "&&" + "||" + "||=" + "&&=" + "!=" + "%=" + "+=" + "-=" + "*=" + "/=" + "=~" + "!~" + "?" + ":" + ".." + "..." +] @operator + +[ + "," + ";" + "." + "&." + "::" +] @punctuation.delimiter + +(regex + "/" @punctuation.bracket) + +(pair + ":" @punctuation.delimiter) + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "%w(" + "%i(" +] @punctuation.bracket + +(block_parameters + "|" @punctuation.bracket) + +(interpolation + "#{" @punctuation.special + "}" @punctuation.special) diff --git a/runtime/queries/ruby/indents.scm b/runtime/queries/ruby/indents.scm new file mode 100644 index 000000000..b76732922 --- /dev/null +++ b/runtime/queries/ruby/indents.scm @@ -0,0 +1,43 @@ +[ + (class) + (singleton_class) + (method) + (singleton_method) + (module) + (call) + (if) + (block) + (do_block) + (hash) + (array) + (argument_list) + (case) + (while) + (until) + (for) + (begin) + (unless) + (assignment) + (parenthesized_statements) +] @indent.begin + +[ + "end" + ")" + "}" + "]" +] @indent.end + +[ + "end" + ")" + "}" + "]" + (when) + (elsif) + (else) + (rescue) + (ensure) +] @indent.branch + +(comment) @indent.ignore diff --git a/runtime/queries/ruby/injections.scm b/runtime/queries/ruby/injections.scm new file mode 100644 index 000000000..12b2c32a5 --- /dev/null +++ b/runtime/queries/ruby/injections.scm @@ -0,0 +1,23 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +(heredoc_body + (heredoc_content) @injection.content + (heredoc_end) @injection.language + (#downcase! @injection.language)) + +(regex + (string_content) @injection.content + (#set! injection.language "regex")) + +((call + receiver: (identifier) @_receiver + method: (identifier) @_method + arguments: (argument_list + (pair + key: (hash_key_symbol) + value: (string + (string_content) @injection.content)))) + (#eq? @_receiver "binding") + (#any-of? @_method "b" "break") + (#set! injection.self)) diff --git a/runtime/queries/ruby/locals.scm b/runtime/queries/ruby/locals.scm new file mode 100644 index 000000000..29a67e2ba --- /dev/null +++ b/runtime/queries/ruby/locals.scm @@ -0,0 +1,93 @@ +; The MIT License (MIT) +; +; Copyright (c) 2016 Rob Rix +; +; Permission is hereby granted, free of charge, to any person obtaining a copy +; of this software and associated documentation files (the "Software"), to deal +; in the Software without restriction, including without limitation the rights +; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +; copies of the Software, and to permit persons to whom the Software is +; furnished to do so, subject to the following conditions: +; +; The above copyright notice and this permission notice shall be included in all +; copies or substantial portions of the Software. +; +; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +; SOFTWARE. +; DECLARATIONS AND SCOPES +(method) @local.scope + +(class) @local.scope + +[ + (block) + (do_block) +] @local.scope + +(identifier) @local.reference + +(constant) @local.reference + +(instance_variable) @local.reference + +(module + name: (constant) @local.definition.namespace) + +(class + name: (constant) @local.definition.type) + +(method + name: [ + (identifier) + (constant) + ] @local.definition.function) + +(singleton_method + name: [ + (identifier) + (constant) + ] @local.definition.function) + +(method_parameters + (identifier) @local.definition.var) + +(lambda_parameters + (identifier) @local.definition.var) + +(block_parameters + (identifier) @local.definition.var) + +(splat_parameter + (identifier) @local.definition.var) + +(hash_splat_parameter + (identifier) @local.definition.var) + +(optional_parameter + name: (identifier) @local.definition.var) + +(destructured_parameter + (identifier) @local.definition.var) + +(block_parameter + name: (identifier) @local.definition.var) + +(keyword_parameter + name: (identifier) @local.definition.var) + +(assignment + left: (_) @local.definition.var) + +(left_assignment_list + (identifier) @local.definition.var) + +(rest_assignment + (identifier) @local.definition.var) + +(destructured_left_assignment + (identifier) @local.definition.var) diff --git a/runtime/queries/runescript/highlights.scm b/runtime/queries/runescript/highlights.scm new file mode 100644 index 000000000..d0c9432bd --- /dev/null +++ b/runtime/queries/runescript/highlights.scm @@ -0,0 +1,119 @@ +; Variables +(identifier) @variable + +(local_variable + "$" @attribute.builtin) + +(game_variable + [ + "%" + ".%" + ] @attribute.builtin) + +(constant_variable + "^" @attribute.builtin) + +(parameter + (local_variable + name: (identifier) @variable.parameter)) + +; Scripts +(script + trigger: (identifier) @keyword.directive + subject: (identifier) @function) + +; Calls +(call + [ + "~" + "@" + ]? @attribute.builtin + callee: (identifier) @function.call) + +; Literals +((literal) @boolean + (#any-of? @boolean "true" "false")) + +(literal + "null" @constant.builtin) + +(integer_literal) @number + +(coord_literal) @string.special + +(comment) @comment @spell + +[ + (string_fragment) + "\"" +] @string + +(escape_sequence) @string.escape + +(string_interpolation + [ + "<" + ">" + ] @punctuation.special) + +(string_tag) @punctuation.special + +; Types +(type) @type + +(parameter_type) @type + +; Tokens +[ + ";" + ":" + "," +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.special + +[ + "*" + "/" + "+" + "-" + "&" + "|" + ">" + ">=" + "<" + "<=" + "=" + "!" +] @operator + +(arithmetic + "%" @operator) + +[ + (def_type_keyword) + (switch_type_keyword) +] @keyword.modifier + +"return" @keyword.return + +"while" @keyword.repeat + +[ + "default" + "if" + "else" + "case" +] @keyword.conditional + +"calc" @keyword diff --git a/runtime/queries/runescript/injections.scm b/runtime/queries/runescript/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/runescript/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/rust/folds.scm b/runtime/queries/rust/folds.scm new file mode 100644 index 000000000..9237b6f7b --- /dev/null +++ b/runtime/queries/rust/folds.scm @@ -0,0 +1,25 @@ +[ + (mod_item) + (foreign_mod_item) + (function_item) + (struct_item) + (trait_item) + (enum_item) + (impl_item) + (type_item) + (union_item) + (const_item) + (let_declaration) + (loop_expression) + (for_expression) + (while_expression) + (if_expression) + (match_expression) + (call_expression) + (array_expression) + (macro_definition) + (macro_invocation) + (attribute_item) + (block) + (use_declaration)+ +] @fold diff --git a/runtime/queries/rust/highlights.scm b/runtime/queries/rust/highlights.scm new file mode 100644 index 000000000..de9d09684 --- /dev/null +++ b/runtime/queries/rust/highlights.scm @@ -0,0 +1,531 @@ +; Forked from https://github.com/tree-sitter/tree-sitter-rust +; Copyright (c) 2017 Maxim Sokolov +; Licensed under the MIT license. +; Identifier conventions +(shebang) @keyword.directive + +(identifier) @variable + +((identifier) @type + (#lua-match? @type "^[A-Z]")) + +(const_item + name: (identifier) @constant) + +; Assume all-caps names are constants +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z%d_]*$")) + +; Other identifiers +(type_identifier) @type + +(primitive_type) @type.builtin + +(field_identifier) @variable.member + +(shorthand_field_identifier) @variable.member + +(shorthand_field_initializer + (identifier) @variable.member) + +(mod_item + name: (identifier) @module) + +(self) @variable.builtin + +"_" @character.special + +(label + [ + "'" + (identifier) + ] @label) + +; Function definitions +(function_item + (identifier) @function) + +(function_signature_item + (identifier) @function) + +(parameter + [ + (identifier) + "_" + ] @variable.parameter) + +(parameter + (ref_pattern + [ + (mut_pattern + (identifier) @variable.parameter) + (identifier) @variable.parameter + ])) + +(closure_parameters + (_) @variable.parameter) + +; Function calls +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (scoped_identifier + (identifier) @function.call .)) + +(call_expression + function: (field_expression + field: (field_identifier) @function.call)) + +(generic_function + function: (identifier) @function.call) + +(generic_function + function: (scoped_identifier + name: (identifier) @function.call)) + +(generic_function + function: (field_expression + field: (field_identifier) @function.call)) + +; Assume other uppercase names are enum constructors +((field_identifier) @constant + (#lua-match? @constant "^[A-Z]")) + +(enum_variant + name: (identifier) @constant) + +; Assume that uppercase names in paths are types +(scoped_identifier + path: (identifier) @module) + +(scoped_identifier + (scoped_identifier + name: (identifier) @module)) + +(scoped_type_identifier + path: (identifier) @module) + +(scoped_type_identifier + path: (identifier) @type + (#lua-match? @type "^[A-Z]")) + +(scoped_type_identifier + (scoped_identifier + name: (identifier) @module)) + +((scoped_identifier + path: (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +((scoped_identifier + name: (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +((scoped_identifier + name: (identifier) @constant) + (#lua-match? @constant "^[A-Z][A-Z%d_]*$")) + +((scoped_identifier + path: (identifier) @type + name: (identifier) @constant) + (#lua-match? @type "^[A-Z]") + (#lua-match? @constant "^[A-Z]")) + +((scoped_type_identifier + path: (identifier) @type + name: (type_identifier) @constant) + (#lua-match? @type "^[A-Z]") + (#lua-match? @constant "^[A-Z]")) + +[ + (crate) + (super) +] @module + +(scoped_use_list + path: (identifier) @module) + +(scoped_use_list + path: (scoped_identifier + (identifier) @module)) + +(use_list + (scoped_identifier + (identifier) @module + . + (_))) + +(use_list + (identifier) @type + (#lua-match? @type "^[A-Z]")) + +(use_as_clause + alias: (identifier) @type + (#lua-match? @type "^[A-Z]")) + +; Correct enum constructors +(call_expression + function: (scoped_identifier + "::" + name: (identifier) @constant) + (#lua-match? @constant "^[A-Z]")) + +; Assume uppercase names in a match arm are constants. +((match_arm + pattern: (match_pattern + (identifier) @constant)) + (#lua-match? @constant "^[A-Z]")) + +((match_arm + pattern: (match_pattern + (scoped_identifier + name: (identifier) @constant))) + (#lua-match? @constant "^[A-Z]")) + +((identifier) @constant.builtin + (#any-of? @constant.builtin "Some" "None" "Ok" "Err")) + +; Macro definitions +"$" @function.macro + +(metavariable) @function.macro + +(macro_definition + "macro_rules!" @function.macro) + +; Attribute macros +(attribute_item + (attribute + (identifier) @function.macro)) + +(inner_attribute_item + (attribute + (identifier) @function.macro)) + +(attribute + (scoped_identifier + (identifier) @function.macro .)) + +; Derive macros (assume all arguments are types) +; (attribute +; (identifier) @_name +; arguments: (attribute (attribute (identifier) @type)) +; (#eq? @_name "derive")) +; Function-like macros +(macro_invocation + macro: (identifier) @function.macro) + +(macro_invocation + macro: (scoped_identifier + (identifier) @function.macro .)) + +; Literals +(boolean_literal) @boolean + +(integer_literal) @number + +(float_literal) @number.float + +[ + (raw_string_literal) + (string_literal) +] @string + +(escape_sequence) @string.escape + +(char_literal) @character + +; Keywords +[ + "use" + "mod" +] @keyword.import + +(use_as_clause + "as" @keyword.import) + +[ + "default" + "impl" + "let" + "move" + "unsafe" + "where" +] @keyword + +[ + "enum" + "struct" + "union" + "trait" + "type" +] @keyword.type + +[ + "async" + "await" + "gen" +] @keyword.coroutine + +"try" @keyword.exception + +[ + "ref" + "pub" + "raw" + (mutable_specifier) + "const" + "static" + "dyn" + "extern" +] @keyword.modifier + +(lifetime + "'" @keyword.modifier) + +(lifetime + (identifier) @attribute) + +(lifetime + (identifier) @attribute.builtin + (#any-of? @attribute.builtin "static" "_")) + +"fn" @keyword.function + +[ + "return" + "yield" +] @keyword.return + +(type_cast_expression + "as" @keyword.operator) + +(qualified_type + "as" @keyword.operator) + +(use_list + (self) @module) + +(scoped_use_list + (self) @module) + +(scoped_identifier + [ + (crate) + (super) + (self) + ] @module) + +(visibility_modifier + [ + (crate) + (super) + (self) + ] @module) + +[ + "if" + "else" + "match" +] @keyword.conditional + +[ + "break" + "continue" + "in" + "loop" + "while" +] @keyword.repeat + +"for" @keyword + +(for_expression + "for" @keyword.repeat) + +; Operators +[ + "!" + "!=" + "%" + "%=" + "&" + "&&" + "&=" + "*" + "*=" + "+" + "+=" + "-" + "-=" + ".." + "..=" + "..." + "/" + "/=" + "<" + "<<" + "<<=" + "<=" + "=" + "==" + ">" + ">=" + ">>" + ">>=" + "?" + "@" + "^" + "^=" + "|" + "|=" + "||" +] @operator + +(use_wildcard + "*" @character.special) + +(remaining_field_pattern + ".." @character.special) + +(range_pattern + [ + ".." + "..=" + "..." + ] @character.special) + +; Punctuation +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(closure_parameters + "|" @punctuation.bracket) + +(type_arguments + [ + "<" + ">" + ] @punctuation.bracket) + +(type_parameters + [ + "<" + ">" + ] @punctuation.bracket) + +(bracketed_type + [ + "<" + ">" + ] @punctuation.bracket) + +(for_lifetimes + [ + "<" + ">" + ] @punctuation.bracket) + +[ + "," + "." + ":" + "::" + ";" + "->" + "=>" +] @punctuation.delimiter + +(attribute_item + "#" @punctuation.special) + +(inner_attribute_item + [ + "!" + "#" + ] @punctuation.special) + +(macro_invocation + "!" @function.macro) + +(never_type + "!" @type.builtin) + +(macro_invocation + macro: (identifier) @_identifier @keyword.exception + "!" @keyword.exception + (#eq? @_identifier "panic")) + +(macro_invocation + macro: (identifier) @_identifier @keyword.exception + "!" @keyword.exception + (#contains? @_identifier "assert")) + +(macro_invocation + macro: (identifier) @_identifier @keyword.debug + "!" @keyword.debug + (#eq? @_identifier "dbg")) + +; Comments +[ + (line_comment) + (block_comment) + (outer_doc_comment_marker) + (inner_doc_comment_marker) +] @comment @spell + +(line_comment + (doc_comment)) @comment.documentation + +(block_comment + (doc_comment)) @comment.documentation + +(call_expression + function: (scoped_identifier + path: (identifier) @_regex + (#any-of? @_regex "Regex" "ByteRegexBuilder") + name: (identifier) @_new + (#eq? @_new "new")) + arguments: (arguments + (raw_string_literal + (string_content) @string.regexp))) + +(call_expression + function: (scoped_identifier + path: (scoped_identifier + (identifier) @_regex + (#any-of? @_regex "Regex" "ByteRegexBuilder") .) + name: (identifier) @_new + (#eq? @_new "new")) + arguments: (arguments + (raw_string_literal + (string_content) @string.regexp))) + +(call_expression + function: (scoped_identifier + path: (identifier) @_regex + (#any-of? @_regex "RegexSet" "RegexSetBuilder") + name: (identifier) @_new + (#eq? @_new "new")) + arguments: (arguments + (array_expression + (raw_string_literal + (string_content) @string.regexp)))) + +(call_expression + function: (scoped_identifier + path: (scoped_identifier + (identifier) @_regex + (#any-of? @_regex "RegexSet" "RegexSetBuilder") .) + name: (identifier) @_new + (#eq? @_new "new")) + arguments: (arguments + (array_expression + (raw_string_literal + (string_content) @string.regexp)))) diff --git a/runtime/queries/rust/indents.scm b/runtime/queries/rust/indents.scm new file mode 100644 index 000000000..9fe337d5c --- /dev/null +++ b/runtime/queries/rust/indents.scm @@ -0,0 +1,132 @@ +[ + (mod_item) + (struct_item) + (enum_item) + (impl_item) + (struct_expression) + (struct_pattern) + (tuple_struct_pattern) + (tuple_expression) + (tuple_type) + (tuple_pattern) + (match_block) + (call_expression) + (assignment_expression) + (arguments) + (block) + (where_clause) + (use_list) + (array_expression) + (ordered_field_declaration_list) + (field_declaration_list) + (enum_variant_list) + (parameters) + (token_tree) + (token_repetition) + (macro_definition) +] @indent.begin + +(trait_item + body: (_) @indent.begin) + +(string_literal + (escape_sequence)) @indent.begin + +; Typing in "(" inside macro definitions breaks the tree entirely +; Making macro_definition becoming errors +; Offset this by adding back one indent for start of macro rules +(ERROR + . + "macro_rules!" + [ + "(" + "{" + "[" + ] @indent.begin + (#set! indent.immediate) + (#set! indent.start_at_same_line)) + +(macro_definition + [ + ")" + "}" + "]" + ] @indent.end) + +(trait_item + body: (_) @indent.begin) + +(string_literal + (escape_sequence)) @indent.begin + +(block + "}" @indent.end) + +(enum_item + body: (enum_variant_list + "}" @indent.end)) + +(impl_item + body: (declaration_list + "}" @indent.end)) + +(match_expression + body: (match_block + "}" @indent.end)) + +(mod_item + body: (declaration_list + "}" @indent.end)) + +(struct_item + body: (field_declaration_list + "}" @indent.end)) + +(struct_expression + body: (field_initializer_list + "}" @indent.end)) + +(struct_pattern + "}" @indent.end) + +(tuple_struct_pattern + ")" @indent.end) +; Typing in "(" inside macro definitions breaks the tree entirely +; Making macro_definition becoming errors +; Offset this by adding back one indent for start of macro rules +(ERROR + . + "macro_rules!" + "(" @indent.begin + (#set! indent.immediate) + (#set! indent.start_at_same_line)) + +(tuple_type + ")" @indent.end) + +(tuple_pattern + ")" @indent.end) + +(trait_item + body: (declaration_list + "}" @indent.end)) + +(impl_item + (where_clause) @indent.dedent) + +[ + "where" + ")" + "]" + "}" +] @indent.branch + +(impl_item + (declaration_list) @indent.branch) + +[ + (line_comment) + (string_literal) +] @indent.ignore + +(raw_string_literal) @indent.auto diff --git a/runtime/queries/rust/injections.scm b/runtime/queries/rust/injections.scm new file mode 100644 index 000000000..7bffd1fc9 --- /dev/null +++ b/runtime/queries/rust/injections.scm @@ -0,0 +1,89 @@ +(macro_invocation + macro: [ + (scoped_identifier + name: (_) @_macro_name) + (identifier) @_macro_name + ] + (token_tree) @injection.content + (#not-any-of? @_macro_name "slint" "html" "json") + (#set! injection.language "rust") + (#set! injection.include-children)) + +(macro_invocation + macro: [ + (scoped_identifier + name: (_) @injection.language) + (identifier) @injection.language + ] + (token_tree) @injection.content + (#any-of? @injection.language "slint" "html" "json") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children)) + +(macro_definition + (macro_rule + left: (token_tree_pattern) @injection.content + (#set! injection.language "rust"))) + +(macro_definition + (macro_rule + right: (token_tree) @injection.content + (#set! injection.language "rust"))) + +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) + +(call_expression + function: (scoped_identifier + path: (identifier) @_regex + (#any-of? @_regex "Regex" "RegexBuilder") + name: (identifier) @_new + (#eq? @_new "new")) + arguments: (arguments + (raw_string_literal + (string_content) @injection.content)) + (#set! injection.language "regex")) + +(call_expression + function: (scoped_identifier + path: (scoped_identifier + (identifier) @_regex + (#any-of? @_regex "Regex" "RegexBuilder") .) + name: (identifier) @_new + (#eq? @_new "new")) + arguments: (arguments + (raw_string_literal + (string_content) @injection.content)) + (#set! injection.language "regex")) + +(call_expression + function: (scoped_identifier + path: (identifier) @_regex + (#any-of? @_regex "RegexSet" "RegexSetBuilder") + name: (identifier) @_new + (#eq? @_new "new")) + arguments: (arguments + (array_expression + (raw_string_literal + (string_content) @injection.content))) + (#set! injection.language "regex")) + +(call_expression + function: (scoped_identifier + path: (scoped_identifier + (identifier) @_regex + (#any-of? @_regex "RegexSet" "RegexSetBuilder") .) + name: (identifier) @_new + (#eq? @_new "new")) + arguments: (arguments + (array_expression + (raw_string_literal + (string_content) @injection.content))) + (#set! injection.language "regex")) + +((block_comment) @injection.content + (#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c") + (#set! injection.language "re2c")) diff --git a/runtime/queries/rust/locals.scm b/runtime/queries/rust/locals.scm new file mode 100644 index 000000000..718d5f24a --- /dev/null +++ b/runtime/queries/rust/locals.scm @@ -0,0 +1,98 @@ +; Imports +(extern_crate_declaration + name: (identifier) @local.definition.import) + +(use_declaration + argument: (scoped_identifier + name: (identifier) @local.definition.import)) + +(use_as_clause + alias: (identifier) @local.definition.import) + +(use_list + (identifier) @local.definition.import) ; use std::process::{Child, Command, Stdio}; + +; Functions +(function_item + name: (identifier) @local.definition.function) + +(function_item + name: (identifier) @local.definition.method + parameters: (parameters + (self_parameter))) + +; Variables +(parameter + pattern: (identifier) @local.definition.var) + +(let_declaration + pattern: (identifier) @local.definition.var) + +(const_item + name: (identifier) @local.definition.var) + +(tuple_pattern + (identifier) @local.definition.var) + +(let_condition + pattern: (_ + (identifier) @local.definition.var)) + +(tuple_struct_pattern + (identifier) @local.definition.var) + +(closure_parameters + (identifier) @local.definition.var) + +(self_parameter + (self) @local.definition.var) + +(for_expression + pattern: (identifier) @local.definition.var) + +; Types +(struct_item + name: (type_identifier) @local.definition.type) + +(enum_item + name: (type_identifier) @local.definition.type) + +; Fields +(field_declaration + name: (field_identifier) @local.definition.field) + +(enum_variant + name: (identifier) @local.definition.field) + +; References +(identifier) @local.reference + +((type_identifier) @local.reference + (#set! reference.kind "type")) + +((field_identifier) @local.reference + (#set! reference.kind "field")) + +; Macros +(macro_definition + name: (identifier) @local.definition.macro) + +; Module +(mod_item + name: (identifier) @local.definition.namespace) + +; Scopes +[ + (block) + (function_item) + (closure_expression) + (while_expression) + (for_expression) + (loop_expression) + (if_expression) + (match_expression) + (match_arm) + (struct_item) + (enum_item) + (impl_item) +] @local.scope diff --git a/runtime/queries/scala/folds.scm b/runtime/queries/scala/folds.scm new file mode 100644 index 000000000..b0f08188e --- /dev/null +++ b/runtime/queries/scala/folds.scm @@ -0,0 +1,16 @@ +(call_expression + (block) @fold) + +[ + (class_definition) + (trait_definition) + (object_definition) + (function_definition) + (val_definition) + (import_declaration) + (while_expression) + (do_while_expression) + (for_expression) + (try_expression) + (match_expression) +] @fold diff --git a/runtime/queries/scala/highlights.scm b/runtime/queries/scala/highlights.scm new file mode 100644 index 000000000..f85c502a4 --- /dev/null +++ b/runtime/queries/scala/highlights.scm @@ -0,0 +1,311 @@ +; CREDITS @stumash (stuart.mashaal@gmail.com) +(class_definition + name: (identifier) @type) + +(enum_definition + name: (identifier) @type) + +(object_definition + name: (identifier) @type) + +(trait_definition + name: (identifier) @type) + +(full_enum_case + name: (identifier) @type) + +(simple_enum_case + name: (identifier) @type) + +; variables +(class_parameter + name: (identifier) @variable.parameter) + +(self_type + (identifier) @variable.parameter) + +(interpolation + (identifier) @none) + +(interpolation + (block) @none) + +; types +(type_definition + name: (type_identifier) @type.definition) + +(type_identifier) @type + +; val/var definitions/declarations +(val_definition + pattern: (identifier) @variable) + +(var_definition + pattern: (identifier) @variable) + +(val_declaration + name: (identifier) @variable) + +(var_declaration + name: (identifier) @variable) + +; method definition +(function_declaration + name: (identifier) @function.method) + +(function_definition + name: (identifier) @function.method) + +; imports/exports +(import_declaration + path: (identifier) @module) + +(stable_identifier + (identifier) @module) + +((import_declaration + path: (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +((stable_identifier + (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +(export_declaration + path: (identifier) @module) + +(stable_identifier + (identifier) @module) + +((export_declaration + path: (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +((stable_identifier + (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +((namespace_selectors + (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +; method invocation +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (operator_identifier) @function.call) + +(call_expression + function: (field_expression + field: (identifier) @function.method.call)) + +((call_expression + function: (identifier) @constructor) + (#lua-match? @constructor "^[A-Z]")) + +(generic_function + function: (identifier) @function.call) + +(interpolated_string_expression + interpolator: (identifier) @function.call) + +; function definitions +(function_definition + name: (identifier) @function) + +(parameter + name: (identifier) @variable.parameter) + +(binding + name: (identifier) @variable.parameter) + +(lambda_expression + parameters: (identifier) @variable.parameter) + +; expressions +(field_expression + field: (identifier) @variable.member) + +(field_expression + value: (identifier) @type + (#lua-match? @type "^[A-Z]")) + +(infix_expression + operator: (identifier) @operator) + +(infix_expression + operator: (operator_identifier) @operator) + +(infix_type + operator: (operator_identifier) @operator) + +(infix_type + operator: (operator_identifier) @operator) + +; literals +(boolean_literal) @boolean + +(integer_literal) @number + +(floating_point_literal) @number.float + +[ + (string) + (interpolated_string_expression) +] @string + +(character_literal) @character + +(interpolation + "$" @punctuation.special) + +; keywords +(opaque_modifier) @keyword.modifier + +(infix_modifier) @keyword + +(transparent_modifier) @keyword.modifier + +(open_modifier) @keyword.modifier + +[ + "case" + "extends" + "derives" + "finally" + ; `forSome` existential types not implemented yet + ; `macro` not implemented yet + "object" + "override" + "val" + "var" + "with" + "given" + "using" + "end" + "implicit" + "extension" + "with" +] @keyword + +[ + "enum" + "class" + "trait" + "type" +] @keyword.type + +[ + "abstract" + "final" + "lazy" + "sealed" + "private" + "protected" +] @keyword.modifier + +(inline_modifier) @keyword.modifier + +(null_literal) @constant.builtin + +(wildcard + "_") @character.special + +(namespace_wildcard + [ + "*" + "_" + ] @character.special) + +(annotation) @attribute + +; special keywords +"new" @keyword.operator + +[ + "else" + "if" + "match" + "then" +] @keyword.conditional + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "." + "," + ":" +] @punctuation.delimiter + +[ + "do" + "for" + "while" + "yield" +] @keyword.repeat + +"def" @keyword.function + +[ + "=>" + "?=>" + "=" + "!" + "<-" + "@" +] @operator + +[ + "import" + "export" + "package" +] @keyword.import + +[ + "try" + "catch" + "throw" +] @keyword.exception + +"return" @keyword.return + +[ + (comment) + (block_comment) +] @comment @spell + +((block_comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +; `case` is a conditional keyword in case_block +(case_block + (case_clause + "case" @keyword.conditional)) + +(case_block + (case_clause + "=>" @punctuation.delimiter)) + +(operator_identifier) @operator + +((identifier) @type + (#lua-match? @type "^[A-Z]")) + +((identifier) @variable.builtin + (#lua-match? @variable.builtin "^this$")) + +((identifier) @function.builtin + (#lua-match? @function.builtin "^super$")) + +; Scala CLI using directives +(using_directive_key) @variable.parameter + +(using_directive_value) @string diff --git a/runtime/queries/scala/injections.scm b/runtime/queries/scala/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/scala/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/scala/locals.scm b/runtime/queries/scala/locals.scm new file mode 100644 index 000000000..7128a4984 --- /dev/null +++ b/runtime/queries/scala/locals.scm @@ -0,0 +1,49 @@ +; Scopes +[ + (template_body) + (lambda_expression) + (function_definition) + (block) + (for_expression) +] @local.scope + +; References +(identifier) @local.reference + +; Definitions +(function_declaration + name: (identifier) @local.definition.function) + +(function_definition + name: (identifier) @local.definition.function + (#set! definition.var.scope parent)) + +(parameter + name: (identifier) @local.definition.parameter) + +(class_parameter + name: (identifier) @local.definition.parameter) + +(lambda_expression + parameters: (identifier) @local.definition.var) + +(binding + name: (identifier) @local.definition.var) + +(val_definition + pattern: (identifier) @local.definition.var) + +(var_definition + pattern: (identifier) @local.definition.var) + +(val_declaration + name: (identifier) @local.definition.var) + +(var_declaration + name: (identifier) @local.definition.var) + +(for_expression + enumerators: (enumerators + (enumerator + (tuple_pattern + (identifier) @local.definition.var)))) diff --git a/runtime/queries/scfg/highlights.scm b/runtime/queries/scfg/highlights.scm new file mode 100644 index 000000000..058f3e3d4 --- /dev/null +++ b/runtime/queries/scfg/highlights.scm @@ -0,0 +1,10 @@ +[ + "{" + "}" +] @punctuation.bracket + +(comment) @comment @spell + +(directive_name) @type + +(directive_params) @variable.parameter diff --git a/runtime/queries/scfg/injections.scm b/runtime/queries/scfg/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/scfg/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/scheme/folds.scm b/runtime/queries/scheme/folds.scm new file mode 100644 index 000000000..115809a77 --- /dev/null +++ b/runtime/queries/scheme/folds.scm @@ -0,0 +1,2 @@ +(program + (list) @fold) diff --git a/runtime/queries/scheme/highlights.scm b/runtime/queries/scheme/highlights.scm new file mode 100644 index 000000000..3d41e4951 --- /dev/null +++ b/runtime/queries/scheme/highlights.scm @@ -0,0 +1,161 @@ +; A highlight query can override the highlights queries before it. +; So the order is important. +; We should highlight general rules, then highlight special forms. +(number) @number + +(character) @character + +(boolean) @boolean + +(string) @string + +[ + (comment) + (block_comment) +] @comment @spell + +; highlight for datum comment +; copied from ../clojure/highlights.scm +([ + (comment) + (directive) +] @comment + (#set! priority 105)) + +(escape_sequence) @string.escape + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; variables +(symbol) @variable + +((symbol) @variable.builtin + (#any-of? @variable.builtin "..." ".")) + +; procedure +(list + . + (symbol) @function) + +; special forms +(list + "[" + (symbol)+ @variable + "]") + +(list + . + (symbol) @_f + . + (list + (symbol) @variable) + (#any-of? @_f "lambda" "λ")) + +(list + . + (symbol) @_f + . + (list + (list + (symbol) @variable)) + (#any-of? @_f + "let" "let*" "let-syntax" "let-values" "let*-values" "letrec" "letrec*" "letrec-syntax")) + +; operators +((symbol) @operator + (#any-of? @operator "+" "-" "*" "/" "=" "<=" ">=" "<" ">")) + +; keyword +((symbol) @keyword + (#any-of? @keyword + "define" "lambda" "λ" "begin" "do" "define-syntax" "and" "or" "if" "cond" "case" "when" + "unless" "else" "=>" "let" "let*" "let-syntax" "let-values" "let*-values" "letrec" "letrec*" + "letrec-syntax" "set!" "syntax-rules" "identifier-syntax" "quote" "unquote" "quote-splicing" + "quasiquote" "unquote-splicing" "delay" "assert" "library" "export" "import" "rename" "only" + "except" "prefix")) + +((symbol) @keyword.conditional + (#any-of? @keyword.conditional "if" "cond" "case" "when" "unless")) + +; quote +(quote + "'" + (symbol)) @string.special.symbol + +(list + . + (symbol) @_f + (#eq? @_f "quote")) @string.special.symbol + +; library +(list + . + (symbol) @_lib + . + (symbol) @module + (#eq? @_lib "library")) + +; builtin procedures +; procedures in R5RS and R6RS but not in R6RS-lib +((symbol) @function.builtin + (#any-of? @function.builtin + ; eq + "eqv?" "eq?" "equal?" + ; number + "number?" "complex?" "real?" "rational?" "integer?" "exact?" "inexact?" "zero?" "positive?" + "negative?" "odd?" "even?" "finite?" "infinite?" "nan?" "max" "min" "abs" "quotient" "remainder" + "modulo" "div" "div0" "mod" "mod0" "div-and-mod" "div0-and-mod0" "gcd" "lcm" "numerator" + "denominator" "floor" "ceiling" "truncate" "round" "rationalize" "exp" "log" "sin" "cos" "tan" + "asin" "acos" "atan" "sqrt" "expt" "exact-integer-sqrt" "make-rectangular" "make-polar" + "real-part" "imag-part" "magnitude" "angle" "real-valued" "rational-valued?" "integer-valued?" + "exact" "inexact" "exact->inexact" "inexact->exact" "number->string" "string->number" + ; boolean + "boolean?" "not" "boolean=?" + ; pair + "pair?" "cons" "car" "cdr" "caar" "cadr" "cdar" "cddr" "caaar" "caadr" "cadar" "caddr" "cdaar" + "cdadr" "cddar" "cdddr" "caaaar" "caaadr" "caadar" "caaddr" "cadaar" "cadadr" "caddar" "cadddr" + "cdaaar" "cdaadr" "cdadar" "cdaddr" "cddaar" "cddadr" "cdddar" "cddddr" "set-car!" "set-cdr!" + ; list + "null?" "list?" "list" "length" "append" "reverse" "list-tail" "list-ref" "map" "for-each" + "memq" "memv" "member" "assq" "assv" "assoc" + ; symbol + "symbol?" "symbol->string" "string->symbol" "symbol=?" + ; char + "char?" "char=?" "char<?" "char>?" "char<=?" "char>=?" "char-ci=?" "char-ci<?" "char-ci>?" + "char-ci<=?" "char-ci>=?" "char-alphabetic?" "char-numeric?" "char-whitespace?" + "char-upper-case?" "char-lower-case?" "char->integer" "integer->char" "char-upcase" + "char-downcase" + ; string + "string?" "make-string" "string" "string-length" "string-ref" "string-set!" "string=?" + "string-ci=?" "string<?" "string>?" "string<=?" "string>=?" "string-ci<?" "string-ci>?" + "string-ci<=?" "string-ci>=?" "substring" "string-append" "string->list" "list->string" + "string-for-each" "string-copy" "string-fill!" "string-upcase" "string-downcase" + ; vector + "vector?" "make-vector" "vector" "vector-length" "vector-ref" "vector-set!" "vector->list" + "list->vector" "vector-fill!" "vector-map" "vector-for-each" + ; bytevector + "bytevector?" "native-endianness" "make-bytevector" "bytevector-length" "bytevector=?" + "bytevector-fill!" "bytevector-copy!" "bytevector-copy" + ; error + "error" "assertion-violation" + ; control + "procedure?" "apply" "force" "call-with-current-continuation" "call/cc" "values" + "call-with-values" "dynamic-wind" "eval" "scheme-report-environment" "null-environment" + "interaction-environment" + ; IO + "call-with-input-file" "call-with-output-file" "input-port?" "output-port?" "current-input-port" + "current-output-port" "with-input-from-file" "with-output-to-file" "open-input-file" + "open-output-file" "close-input-port" "close-output-port" + ; input + "read" "read-char" "peek-char" "eof-object?" "char-ready?" + ; output + "write" "display" "newline" "write-char" + ; system + "load" "transcript-on" "transcript-off")) diff --git a/runtime/queries/scheme/injections.scm b/runtime/queries/scheme/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/scheme/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/scss/folds.scm b/runtime/queries/scss/folds.scm new file mode 100644 index 000000000..cbe41875e --- /dev/null +++ b/runtime/queries/scss/folds.scm @@ -0,0 +1 @@ +; inherits: css diff --git a/runtime/queries/scss/highlights.scm b/runtime/queries/scss/highlights.scm new file mode 100644 index 000000000..726256f8e --- /dev/null +++ b/runtime/queries/scss/highlights.scm @@ -0,0 +1,87 @@ +; inherits: css + +[ + "@at-root" + "@debug" + "@error" + "@extend" + "@forward" + "@mixin" + "@use" + "@warn" +] @keyword + +"@function" @keyword.function + +"@return" @keyword.return + +"@include" @keyword.import + +[ + "@while" + "@each" + "@for" + "from" + "through" + "in" +] @keyword.repeat + +(single_line_comment) @comment @spell + +(function_name) @function + +[ + ">=" + "<=" +] @operator + +(mixin_statement + (name) @function) + +(mixin_statement + (parameters + (parameter) @variable.parameter)) + +(function_statement + (name) @function) + +(function_statement + (parameters + (parameter) @variable.parameter)) + +(plain_value) @string + +(keyword_query) @function + +(identifier) @variable + +(variable_name) @variable + +(each_statement + (key) @variable.parameter) + +(each_statement + (value) @variable.parameter) + +(each_statement + (variable_value) @variable.parameter) + +(for_statement + (variable) @variable.parameter) + +(for_statement + (_ + (variable_value) @variable.parameter)) + +(argument) @variable.parameter + +(arguments + (variable_value) @variable.parameter) + +[ + "[" + "]" +] @punctuation.bracket + +(include_statement + (identifier) @function) diff --git a/runtime/queries/scss/indents.scm b/runtime/queries/scss/indents.scm new file mode 100644 index 000000000..3d54a0467 --- /dev/null +++ b/runtime/queries/scss/indents.scm @@ -0,0 +1,7 @@ +; inherits: css + +[ + (mixin_statement) + (while_statement) + (each_statement) +] @indent.begin diff --git a/runtime/queries/scss/injections.scm b/runtime/queries/scss/injections.scm new file mode 100644 index 000000000..c3a252a79 --- /dev/null +++ b/runtime/queries/scss/injections.scm @@ -0,0 +1,2 @@ +((single_line_comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/sflog/highlights.scm b/runtime/queries/sflog/highlights.scm new file mode 100644 index 000000000..8eeee5d24 --- /dev/null +++ b/runtime/queries/sflog/highlights.scm @@ -0,0 +1,48 @@ +; highlights.scm +[ + "|" + "|[" + "]" + "(" + ")" + "|(" + ")|" +] @punctuation.bracket + +[ + "," + ";" + ":" +] @punctuation.delimiter + +"EXTERNAL" @keyword + +"out of" @property + +(number) @number + +(identifier) @variable + +(version) @string.special + +(anonymous_block) @string + +(limit) @property + +(time) @function + +(limit + (identifier) @string) + +(event_detail + (event_detail_value) @string) + +(log_level_setting + (component) @type) + +(log_level_setting + (log_level) @constant) + +(log_entry + (event_identifier + (identifier) @type)) diff --git a/runtime/queries/slang/folds.scm b/runtime/queries/slang/folds.scm new file mode 100644 index 000000000..e0ae6853e --- /dev/null +++ b/runtime/queries/slang/folds.scm @@ -0,0 +1,9 @@ +; inherits: hlsl + +[ + (interface_specifier) + (extension_specifier) + (property_declaration) + (subscript_declaration) + (init_declaration) +] @fold diff --git a/runtime/queries/slang/highlights.scm b/runtime/queries/slang/highlights.scm new file mode 100644 index 000000000..166964c62 --- /dev/null +++ b/runtime/queries/slang/highlights.scm @@ -0,0 +1,350 @@ +; inherits: c + +; cpp +((identifier) @variable.member + (#lua-match? @variable.member "^m_.*$")) + +(parameter_declaration + declarator: (reference_declarator) @variable.parameter) + +; function(Foo ...foo) +(variadic_parameter_declaration + declarator: (variadic_declarator + (_) @variable.parameter)) + +; int foo = 0 +(optional_parameter_declaration + declarator: (_) @variable.parameter) + +;(field_expression) @variable.parameter ;; How to highlight this? +((field_expression + (field_identifier) @function.method) @_parent + (#has-parent? @_parent template_method function_declarator)) + +(field_declaration + (field_identifier) @variable.member) + +(field_initializer + (field_identifier) @property) + +(function_declarator + declarator: (field_identifier) @function.method) + +(concept_definition + name: (identifier) @type.definition) + +(alias_declaration + name: (type_identifier) @type.definition) + +(namespace_identifier) @module + +((namespace_identifier) @type + (#lua-match? @type "^[%u]")) + +(case_statement + value: (qualified_identifier + (identifier) @constant)) + +(using_declaration + . + "using" + . + "namespace" + . + [ + (qualified_identifier) + (identifier) + ] @module) + +(destructor_name + (identifier) @function.method) + +; functions +(function_declarator + (qualified_identifier + (identifier) @function)) + +(function_declarator + (qualified_identifier + (qualified_identifier + (identifier) @function))) + +(function_declarator + (qualified_identifier + (qualified_identifier + (qualified_identifier + (identifier) @function)))) + +((qualified_identifier + (qualified_identifier + (qualified_identifier + (qualified_identifier + (identifier) @function)))) @_parent + (#has-ancestor? @_parent function_declarator)) + +(function_declarator + (template_function + (identifier) @function)) + +(operator_name) @function + +"operator" @function + +"static_assert" @function.builtin + +(call_expression + (qualified_identifier + (identifier) @function.call)) + +(call_expression + (qualified_identifier + (qualified_identifier + (identifier) @function.call))) + +(call_expression + (qualified_identifier + (qualified_identifier + (qualified_identifier + (identifier) @function.call)))) + +((qualified_identifier + (qualified_identifier + (qualified_identifier + (qualified_identifier + (identifier) @function.call)))) @_parent + (#has-ancestor? @_parent call_expression)) + +(call_expression + (template_function + (identifier) @function.call)) + +(call_expression + (qualified_identifier + (template_function + (identifier) @function.call))) + +(call_expression + (qualified_identifier + (qualified_identifier + (template_function + (identifier) @function.call)))) + +(call_expression + (qualified_identifier + (qualified_identifier + (qualified_identifier + (template_function + (identifier) @function.call))))) + +((qualified_identifier + (qualified_identifier + (qualified_identifier + (qualified_identifier + (template_function + (identifier) @function.call))))) @_parent + (#has-ancestor? @_parent call_expression)) + +; methods +(function_declarator + (template_method + (field_identifier) @function.method)) + +(call_expression + (field_expression + (field_identifier) @function.method.call)) + +; constructors +((function_declarator + (qualified_identifier + (identifier) @constructor)) + (#lua-match? @constructor "^%u")) + +((call_expression + function: (identifier) @constructor) + (#lua-match? @constructor "^%u")) + +((call_expression + function: (qualified_identifier + name: (identifier) @constructor)) + (#lua-match? @constructor "^%u")) + +((call_expression + function: (field_expression + field: (field_identifier) @constructor)) + (#lua-match? @constructor "^%u")) + +; constructing a type in an initializer list: Constructor (): **SuperType (1)** +((field_initializer + (field_identifier) @constructor + (argument_list)) + (#lua-match? @constructor "^%u")) + +; Constants +(this) @variable.builtin + +(null + "nullptr" @constant.builtin) + +(true) @boolean + +(false) @boolean + +; Literals +(raw_string_literal) @string + +; Keywords +[ + "try" + "catch" + "noexcept" + "throw" +] @keyword.exception + +[ + "decltype" + "explicit" + "friend" + "override" + "using" + "requires" + "constexpr" +] @keyword + +[ + "class" + "namespace" + "template" + "typename" + "concept" +] @keyword.type + +[ + "co_await" + "co_yield" + "co_return" +] @keyword.coroutine + +[ + "public" + "private" + "protected" + "final" + "virtual" +] @keyword.modifier + +[ + "new" + "delete" + "xor" + "bitand" + "bitor" + "compl" + "not" + "xor_eq" + "and_eq" + "or_eq" + "not_eq" + "and" + "or" +] @keyword.operator + +"<=>" @operator + +"::" @punctuation.delimiter + +(template_argument_list + [ + "<" + ">" + ] @punctuation.bracket) + +(template_parameter_list + [ + "<" + ">" + ] @punctuation.bracket) + +(literal_suffix) @operator + +; hlsl +[ + "in" + "out" + "inout" + "uniform" + "shared" + "groupshared" + "discard" + "cbuffer" + "row_major" + "column_major" + "globallycoherent" + "centroid" + "noperspective" + "nointerpolation" + "sample" + "linear" + "snorm" + "unorm" + "point" + "line" + "triangleadj" + "lineadj" + "triangle" +] @keyword.modifier + +((identifier) @variable.builtin + (#lua-match? @variable.builtin "^SV_")) + +(hlsl_attribute) @attribute + +(hlsl_attribute + [ + "[" + "]" + ] @attribute) + +[ + "var" + "let" + "This" +] @type.builtin + +[ + "interface" + "extension" + "property" + "associatedtype" + "where" +] @keyword + +"__init" @constructor + +[ + "__subscript" + "get" + "set" +] @function.builtin + +(interface_requirements + (identifier) @type) + +(binary_expression + [ + "is" + "as" + ] + right: (identifier) @type) + +[ + "as" + "is" +] @keyword.operator + +[ + "__exported" + "import" +] @keyword.import + +(property_declaration + (identifier) @property) diff --git a/runtime/queries/slang/indents.scm b/runtime/queries/slang/indents.scm new file mode 100644 index 000000000..6175ac5bc --- /dev/null +++ b/runtime/queries/slang/indents.scm @@ -0,0 +1,6 @@ +; inherits: hlsl + +[ + (interface_specifier) + (extension_specifier) +] @indent.begin diff --git a/runtime/queries/slang/injections.scm b/runtime/queries/slang/injections.scm new file mode 100644 index 000000000..2fd39cba0 --- /dev/null +++ b/runtime/queries/slang/injections.scm @@ -0,0 +1,5 @@ +((preproc_arg) @injection.content + (#set! injection.language "slang")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/slang/locals.scm b/runtime/queries/slang/locals.scm new file mode 100644 index 000000000..647bd1fef --- /dev/null +++ b/runtime/queries/slang/locals.scm @@ -0,0 +1 @@ +; inherits: hlsl diff --git a/runtime/queries/slim/folds.scm b/runtime/queries/slim/folds.scm new file mode 100644 index 000000000..aabc67617 --- /dev/null +++ b/runtime/queries/slim/folds.scm @@ -0,0 +1 @@ +(child) @fold diff --git a/runtime/queries/slim/highlights.scm b/runtime/queries/slim/highlights.scm new file mode 100644 index 000000000..e219932f6 --- /dev/null +++ b/runtime/queries/slim/highlights.scm @@ -0,0 +1,82 @@ +(comment) @comment @spell + +(tag_id) @keyword.function + +(tag_class) @keyword.type + +(injector) @keyword.import + +(directive_sign) @keyword.directive + +[ + (string_start) + (string_content) + (string_end) +] @string + +(bracket) @punctuation.bracket + +[ + "#{" + "}" +] @punctuation.special + +(delimiter) @tag.delimiter + +(parameter_name) @variable.parameter + +(parameter_value) @tag.attribute + +[ + (text_inline) + (text_block) +] @markup.raw.block + +; Markup tags +; https://developer.mozilla.org/en-US/docs/Web/HTML/Element +(tag_name) @tag + +((tag_name) @tag.builtin + (#any-of? @tag.builtin + "doctype" "html" "head" "title" "base" "link" "meta" "style" "body" "article" "section" "nav" + "aside" "hgroup" "footer" "address" "p" "hr" "pre" "blockquote" "menu" "figure" "figcaption" + "main" "div" "small" "s" "cite" "q" "dfn" "abbr" "rt" "rp" "data" "time" "code" "var" "samp" + "kbd" "sub" "sup" "u" "mark" "bdi" "bdo" "span" "br" "wbr" "ins" "del" "picture" "source" "img" + "iframe" "embed" "object" "param" "video" "audio" "track" "map" "area" "table" "caption" + "colgroup" "col" "tbody" "thead" "tfoot" "tr" "td" "th" "form" "label" "input" "button" "select" + "datalist" "optgroup" "option" "textarea" "output" "progress" "meter" "fieldset" "legend" + "details" "summary" "dialog" "script" "noscript" "template" "slot" "canvas")) + +((tag_name) @markup.strong + (#any-of? @markup.strong "b" "strong")) + +((tag_name) @markup.italic + (#any-of? @markup.italic "i" "em")) + +((tag_name) @markup.link + (#any-of? @markup.link "a")) + +; Headings +((tag_name) @markup.heading + (#any-of? @markup.heading "header")) + +((tag_name) @markup.heading.1 + (#any-of? @markup.heading.1 "h1")) + +((tag_name) @markup.heading.2 + (#any-of? @markup.heading.2 "h2")) + +((tag_name) @markup.heading.3 + (#any-of? @markup.heading.3 "h3")) + +((tag_name) @markup.heading.4 + (#any-of? @markup.heading.4 "h4")) + +((tag_name) @markup.heading.5 + (#any-of? @markup.heading.5 "h5")) + +((tag_name) @markup.heading.6 + (#any-of? @markup.heading.6 "h6")) + +((tag_name) @markup.list + (#any-of? @markup.list "ul" "ol" "li" "dl" "dt" "dd")) diff --git a/runtime/queries/slim/indents.scm b/runtime/queries/slim/indents.scm new file mode 100644 index 000000000..a06a75867 --- /dev/null +++ b/runtime/queries/slim/indents.scm @@ -0,0 +1,4 @@ +(tag) @indent.begin + +((tag) @indent.zero + (#any-of? @indent.zero "doctype" "html")) diff --git a/runtime/queries/slim/injections.scm b/runtime/queries/slim/injections.scm new file mode 100644 index 000000000..3bee13931 --- /dev/null +++ b/runtime/queries/slim/injections.scm @@ -0,0 +1,39 @@ +((ruby_inline) @injection.content + (#set! injection.language "ruby")) + +((ruby_lang) @injection.content + (#set! injection.language "ruby") + (#set! injection.combined)) + +((javascript_lang) @injection.content + (#set! injection.language "javascript") + (#set! injection.combined)) + +((css_lang) @injection.content + (#set! injection.language "css") + (#set! injection.combined)) + +((sass_lang) @injection.content + (#set! injection.language "sass") + (#set! injection.combined)) + +((scss_lang) @injection.content + (#set! injection.language "scss") + (#set! injection.combined)) + +((less_lang) @injection.content + (#set! injection.language "less") + (#set! injection.combined)) + +((scss_lang) @injection.content + (#set! injection.language "scss") + (#set! injection.combined)) + +((markdown_lang) @injection.content + (#set! injection.language "markdown")) + +((rdoc_lang) @injection.content + (#set! injection.language "rdoc")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/slim/locals.scm b/runtime/queries/slim/locals.scm new file mode 100644 index 000000000..e9f0b0079 --- /dev/null +++ b/runtime/queries/slim/locals.scm @@ -0,0 +1,7 @@ +(child) @local.scope + +(tag_name) @local.definition.function + +(tag_class) @local.definition.parameter + +(tag_id) @local.definition.constant diff --git a/runtime/queries/slint/folds.scm b/runtime/queries/slint/folds.scm new file mode 100644 index 000000000..4c5b1307a --- /dev/null +++ b/runtime/queries/slint/folds.scm @@ -0,0 +1,11 @@ +[ + (anon_struct_block) + (block) + (callback_event) + (component) + (enum_block) + (function_definition) + (global_definition) + (imperative_block) + (struct_block) +] @fold diff --git a/runtime/queries/slint/highlights.scm b/runtime/queries/slint/highlights.scm new file mode 100644 index 000000000..1b56b1c0d --- /dev/null +++ b/runtime/queries/slint/highlights.scm @@ -0,0 +1,263 @@ +(comment) @comment @spell + +; Different types: +(string_value) @string @spell + +(escape_sequence) @string.escape + +(color_value) @constant + +[ + (children_identifier) + (easing_kind_identifier) +] @constant.builtin + +(bool_value) @boolean + +[ + (int_value) + (physical_length_value) +] @number + +[ + (angle_value) + (duration_value) + (float_value) + (length_value) + (percent_value) + (relative_font_size_value) +] @number.float + +(purity) @keyword.modifier + +(function_visibility) @keyword.modifier + +(property_visibility) @keyword.modifier + +(builtin_type_identifier) @type.builtin + +(reference_identifier) @variable.builtin + +(type + [ + (type_list) + (user_type_identifier) + (anon_struct_block) + ]) @type + +(user_type_identifier) @type + +(enum_block + (user_type_identifier) @constant) + +; Functions and callbacks +(argument) @variable.parameter + +(function_call + name: (_) @function.call) + +; definitions +(callback + name: (_) @function) + +(callback_alias + name: (_) @function) + +(callback_event + name: (simple_identifier) @function.call) + +(component + id: (_) @variable) + +(enum_definition + name: (_) @type) + +(function_definition + name: (_) @function) + +(struct_definition + name: (_) @type) + +(typed_identifier + type: (_) @type) + +; Operators +(binary_expression + op: (_) @operator) + +(unary_expression + op: (_) @operator) + +[ + (comparison_operator) + (mult_prec_operator) + (add_prec_operator) + (unary_prec_operator) + (assignment_prec_operator) +] @operator + +[ + ":=" + "=>" + "->" + "<=>" +] @operator + +; Punctuation +[ + ";" + "." + "," + ":" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(property + [ + "<" + ">" + ] @punctuation.bracket) + +; Properties, Variables and Constants: +(component + id: (simple_identifier) @constant) + +(property + name: (simple_identifier) @property) + +(binding_alias + name: (simple_identifier) @property) + +(binding + name: (simple_identifier) @property) + +(struct_block + (simple_identifier) @variable.member) + +(anon_struct_block + (simple_identifier) @variable.member) + +(property_assignment + property: (simple_identifier) @property) + +(states_definition + name: (simple_identifier) @variable) + +(callback + name: (simple_identifier) @variable) + +(typed_identifier + name: (_) @variable) + +(simple_indexed_identifier + name: (simple_identifier) @variable + index_var: (simple_identifier) @variable) + +(expression + (simple_identifier) @variable) + +(member_access + member: (expression + (simple_identifier) @property)) + +(states_definition + name: (simple_identifier) @constant) + +; Attributes: +[ + (linear_gradient_identifier) + (radial_gradient_identifier) + (radial_gradient_kind) +] @attribute + +(image_call + "@image-url" @attribute) + +(tr + "@tr" @attribute) + +; Keywords: +(animate_option_identifier) @keyword + +(export) @keyword.import + +(if_statement + "if" @keyword.conditional) + +(if_expr + [ + "if" + "else" + ] @keyword.conditional) + +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +(animate_statement + "animate" @keyword) + +(callback + "callback" @keyword) + +(component_definition + [ + "component" + "inherits" + ] @keyword) + +(enum_definition + "enum" @keyword.type) + +(for_loop + [ + "for" + "in" + ] @keyword.repeat) + +(function_definition + "function" @keyword.function) + +(global_definition + "global" @keyword) + +(imperative_block + "return" @keyword.return) + +(import_statement + [ + "import" + "from" + ] @keyword.import) + +(import_type + "as" @keyword.import) + +(property + "property" @keyword) + +(states_definition + [ + "states" + "when" + ] @keyword) + +(struct_definition + "struct" @keyword.type) + +(transitions_definition + [ + "transitions" + "in" + "out" + ] @keyword) diff --git a/runtime/queries/slint/indents.scm b/runtime/queries/slint/indents.scm new file mode 100644 index 000000000..d6bdeacde --- /dev/null +++ b/runtime/queries/slint/indents.scm @@ -0,0 +1,26 @@ +[ + (arguments) + (block) + (enum_block) + (global_block) + (imperative_block) + (struct_block) + (typed_identifier) +] @indent.begin + +([ + (block) + (enum_block) + (global_block) + (imperative_block) + (struct_block) +] + "}" @indent.end) + +([ + (arguments) + (typed_identifier) +] + ")" @indent.end) + +(string_value) @indent.auto diff --git a/runtime/queries/slint/injections.scm b/runtime/queries/slint/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/slint/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/slint/locals.scm b/runtime/queries/slint/locals.scm new file mode 100644 index 000000000..7e895a6b5 --- /dev/null +++ b/runtime/queries/slint/locals.scm @@ -0,0 +1,117 @@ +[ + (anon_struct_block) + (block) + (callback_event) + (component) + (enum_block) + (function_definition) + (global_definition) + (imperative_block) + (struct_block) +] @local.scope + +(anon_struct_block + (_) @local.definition.field) + +(argument) @local.definition.var + +(callback + name: (_) @local.definition.field) + +(component_definition + name: (_) @local.definition.type) + +(enum_definition + name: (_) @local.definition.type) + +(enum_block + (_) @local.definition.field) + +(function_definition + name: (_) @local.definition.function) + +(global_definition + name: (_) @local.definition.type) + +(import_type + import_name: (_) + !local_name) @local.definition.import + +(import_type + import_name: (_) + local_name: (_) @local.definition.import) + +(property + name: (_) @local.definition.field) + +(struct_block + (_) @local.definition.field) + +(struct_definition + name: (_) @local.definition.type) + +(typed_identifier + name: (_) @local.definition.var) + +(argument + (_) @local.reference) + +(binary_expression + left: (_) @local.reference) + +(binary_expression + right: (_) @local.reference) + +(callback_event + name: (_) @local.reference) + +(component + type: (_) @local.reference + (#set! reference.kind "type")) + +(component_definition + base_type: (_) @local.reference + (#set! reference.kind "type")) + +(function_call + name: (_) @local.reference) + +(index_op + index: (_) @local.reference) + +(index_op + left: (_) @local.reference) + +(member_access + base: (_) @local.reference) + +(member_access + member: (_) @local.reference) + +(parens_op + left: (_) @local.reference) + +(property + type: (_) @local.reference + (#set! reference.kind "type")) + +(property_assignment + property: (_) @local.reference + (#set! reference.kind "field")) + +(property_assignment + value: (_) @local.reference) + +(struct_block + (_) @local.reference + (#set! reference.kind "type")) + +(tr + percent: (_) @local.reference) + +(typed_identifier + type: (_) @local.reference + (#set! reference.kind "type")) + +(unary_expression + left: (_) @local.reference) diff --git a/runtime/queries/smali/folds.scm b/runtime/queries/smali/folds.scm new file mode 100644 index 000000000..c2062e5ef --- /dev/null +++ b/runtime/queries/smali/folds.scm @@ -0,0 +1,12 @@ +[ + (annotation_directive) + (array_data_directive) + (field_definition) + (method_definition) + (packed_switch_directive) + (param_directive) + (parameter_directive) + (sparse_switch_directive) + (subannotation_directive) + (list) +] @fold diff --git a/runtime/queries/smali/highlights.scm b/runtime/queries/smali/highlights.scm new file mode 100644 index 000000000..161b732b2 --- /dev/null +++ b/runtime/queries/smali/highlights.scm @@ -0,0 +1,226 @@ +; Types +(class_identifier + (identifier) @type) + +(primitive_type) @type.builtin + +((class_identifier + . + (identifier) @_first @type.builtin + (identifier) @type.builtin) + (#any-of? @_first "android" "dalvik" "java" "kotlinx")) + +((class_identifier + . + (identifier) @_first @type.builtin + . + (identifier) @_second @type.builtin + (identifier) @type.builtin) + (#eq? @_first "com") + (#any-of? @_second "android" "google")) + +; Methods +(method_definition + (method_signature + (method_identifier) @function.method)) + +(expression + (opcode) @_invoke + (body + (full_method_signature + (method_signature + (method_identifier) @function.method.call))) + (#lua-match? @_invoke "^invoke")) + +(method_handle + (full_method_signature + (method_signature + (method_identifier) @function.method.call))) + +(custom_invoke + . + (identifier) @function.method.call + (method_signature + (method_identifier) @function.method.call)) + +(annotation_value + (body + (method_signature + (method_identifier) @function.method.call))) + +(annotation_value + (body + (full_method_signature + (method_signature + (method_identifier) @function.method.call)))) + +(field_definition + (body + (method_signature + (method_identifier) @function.method.call))) + +(field_definition + (body + (full_method_signature + (method_signature + (method_identifier) @function.method.call)))) + +((method_identifier) @constructor + (#any-of? @constructor "<init>" "<clinit>")) + +"constructor" @constructor + +; Fields +(field_identifier) @variable.member + +(annotation_key) @variable.member + +((field_identifier) @constant + (#lua-match? @constant "^[%u_]*$")) + +; Variables +(variable) @variable.builtin + +(local_directive + (identifier) @variable) + +; Parameters +(parameter) @variable.parameter.builtin + +(param_identifier) @variable.parameter + +; Labels +[ + (label) + (jmp_label) +] @label + +; Operators +(opcode) @keyword.operator + +((opcode) @keyword.return + (#lua-match? @keyword.return "^return")) + +((opcode) @keyword.conditional + (#lua-match? @keyword.conditional "^if")) + +((opcode) @keyword.conditional + (#lua-match? @keyword.conditional "^cmp")) + +((opcode) @keyword.exception + (#lua-match? @keyword.exception "^throw")) + +((opcode) @comment + (#eq? @comment "nop")) ; haha, anyone get it? ;) + +[ + "=" + ".." +] @operator + +; Keywords +[ + ".class" + ".super" + ".implements" + ".field" + ".end field" + ".annotation" + ".end annotation" + ".subannotation" + ".end subannotation" + ".param" + ".end param" + ".parameter" + ".end parameter" + ".line" + ".locals" + ".local" + ".end local" + ".restart local" + ".registers" + ".packed-switch" + ".end packed-switch" + ".sparse-switch" + ".end sparse-switch" + ".array-data" + ".end array-data" + ".enum" + (prologue_directive) + (epilogue_directive) +] @keyword + +".source" @keyword.import + +[ + ".method" + ".end method" +] @keyword.function + +[ + ".catch" + ".catchall" +] @keyword.exception + +; Literals +(string) @string + +(source_directive + (string + "\"" + _ @string.special.url + "\"")) + +(escape_sequence) @string.escape + +(character) @character + +"L" @character.special + +(number) @number + +[ + (float) + (NaN) + (Infinity) +] @number.float + +(boolean) @boolean + +(null) @constant.builtin + +; Misc +(annotation_visibility) @keyword.modifier + +(access_modifier) @keyword.modifier + +(array_type + "[" @punctuation.special) + +[ + "{" + "}" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "->" + "," + ":" + ";" + "@" + "/" +] @punctuation.delimiter + +(line_directive + (number) @string.special) + +; Comments +(comment) @comment @spell + +(class_definition + (comment) @comment.documentation) diff --git a/runtime/queries/smali/indents.scm b/runtime/queries/smali/indents.scm new file mode 100644 index 000000000..b4f37ddb4 --- /dev/null +++ b/runtime/queries/smali/indents.scm @@ -0,0 +1,35 @@ +[ + (annotation_directive) + (array_data_directive) + (field_definition) + (method_definition) + (packed_switch_directive) + (param_directive) + (parameter_directive) + (sparse_switch_directive) + (subannotation_directive) + (list) +] @indent.begin + +[ + ".end annotation" + ".end array-data" + ".end field" + ".end method" + ".end packed-switch" + ".end param" + ".end parameter" + ".end sparse-switch" + ".end subannotation" + "}" +] @indent.end @indent.branch + +[ + "{" + "}" +] @indent.branch + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/runtime/queries/smali/injections.scm b/runtime/queries/smali/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/smali/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/smali/locals.scm b/runtime/queries/smali/locals.scm new file mode 100644 index 000000000..a34b799ba --- /dev/null +++ b/runtime/queries/smali/locals.scm @@ -0,0 +1,43 @@ +[ + (class_directive) + (expression) + (annotation_directive) + (array_data_directive) + (method_definition) + (packed_switch_directive) + (sparse_switch_directive) + (subannotation_directive) +] @local.scope + +[ + (identifier) + (class_identifier) + (label) + (jmp_label) +] @local.reference + +(enum_reference + (field_identifier) @local.definition.enum) + +((field_definition + (access_modifiers) @_mod + (field_identifier) @local.definition.enum) + (#eq? @_mod "enum")) + +(field_definition + (field_identifier) @local.definition.field + (field_type) @local.definition.associated) + +(annotation_key) @local.definition.field + +(method_definition + (method_signature + (method_identifier) @local.definition.method)) + +(param_identifier) @local.definition.parameter + +(annotation_directive + (class_identifier) @local.definition.type) + +(class_directive + (class_identifier) @local.definition.type) diff --git a/runtime/queries/smithy/highlights.scm b/runtime/queries/smithy/highlights.scm new file mode 100644 index 000000000..14e1f20fd --- /dev/null +++ b/runtime/queries/smithy/highlights.scm @@ -0,0 +1,114 @@ +; Preproc +(control_key) @keyword.directive + +; Namespace +(namespace) @module + +; Includes +"use" @keyword.import + +; Builtins +(primitive) @type.builtin + +[ + "enum" + "intEnum" + "list" + "map" + "set" + "structure" + "union" + "namespace" + "service" + "operation" + "resource" +] @keyword.type + +; Fields (Members) +; (field) @variable.member +(key_identifier) @variable.member + +(shape_member + (field) @variable.member) + +(operation_field) @variable.member + +(operation_error_field) @variable.member + +; Constants +(enum_member + (enum_field) @constant) + +; Types +(identifier) @type + +(structure_resource + (shape_id) @type) + +; Attributes +(mixins + (shape_id) @attribute) + +(trait_statement + (shape_id + (#set! priority 105)) @attribute) + +; Operators +[ + "@" + "-" + "=" + ":=" +] @operator + +; Keywords +[ + "metadata" + "apply" + "for" + "with" +] @keyword + +; Literals +(string) @string + +(escape_sequence) @string.escape + +(number) @number + +(float) @number.float + +(boolean) @boolean + +(null) @constant.builtin + +; Misc +[ + "$" + "#" +] @punctuation.special + +[ + "{" + "}" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + ":" + "." +] @punctuation.delimiter + +; Comments +(comment) @comment @spell + +(documentation_comment) @comment.documentation @spell diff --git a/runtime/queries/smithy/injections.scm b/runtime/queries/smithy/injections.scm new file mode 100644 index 000000000..cb85ecaa1 --- /dev/null +++ b/runtime/queries/smithy/injections.scm @@ -0,0 +1,5 @@ +([ + (comment) + (documentation_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/snakemake/folds.scm b/runtime/queries/snakemake/folds.scm new file mode 100644 index 000000000..d154f3cde --- /dev/null +++ b/runtime/queries/snakemake/folds.scm @@ -0,0 +1,8 @@ +; inherits: python + +[ + (rule_definition) + (rule_inheritance) + (module_definition) + (checkpoint_definition) +] @fold diff --git a/runtime/queries/snakemake/highlights.scm b/runtime/queries/snakemake/highlights.scm new file mode 100644 index 000000000..8781b405c --- /dev/null +++ b/runtime/queries/snakemake/highlights.scm @@ -0,0 +1,82 @@ +; inherits: python + +; Compound directives +[ + "rule" + "checkpoint" + "module" +] @keyword + +; Top level directives (eg. configfile, include) +(module + (directive + name: _ @keyword)) + +; Subordinate directives (eg. input, output) +body: (_ + (directive + name: _ @label)) + +; rule/module/checkpoint names +(rule_definition + name: (identifier) @type) + +(module_definition + name: (identifier) @type) + +(checkpoint_definition + name: (identifier) @type) + +; Rule imports +(rule_import + [ + "use" + "rule" + "from" + "exclude" + "as" + "with" + ] @keyword.import) + +; Rule inheritance +(rule_inheritance + "use" @keyword + "rule" @keyword + "with" @keyword) + +; Wildcard names +(wildcard + (identifier) @variable) + +(wildcard + (flag) @variable.parameter.builtin) + +; builtin variables +((identifier) @variable.builtin + (#any-of? @variable.builtin "checkpoints" "config" "gather" "rules" "scatter" "workflow")) + +; References to directive labels in wildcard interpolations +; the #any-of? queries are moved above the #has-ancestor? queries to +; short-circuit the potentially expensive tree traversal, if possible +; see: +; https://github.com/nvim-treesitter/nvim-treesitter/pull/4302#issuecomment-1685789790 +; directive labels in wildcard context +((wildcard + (identifier) @label) + (#any-of? @label "input" "log" "output" "params" "resources" "threads" "wildcards")) + +((wildcard + (attribute + object: (identifier) @label)) + (#any-of? @label "input" "log" "output" "params" "resources" "threads" "wildcards")) + +((wildcard + (subscript + value: (identifier) @label)) + (#any-of? @label "input" "log" "output" "params" "resources" "threads" "wildcards")) + +; directive labels in block context (eg. within 'run:') +((identifier) @label + (#any-of? @label "input" "log" "output" "params" "resources" "threads" "wildcards") + (#has-ancestor? @label "directive") + (#has-ancestor? @label "block")) diff --git a/runtime/queries/snakemake/indents.scm b/runtime/queries/snakemake/indents.scm new file mode 100644 index 000000000..140b7fb3c --- /dev/null +++ b/runtime/queries/snakemake/indents.scm @@ -0,0 +1,25 @@ +; inherits: python + +((rule_definition) @indent.begin + (#set! indent.immediate 1)) + +((checkpoint_definition) @indent.begin + (#set! indent.immediate 1)) + +((rule_inheritance) @indent.begin + (#set! indent.immediate 1)) + +((rule_import + "with" + ":") @indent.begin + (#set! indent.immediate 1)) + +((module_definition) @indent.begin + (#set! indent.immediate 1)) + +((directive) @indent.begin + (#set! indent.immediate 1)) + +; end indentation after last parameter node (no following ',') +(directive_parameters + (_) @indent.end .) diff --git a/runtime/queries/snakemake/injections.scm b/runtime/queries/snakemake/injections.scm new file mode 100644 index 000000000..fa56daabb --- /dev/null +++ b/runtime/queries/snakemake/injections.scm @@ -0,0 +1,5 @@ +; inherits: python + +(wildcard + (constraint) @injection.content + (#set! injection.language "regex")) diff --git a/runtime/queries/snakemake/locals.scm b/runtime/queries/snakemake/locals.scm new file mode 100644 index 000000000..219f23347 --- /dev/null +++ b/runtime/queries/snakemake/locals.scm @@ -0,0 +1,4 @@ +; inherits: python + +(rule_definition + name: (identifier) @local.definition.type) @local.scope diff --git a/runtime/queries/solidity/folds.scm b/runtime/queries/solidity/folds.scm new file mode 100644 index 000000000..7e3cbdec9 --- /dev/null +++ b/runtime/queries/solidity/folds.scm @@ -0,0 +1,20 @@ +[ + (error_declaration) + (contract_body) + (struct_declaration) + (enum_declaration) + (event_definition) + (assembly_statement) + (block_statement) + (if_statement) + (for_statement) + (while_statement) + (yul_block) + (function_body) + (call_expression) + (inline_array_expression) + (tuple_expression) + (struct_expression) + (comment) + (emit_statement) +] @fold diff --git a/runtime/queries/solidity/highlights.scm b/runtime/queries/solidity/highlights.scm new file mode 100644 index 000000000..ca6988edb --- /dev/null +++ b/runtime/queries/solidity/highlights.scm @@ -0,0 +1,315 @@ +; Pragma +[ + "pragma" + "solidity" +] @keyword.directive + +(solidity_pragma_token + "||" @string.special.symbol) + +(solidity_pragma_token + "-" @string.special.symbol) + +(solidity_version_comparison_operator) @operator + +(solidity_version) @string.special + +; Literals +[ + (string) + (yul_string_literal) +] @string + +(hex_string_literal + "hex" @string.special.symbol + (_) @string) + +(unicode_string_literal + "unicode" @string.special.symbol + (_) @string) + +[ + (number_literal) + (yul_decimal_number) + (yul_hex_number) +] @number + +(yul_boolean) @boolean + +; Variables +[ + (identifier) + (yul_identifier) +] @variable + +; Types +(type_name + (identifier) @type) + +(type_name + (user_defined_type + (identifier) @type)) + +(type_name + "mapping" @function.builtin) + +[ + (primitive_type) + (number_unit) +] @type.builtin + +(contract_declaration + name: (identifier) @type) + +(struct_declaration + name: (identifier) @type) + +(struct_member + name: (identifier) @variable.member) + +(enum_declaration + name: (identifier) @type) + +(emit_statement + . + (expression + (identifier)) @type) + +; Handles ContractA, ContractB in function foo() override(ContractA, contractB) {} +(override_specifier + (user_defined_type) @type) + +; Functions and parameters +(function_definition + name: (identifier) @function) + +(modifier_definition + name: (identifier) @function) + +(yul_evm_builtin) @function.builtin + +; Use constructor coloring for special functions +(constructor_definition + "constructor" @constructor) + +(modifier_invocation + (identifier) @function) + +; Handles expressions like structVariable.g(); +(call_expression + . + (expression + (member_expression + (identifier) @function.method.call))) + +; Handles expressions like g(); +(call_expression + . + (expression + (identifier) @function.call)) + +; Function parameters +(event_parameter + name: (_) @variable.parameter) + +(parameter + name: (_) @variable.parameter) + +; Yul functions +(yul_function_call + function: (yul_identifier) @function.call) + +; Yul function parameters +(yul_function_definition + . + (yul_identifier) @function + (yul_identifier) @variable.parameter) + +(meta_type_expression + "type" @keyword) + +(member_expression + property: (_) @variable.member) + +(call_struct_argument + name: (_) @variable.member) + +(struct_field_assignment + name: (identifier) @variable.member) + +(enum_value) @constant + +; Keywords +[ + "abstract" + "library" + "is" + "event" + "assembly" + "emit" + "override" + "modifier" + "var" + "let" + "emit" + "error" + "fallback" + "receive" + (virtual) +] @keyword + +[ + "enum" + "struct" + "contract" + "interface" +] @keyword.type + +; FIXME: update grammar +; (block_statement "unchecked" @keyword) +(event_parameter + "indexed" @keyword) + +[ + "public" + "internal" + "private" + "external" + "pure" + "view" + "payable" + (immutable) +] @keyword.modifier + +[ + "memory" + "storage" + "calldata" + "constant" +] @keyword.modifier + +[ + "for" + "while" + "do" + "break" + "continue" +] @keyword.repeat + +[ + "if" + "else" + "switch" + "case" + "default" +] @keyword.conditional + +(ternary_expression + "?" @keyword.conditional.ternary + ":" @keyword.conditional.ternary) + +[ + "try" + "catch" + "revert" +] @keyword.exception + +[ + "return" + "returns" + (yul_leave) +] @keyword.return + +"function" @keyword.function + +[ + "import" + "using" +] @keyword.import + +(import_directive + "as" @keyword.import) + +(import_directive + "from" @keyword.import) + +((import_directive + source: (string) @string.special.path) + (#offset! @string.special.path 0 1 0 -1)) + +; Punctuation +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "." + "," + ":" + ; FIXME: update grammar + ; (semicolon) + "->" + "=>" +] @punctuation.delimiter + +; Operators +[ + "&&" + "||" + ">>" + "<<" + "&" + "^" + "|" + "+" + "-" + "*" + "/" + "%" + "**" + "=" + "<" + "<=" + "==" + "!=" + ">=" + ">" + "!" + "~" + "-" + "+" + "++" + "--" + ":=" +] @operator + +[ + "delete" + "new" +] @keyword.operator + +(import_directive + "*" @character.special) + +; Comments +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) diff --git a/runtime/queries/solidity/injections.scm b/runtime/queries/solidity/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/solidity/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/soql/highlights.scm b/runtime/queries/soql/highlights.scm new file mode 100644 index 000000000..11e9d582a --- /dev/null +++ b/runtime/queries/soql/highlights.scm @@ -0,0 +1,161 @@ +(field_identifier + (identifier) @variable.member) + +(field_identifier + (dotted_identifier + (identifier) @variable.member)) + +(type_of_clause + (identifier) @variable.member) + +(when_expression + (identifier) @type) + +(when_expression + (field_list + (identifier) @variable.member)) + +(when_expression + (field_list + (dotted_identifier + (identifier) @variable.member))) + +(else_expression + (field_list + (identifier) @variable.member)) + +(else_expression + (field_list + (dotted_identifier + (identifier) @variable.member))) + +(alias_expression + (identifier) @label) + +(storage_identifier) @keyword.modifier + +(_ + function_name: (identifier) @function) + +(date_literal) @string.special + +[ + "," + "." + ":" + "(" + ")" +] @punctuation.delimiter + +[ + "AND" + "OR" + "NOT" + "LIKE" + "NOT_IN" + "INCLUDES" + "EXCLUDES" +] @keyword.operator + +[ + "=" + "!=" + "<=" + ">=" +] @operator + +(value_comparison_operator + [ + "<" + ">" + ] @operator) + +(set_comparison_operator + "IN" @keyword.operator) + +[ + (int) + (decimal) + (currency_literal) +] @number + +(string_literal) @string + +[ + (date) + (date_time) +] @string.special + +[ + "TRUE" + "FALSE" +] @boolean + +(null_literal) @constant.builtin + +[ + "ABOVE" + "ABOVE_OR_BELOW" + "ALL" + "AS" + "ASC" + "AT" + "BELOW" + "CUSTOM" + "DATA_CATEGORY" + "DESC" + "END" + "FIELDS" + "FOR" + "FROM" + "GROUP_BY" + "HAVING" + "LIMIT" + "NULLS_FIRST" + "NULLS_LAST" + "OFFSET" + "ORDER_BY" + "REFERENCE" + "SELECT" + "STANDARD" + "TRACKING" + "TYPEOF" + "UPDATE" + "USING" + "SCOPE" + "LOOKUP" + "BIND" + "VIEW" + "VIEWSTAT" + "WITH" +] @keyword + +[ + "WHERE" + "WHEN" + "ELSE" + "THEN" +] @keyword.conditional + +; Using Scope +[ + "delegated" + "everything" + "mine" + "mine_and_my_groups" + "my_territory" + "my_team_territory" + "team" +] @keyword + +; With +[ + "maxDescriptorPerRecord" + "RecordVisibilityContext" + "Security_Enforced" + "supportsDomains" + "supportsDelegates" + "System_Mode" + "User_Mode" + "UserId" +] @keyword diff --git a/runtime/queries/sosl/highlights.scm b/runtime/queries/sosl/highlights.scm new file mode 100644 index 000000000..f3b77be3b --- /dev/null +++ b/runtime/queries/sosl/highlights.scm @@ -0,0 +1,30 @@ +(find_clause + (term) @string) + +(sobject_return + (identifier) @type) + +(with_type + (_ + "=" @operator)) + +[ + "ALL" + "DIVISION" + "EMAIL" + "FIND" + "ListView" + "HIGHLIGHT" + "IN" + "METADATA" + "NAME" + "NETWORK" + "PHONE" + "PricebookId" + "RETURNING" + "SIDEBAR" + "SNIPPET" + "SPELL_CORRECTION" + "target_length" + "USING" +] @keyword diff --git a/runtime/queries/sourcepawn/highlights.scm b/runtime/queries/sourcepawn/highlights.scm new file mode 100644 index 000000000..21cbb9733 --- /dev/null +++ b/runtime/queries/sourcepawn/highlights.scm @@ -0,0 +1,303 @@ +(identifier) @variable + +; Assume all-caps names are constants +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z0-9_]+$")) + +; Function definitions/declarations +(function_definition + name: (identifier) @function) + +(function_declaration + name: (identifier) @function) + +(parameter_declaration + name: (identifier) @variable.parameter) + +; Methods / Properties +(field_access + field: (identifier) @variable.member) + +; Function calls +(call_expression + function: (identifier) @function) + +(call_expression + function: (field_access + field: (identifier) @function.method.call)) + +; Types +[ + (builtin_type) + (any_type) +] @type.builtin + +(type + (identifier) @type) + +; Variables +(variable_declaration + name: (identifier) @variable) + +(old_variable_declaration + name: (identifier) @variable) + +[ + (system_lib_string) + (string_literal) +] @string + +; Preprocessor +[ + "#include" + "#tryinclude" +] @keyword.import + +[ + (preproc_assert) + (preproc_pragma) + (preproc_if) + (preproc_else) + (preproc_elseif) + (preproc_endinput) + (preproc_endif) + (preproc_error) + (preproc_warning) +] @keyword.directive + +[ + "#define" + "#undef" +] @keyword.directive.define + +(macro_param) @variable.parameter + +(preproc_define + name: (identifier) @constant) + +(preproc_macro + name: (identifier) @function.macro) + +(preproc_undefine + name: (identifier) @constant) + +; Expressions +(view_as) @function.builtin + +(sizeof_expression) @function.macro + +[ + (this) + ; https://github.com/alliedmodders/sourcemod/blob/5c0ae11a4619e9cba93478683c7737253ea93ba6/plugins/include/handles.inc#L78 + (hardcoded_symbol) +] @variable.builtin + +; Comments +(comment) @comment @spell + +; General +(parameter_declaration + defaultValue: (identifier) @constant) + +[ + (fixed_dimension) + (dimension) +] @punctuation.bracket + +(escape_sequence) @string.escape + +; Constructors +(new_expression + class: (identifier) @type + arguments: (call_arguments) @constructor) + +; Methodmaps +(methodmap + name: (identifier) @type) + +(methodmap + inherits: (identifier) @type) + +(methodmap_method_constructor + name: (identifier) @constructor) + +(methodmap_method + name: (identifier) @function.method) + +(methodmap_native + name: (identifier) @function.method) + +(methodmap_property + name: (identifier) @property) + +[ + (methodmap_property_getter) + (methodmap_property_setter) +] @function.method + +; Enum structs +(enum_struct + name: (identifier) @type) + +(enum_struct_field + name: (identifier) @variable.member) + +(enum_struct_method + name: (identifier) @function.method) + +; Non-type Keywords +(variable_storage_class) @keyword.modifier + +(visibility) @keyword.modifier + +(assertion) @function.builtin + +(function_declaration_kind) @keyword.function + +[ + "new" + "delete" +] @keyword.operator + +[ + "." + "," +] @punctuation.delimiter + +; Operators +[ + "+" + "-" + "*" + "/" + "%" + "++" + "--" + "=" + "+=" + "-=" + "*=" + "/=" + "==" + "!=" + "<" + ">" + ">=" + "<=" + "!" + "&&" + "||" + "&" + "|" + "~" + "^" + "<<" + ">>" + ">>>" + "|=" + "&=" + "^=" + "~=" + "<<=" + ">>=" + "..." + (ignore_argument) + (scope_access) + (rest_operator) +] @operator + +; public Plugin myinfo +(struct_declaration + name: (identifier) @variable.builtin) + +; Typedef/Typedef +(typedef + name: (identifier) @type) + +(functag + name: (identifier) @type) + +(funcenum + name: (identifier) @type) + +(typeset + name: (identifier) @type) + +(typedef_expression) @keyword.function ; function void(int x) + +; Enums +(enum + name: (identifier) @type) + +(enum_entry + name: (identifier) @constant) + +(enum_entry + value: (_) @constant) + +; Literals +(int_literal) @number + +(char_literal) @character + +(float_literal) @number.float + +(string_literal) @string + +(array_literal) @punctuation.bracket + +(bool_literal) @boolean + +(null) @constant.builtin + +((identifier) @constant.builtin + (#eq? @constant.builtin "INVALID_HANDLE")) + +; Keywords +"return" @keyword.return + +[ + "if" + "else" + "case" + "default" + "switch" +] @keyword.conditional + +[ + "do" + "while" + "for" + "continue" + "break" +] @keyword.repeat + +[ + "__nullable__" + "defined" + "delete" + "functag" + "get" + "methodmap" + "new" + "property" + "public" + "set" + "typeset" + "void" +] @keyword + +[ + "enum" + "funcenum" + "struct" + "typedef" +] @keyword.type + +[ + "const" + "native" + "static" + "stock" + "forward" +] @keyword.modifier diff --git a/runtime/queries/sourcepawn/injections.scm b/runtime/queries/sourcepawn/injections.scm new file mode 100644 index 000000000..c579ffad8 --- /dev/null +++ b/runtime/queries/sourcepawn/injections.scm @@ -0,0 +1,3 @@ +; Parse JSDoc annotations in comments +((comment) @injection.content + (#set! injection.language "jsdoc")) diff --git a/runtime/queries/sourcepawn/locals.scm b/runtime/queries/sourcepawn/locals.scm new file mode 100644 index 000000000..39d6fb516 --- /dev/null +++ b/runtime/queries/sourcepawn/locals.scm @@ -0,0 +1,19 @@ +[ + (function_definition) + (alias_declaration) + (enum_struct_method) + (methodmap_method) + (methodmap_method_constructor) + (methodmap_method_destructor) + (methodmap_property_method) +] @local.scope + +; Definitions +(variable_declaration + name: (identifier) @local.definition) + +(old_variable_declaration + name: (identifier) @local.definition) + +; References +(identifier) @local.reference diff --git a/runtime/queries/sparql/folds.scm b/runtime/queries/sparql/folds.scm new file mode 100644 index 000000000..2b93a7bc7 --- /dev/null +++ b/runtime/queries/sparql/folds.scm @@ -0,0 +1,26 @@ +[ + (prologue) + (select_query) + (construct_query) + (describe_query) + (ask_query) + (values_clause) + (load) + (clear) + (drop) + (add) + (move) + (copy) + (create) + (insert_data) + (delete_data) + (delete_where) + (modify) + (group_graph_pattern) + (triples_same_subject) + (where_clause) + (delete_clause) + (insert_clause) + (data_block) + (blank_node_property_list) +] @fold diff --git a/runtime/queries/sparql/highlights.scm b/runtime/queries/sparql/highlights.scm new file mode 100644 index 000000000..19c0257ca --- /dev/null +++ b/runtime/queries/sparql/highlights.scm @@ -0,0 +1,249 @@ +[ + (path_mod) + "||" + "&&" + "=" + "<" + ">" + "<=" + ">=" + "+" + "-" + "*" + "/" + "!" + "|" + "^" +] @operator + +[ + "_:" + (namespace) +] @module + +[ + "UNDEF" + "a" +] @variable.builtin + +[ + "ADD" + "ALL" + "AS" + "ASC" + "ASK" + "BIND" + "BY" + "CLEAR" + "CONSTRUCT" + "COPY" + "CREATE" + "DEFAULT" + "DELETE" + "DELETE DATA" + "DELETE WHERE" + "DESC" + "DESCRIBE" + "DISTINCT" + "DROP" + "EXISTS" + "FILTER" + "FROM" + "GRAPH" + "GROUP" + "HAVING" + "INSERT" + "INSERT DATA" + "INTO" + "LIMIT" + "LOAD" + "MINUS" + "MOVE" + "NAMED" + "NOT" + "OFFSET" + "OPTIONAL" + "ORDER" + "PREFIX" + "REDUCED" + "SELECT" + "SERVICE" + "SILENT" + "UNION" + "USING" + "VALUES" + "WHERE" + "WITH" +] @keyword + +(string) @string + +(echar) @string.escape + +(integer) @number + +[ + (decimal) + (double) +] @number.float + +(boolean_literal) @boolean + +[ + "BASE" + "PREFIX" +] @keyword + +[ + "ABS" + "AVG" + "BNODE" + "BOUND" + "CEIL" + "CONCAT" + "COALESCE" + "CONTAINS" + "DATATYPE" + "DAY" + "ENCODE_FOR_URI" + "FLOOR" + "HOURS" + "IF" + "IRI" + "LANG" + "LANGMATCHES" + "LCASE" + "MD5" + "MINUTES" + "MONTH" + "NOW" + "RAND" + "REGEX" + "ROUND" + "SECONDS" + "SHA1" + "SHA256" + "SHA384" + "SHA512" + "STR" + "SUM" + "MAX" + "MIN" + "SAMPLE" + "GROUP_CONCAT" + "SEPARATOR" + "COUNT" + "STRAFTER" + "STRBEFORE" + "STRDT" + "STRENDS" + "STRLANG" + "STRLEN" + "STRSTARTS" + "STRUUID" + "TIMEZONE" + "TZ" + "UCASE" + "URI" + "UUID" + "YEAR" + "isBLANK" + "isIRI" + "isLITERAL" + "isNUMERIC" + "isURI" + "sameTerm" +] @function.builtin + +[ + "." + "," + ";" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" + (nil) + (anon) +] @punctuation.bracket + +[ + "IN" + ("NOT" + "IN") +] @keyword.operator + +(comment) @comment @spell + +; Could this be summarized? +(select_clause + [ + bound_variable: (var) + "*" + ] @variable.parameter) + +(bind + bound_variable: (var) @variable.parameter) + +(data_block + bound_variable: (var) @variable.parameter) + +(group_condition + bound_variable: (var) @variable.parameter) + +(iri_reference + [ + "<" + ">" + ] @module) + +(lang_tag) @type + +(rdf_literal + "^^" @type + datatype: (_ + [ + "<" + ">" + (namespace) + ] @type) @type) + +(function_call + identifier: (_) @function) + +(function_call + identifier: (iri_reference + [ + "<" + ">" + ] @function)) + +(function_call + identifier: (prefixed_name + (namespace) @function)) + +(base_declaration + (iri_reference + [ + "<" + ">" + ] @variable)) + +(prefix_declaration + (iri_reference + [ + "<" + ">" + ] @variable)) + +[ + (var) + (blank_node_label) + (iri_reference) + (prefixed_name) +] @variable diff --git a/runtime/queries/sparql/indents.scm b/runtime/queries/sparql/indents.scm new file mode 100644 index 000000000..e070546df --- /dev/null +++ b/runtime/queries/sparql/indents.scm @@ -0,0 +1,18 @@ +[ + (group_graph_pattern) + (triples_block) + (triples_template) + (construct_template) + (construct_triples) + (quads) + (data_block) + (blank_node_property_list) + (collection) +] @indent.begin + +[ + "}" + "]" + ")" + (triples_same_subject) +] @indent.branch diff --git a/runtime/queries/sparql/injections.scm b/runtime/queries/sparql/injections.scm new file mode 100644 index 000000000..bce9a19ee --- /dev/null +++ b/runtime/queries/sparql/injections.scm @@ -0,0 +1,8 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +(regex_expression + pattern: (rdf_literal + value: (string) @injection.content) + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "regex")) diff --git a/runtime/queries/sparql/locals.scm b/runtime/queries/sparql/locals.scm new file mode 100644 index 000000000..cbb2bb252 --- /dev/null +++ b/runtime/queries/sparql/locals.scm @@ -0,0 +1,14 @@ +(group_graph_pattern + (triples_block) @local.scope) + +((sub_select + (select_clause + (var) @local.definition.var)) + (#set! definition.var.scope "parent")) + +((select_query + (select_clause + (var) @local.definition.var)) + (#set! definition.var.scope "parent")) + +(var) @local.reference diff --git a/runtime/queries/sql/folds.scm b/runtime/queries/sql/folds.scm new file mode 100644 index 000000000..07f2282d0 --- /dev/null +++ b/runtime/queries/sql/folds.scm @@ -0,0 +1 @@ +(statement) @fold diff --git a/runtime/queries/sql/highlights.scm b/runtime/queries/sql/highlights.scm new file mode 100644 index 000000000..67eef18ae --- /dev/null +++ b/runtime/queries/sql/highlights.scm @@ -0,0 +1,427 @@ +(invocation + (object_reference + name: (identifier) @function.call)) + +[ + (keyword_gist) + (keyword_btree) + (keyword_hash) + (keyword_spgist) + (keyword_gin) + (keyword_brin) + (keyword_array) +] @function.call + +(object_reference + name: (identifier) @type) + +(relation + alias: (identifier) @variable) + +(field + name: (identifier) @variable.member) + +(column_definition + name: (identifier) @variable.member) + +(term + alias: (identifier) @variable) + +(term + value: (cast + name: (keyword_cast) @function.call + parameter: (literal)?)) + +(literal) @string + +(comment) @comment @spell + +(marginalia) @comment + +((literal) @number + (#lua-match? @number "^%d+$")) + +((literal) @number.float + (#lua-match? @number.float "^[-]?%d*\.%d*$")) + +(parameter) @variable.parameter + +[ + (keyword_true) + (keyword_false) +] @boolean + +[ + (keyword_asc) + (keyword_desc) + (keyword_terminated) + (keyword_escaped) + (keyword_unsigned) + (keyword_nulls) + (keyword_last) + (keyword_delimited) + (keyword_replication) + (keyword_auto_increment) + (keyword_default) + (keyword_collate) + (keyword_concurrently) + (keyword_engine) + (keyword_always) + (keyword_generated) + (keyword_preceding) + (keyword_following) + (keyword_first) + (keyword_current_timestamp) + (keyword_immutable) + (keyword_atomic) + (keyword_parallel) + (keyword_leakproof) + (keyword_safe) + (keyword_cost) + (keyword_strict) +] @attribute + +[ + (keyword_materialized) + (keyword_recursive) + (keyword_temp) + (keyword_temporary) + (keyword_unlogged) + (keyword_external) + (keyword_parquet) + (keyword_csv) + (keyword_rcfile) + (keyword_textfile) + (keyword_orc) + (keyword_avro) + (keyword_jsonfile) + (keyword_sequencefile) + (keyword_volatile) +] @keyword.modifier + +[ + (keyword_case) + (keyword_when) + (keyword_then) + (keyword_else) +] @keyword.conditional + +[ + (keyword_select) + (keyword_from) + (keyword_where) + (keyword_index) + (keyword_join) + (keyword_primary) + (keyword_delete) + (keyword_create) + (keyword_insert) + (keyword_merge) + (keyword_distinct) + (keyword_replace) + (keyword_update) + (keyword_into) + (keyword_overwrite) + (keyword_matched) + (keyword_values) + (keyword_value) + (keyword_attribute) + (keyword_set) + (keyword_left) + (keyword_right) + (keyword_outer) + (keyword_inner) + (keyword_full) + (keyword_order) + (keyword_partition) + (keyword_group) + (keyword_with) + (keyword_without) + (keyword_as) + (keyword_having) + (keyword_limit) + (keyword_offset) + (keyword_table) + (keyword_tables) + (keyword_key) + (keyword_references) + (keyword_foreign) + (keyword_constraint) + (keyword_force) + (keyword_use) + (keyword_for) + (keyword_if) + (keyword_exists) + (keyword_column) + (keyword_columns) + (keyword_cross) + (keyword_lateral) + (keyword_natural) + (keyword_alter) + (keyword_drop) + (keyword_add) + (keyword_view) + (keyword_end) + (keyword_is) + (keyword_using) + (keyword_between) + (keyword_window) + (keyword_no) + (keyword_data) + (keyword_type) + (keyword_rename) + (keyword_to) + (keyword_schema) + (keyword_owner) + (keyword_authorization) + (keyword_all) + (keyword_any) + (keyword_some) + (keyword_returning) + (keyword_begin) + (keyword_commit) + (keyword_rollback) + (keyword_transaction) + (keyword_only) + (keyword_like) + (keyword_similar) + (keyword_over) + (keyword_change) + (keyword_modify) + (keyword_after) + (keyword_before) + (keyword_range) + (keyword_rows) + (keyword_groups) + (keyword_exclude) + (keyword_current) + (keyword_ties) + (keyword_others) + (keyword_zerofill) + (keyword_format) + (keyword_fields) + (keyword_row) + (keyword_sort) + (keyword_compute) + (keyword_comment) + (keyword_location) + (keyword_cached) + (keyword_uncached) + (keyword_lines) + (keyword_stored) + (keyword_virtual) + (keyword_partitioned) + (keyword_analyze) + (keyword_explain) + (keyword_verbose) + (keyword_truncate) + (keyword_rewrite) + (keyword_optimize) + (keyword_vacuum) + (keyword_cache) + (keyword_language) + (keyword_called) + (keyword_conflict) + (keyword_declare) + (keyword_filter) + (keyword_function) + (keyword_input) + (keyword_name) + (keyword_oid) + (keyword_oids) + (keyword_precision) + (keyword_regclass) + (keyword_regnamespace) + (keyword_regproc) + (keyword_regtype) + (keyword_restricted) + (keyword_return) + (keyword_returns) + (keyword_separator) + (keyword_setof) + (keyword_stable) + (keyword_support) + (keyword_tblproperties) + (keyword_trigger) + (keyword_unsafe) + (keyword_admin) + (keyword_connection) + (keyword_cycle) + (keyword_database) + (keyword_encrypted) + (keyword_increment) + (keyword_logged) + (keyword_none) + (keyword_owned) + (keyword_password) + (keyword_reset) + (keyword_role) + (keyword_sequence) + (keyword_start) + (keyword_restart) + (keyword_tablespace) + (keyword_until) + (keyword_user) + (keyword_valid) + (keyword_action) + (keyword_definer) + (keyword_invoker) + (keyword_security) + (keyword_extension) + (keyword_version) + (keyword_out) + (keyword_inout) + (keyword_variadic) + (keyword_session) + (keyword_isolation) + (keyword_level) + (keyword_serializable) + (keyword_repeatable) + (keyword_read) + (keyword_write) + (keyword_committed) + (keyword_uncommitted) + (keyword_deferrable) + (keyword_names) + (keyword_zone) + (keyword_immediate) + (keyword_deferred) + (keyword_constraints) + (keyword_snapshot) + (keyword_characteristics) + (keyword_off) + (keyword_follows) + (keyword_precedes) + (keyword_each) + (keyword_instead) + (keyword_of) + (keyword_initially) + (keyword_old) + (keyword_new) + (keyword_referencing) + (keyword_statement) + (keyword_execute) + (keyword_procedure) +] @keyword + +[ + (keyword_restrict) + (keyword_unbounded) + (keyword_unique) + (keyword_cascade) + (keyword_delayed) + (keyword_high_priority) + (keyword_low_priority) + (keyword_ignore) + (keyword_nothing) + (keyword_check) + (keyword_option) + (keyword_local) + (keyword_cascaded) + (keyword_wait) + (keyword_nowait) + (keyword_metadata) + (keyword_incremental) + (keyword_bin_pack) + (keyword_noscan) + (keyword_stats) + (keyword_statistics) + (keyword_maxvalue) + (keyword_minvalue) +] @keyword.modifier + +[ + (keyword_int) + (keyword_null) + (keyword_boolean) + (keyword_binary) + (keyword_varbinary) + (keyword_image) + (keyword_bit) + (keyword_inet) + (keyword_character) + (keyword_smallserial) + (keyword_serial) + (keyword_bigserial) + (keyword_smallint) + (keyword_mediumint) + (keyword_bigint) + (keyword_tinyint) + (keyword_decimal) + (keyword_float) + (keyword_double) + (keyword_numeric) + (keyword_real) + (double) + (keyword_money) + (keyword_smallmoney) + (keyword_char) + (keyword_nchar) + (keyword_varchar) + (keyword_nvarchar) + (keyword_varying) + (keyword_text) + (keyword_string) + (keyword_uuid) + (keyword_json) + (keyword_jsonb) + (keyword_xml) + (keyword_bytea) + (keyword_enum) + (keyword_date) + (keyword_datetime) + (keyword_time) + (keyword_datetime2) + (keyword_datetimeoffset) + (keyword_smalldatetime) + (keyword_timestamp) + (keyword_timestamptz) + (keyword_geometry) + (keyword_geography) + (keyword_box2d) + (keyword_box3d) + (keyword_interval) +] @type.builtin + +[ + (keyword_in) + (keyword_and) + (keyword_or) + (keyword_not) + (keyword_by) + (keyword_on) + (keyword_do) + (keyword_union) + (keyword_except) + (keyword_intersect) +] @keyword.operator + +[ + "+" + "-" + "*" + "/" + "%" + "^" + ":=" + "=" + "<" + "<=" + "!=" + ">=" + ">" + "<>" + (op_other) + (op_unary_other) +] @operator + +[ + "(" + ")" +] @punctuation.bracket + +[ + ";" + "," + "." +] @punctuation.delimiter diff --git a/runtime/queries/sql/indents.scm b/runtime/queries/sql/indents.scm new file mode 100644 index 000000000..34ae079dd --- /dev/null +++ b/runtime/queries/sql/indents.scm @@ -0,0 +1,29 @@ +[ + (select) + (cte) + (column_definitions) + (case) + (subquery) + (insert) + (when_clause) +] @indent.begin + +(block + (keyword_begin)) @indent.begin + +(column_definitions + ")" @indent.branch) + +(subquery + ")" @indent.branch) + +(cte + ")" @indent.branch) + +[ + (keyword_end) + (keyword_values) + (keyword_into) +] @indent.branch + +(keyword_end) @indent.end diff --git a/runtime/queries/sql/injections.scm b/runtime/queries/sql/injections.scm new file mode 100644 index 000000000..602997440 --- /dev/null +++ b/runtime/queries/sql/injections.scm @@ -0,0 +1,5 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((marginalia) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/squirrel/folds.scm b/runtime/queries/squirrel/folds.scm new file mode 100644 index 000000000..c2903cc66 --- /dev/null +++ b/runtime/queries/squirrel/folds.scm @@ -0,0 +1,23 @@ +[ + (class_declaration) + (function_declaration) + (member_declaration) + (enum_declaration) + (array) + (block) + (table) + (anonymous_function) + (parenthesized_expression) + (string) + (verbatim_string) + (comment) + (if_statement) + (else_statement) + (while_statement) + (do_while_statement) + (switch_statement) + (for_statement) + (foreach_statement) + (try_statement) + (catch_statement) +] @fold diff --git a/runtime/queries/squirrel/highlights.scm b/runtime/queries/squirrel/highlights.scm new file mode 100644 index 000000000..03acacadc --- /dev/null +++ b/runtime/queries/squirrel/highlights.scm @@ -0,0 +1,316 @@ +; Keywords +[ + "clone" + "delete" + "extends" + "rawcall" + "resume" + "var" +] @keyword + +[ + "class" + "enum" +] @keyword.type + +"function" @keyword.function + +[ + "in" + "instanceof" + "typeof" +] @keyword.operator + +[ + "return" + "yield" +] @keyword.return + +((global_variable + "::" + (_) @keyword.coroutine) + (#any-of? @keyword.coroutine "suspend" "newthread")) + +; Conditionals +[ + "if" + "else" + "switch" + "case" + "default" + "break" +] @keyword.conditional + +; Repeats +[ + "for" + "foreach" + "do" + "while" + "continue" +] @keyword.repeat + +; Exceptions +[ + "try" + "catch" + "throw" +] @keyword.exception + +; Storageclasses +"local" @keyword.modifier + +; Qualifiers +[ + "static" + "const" +] @keyword.modifier + +; Variables +[ + (identifier) + (global_variable) +] @variable + +(local_declaration + (identifier) @variable + . + "=") + +((identifier) @variable.builtin + (#any-of? @variable.builtin "base" "this" "vargv")) + +; Parameters +(parameter + . + (identifier) @variable.parameter) + +; Properties (Slots) +(deref_expression + "." + . + (identifier) @variable.member) + +(member_declaration + (identifier) @variable.member + . + "=") + +((table_slot + . + (identifier) @variable.member + . + [ + "=" + ":" + ]) + (#set! priority 105)) + +; Types +((identifier) @type + (#lua-match? @type "^[A-Z]")) + +(class_declaration + (identifier) @type + "extends"? + . + (identifier)? @type) + +(enum_declaration + (identifier) @type) + +; Attributes +(attribute_declaration + left: (identifier) @attribute) + +; Functions & Methods +(member_declaration + (function_declaration + "::"? + (_) @function.method + . + "(" + (_)? + ")")) + +((function_declaration + "::"? + (_) @function + . + "(" + (_)? + ")") + (#not-has-ancestor? @function member_declaration)) + +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (deref_expression + "." + . + (identifier) @function.call)) + +(call_expression + (global_variable + "::" + (_) @function.call)) + +(_ + (identifier) @function + "=" + (lambda_expression + "@" @string.special.symbol)) + +(call_expression + [ + function: (identifier) @function.builtin + function: (global_variable + "::" + (_) @function.builtin) + function: (deref_expression + "." + (_) @function.builtin) + ] + (#any-of? @function.builtin + ; General Methods + "assert" "array" "callee" "collectgarbage" "compilestring" "enabledebughook" "enabledebuginfo" + "error" "getconsttable" "getroottable" "print" "resurrectunreachable" "setconsttable" + "setdebughook" "seterrorhandler" "setroottable" "type" + ; Hidden Methods + "_charsize_" "_intsize_" "_floatsize_" "_version_" "_versionnumber_" + ; Number Methods + "tofloat" "tostring" "tointeger" "tochar" + ; String Methods + "len" "slice" "find" "tolower" "toupper" + ; Table Methods + "rawget" "rawset" "rawdelete" "rawin" "clear" "setdelegate" "getdelegate" "filter" "keys" + "values" + ; Array Methods + "append" "push" "extend" "pop" "top" "insert" "remove" "resize" "sort" "reverse" "map" "apply" + "reduce" + ; Function Methods + "call" "pcall" "acall" "pacall" "setroot" "getroot" "bindenv" "getinfos" + ; Class Methods + "instance" "getattributes" "setattributes" "newmember" "rawnewmember" + ; Class Instance Methods + "getclass" + ; Generator Methods + "getstatus" + ; Thread Methods + "call" "wakeup" "wakeupthrow" "getstackinfos" + ; Weak Reference Methods + "ref" "weakref")) + +(member_declaration + "constructor" @constructor) + +; Constants +(const_declaration + "const" + . + (identifier) @constant) + +(enum_declaration + "{" + . + (identifier) @constant) + +((identifier) @constant + (#lua-match? @constant "^_*[A-Z][A-Z%d_]*$")) + +; Operators +[ + "+" + "-" + "*" + "/" + "%" + "||" + "&&" + "|" + "^" + "&" + "==" + "!=" + "<=>" + ">" + ">=" + "<=" + "<" + "<<" + ">>" + ">>>" + "=" + "<-" + "+=" + "-=" + "*=" + "/=" + "%=" + "~" + "!" + "++" + "--" +] @operator + +; Punctuation +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "</" + "/>" +] @punctuation.bracket + +[ + "." + "," + ";" + ":" +] @punctuation.delimiter + +[ + "::" + "..." +] @punctuation.special + +; Ternaries +(ternary_expression + "?" @keyword.conditional.ternary + ":" @keyword.conditional.ternary) + +; Literals +(string) @string + +(verbatim_string) @string.special + +(char) @character + +(escape_sequence) @string.escape + +(integer) @number + +(float) @number.float + +(bool) @boolean + +(null) @constant.builtin + +; Comments +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) diff --git a/runtime/queries/squirrel/indents.scm b/runtime/queries/squirrel/indents.scm new file mode 100644 index 000000000..00245d6ae --- /dev/null +++ b/runtime/queries/squirrel/indents.scm @@ -0,0 +1,63 @@ +[ + (class_declaration) + (function_declaration) + (enum_declaration) + (array) + (block) + (table) + (anonymous_function) + (parenthesized_expression) + (while_statement) + (switch_statement) + (for_statement) + (foreach_statement) + ; (try_statement) + (catch_statement) +] @indent.begin + +((if_statement) + (ERROR + "else") @indent.begin) + +(if_statement + condition: (_) @indent.begin) + +(if_statement + consequence: (_) + (else_statement) @indent.begin) + +(do_while_statement + "do" + (_) @indent.begin) + +(try_statement + (_) @indent.begin + (catch_statement) @indent.begin) + +[ + "{" + "}" +] @indent.branch + +[ + "(" + ")" +] @indent.branch + +[ + "[" + "]" +] @indent.branch + +[ + "}" + ")" + "]" +] @indent.end + +[ + (ERROR) + (comment) + (string) + (verbatim_string) +] @indent.auto diff --git a/runtime/queries/squirrel/injections.scm b/runtime/queries/squirrel/injections.scm new file mode 100644 index 000000000..578a9eeca --- /dev/null +++ b/runtime/queries/squirrel/injections.scm @@ -0,0 +1,12 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((verbatim_string) @injection.content + (#lua-match? @injection.content "^@\"<html") + (#set! injection.language "html") + (#offset! @injection.content 0 2 0 -1)) + +((verbatim_string) @injection.content + (#lua-match? @injection.content "@\"<!DOCTYPE html>") + (#set! injection.language "html") + (#offset! @injection.content 0 2 0 -1)) diff --git a/runtime/queries/squirrel/locals.scm b/runtime/queries/squirrel/locals.scm new file mode 100644 index 000000000..e5fce7d57 --- /dev/null +++ b/runtime/queries/squirrel/locals.scm @@ -0,0 +1,75 @@ +; Scopes +[ + (script) + (class_declaration) + (enum_declaration) + (function_declaration) + (attribute_declaration) + (array) + (block) + (table) + (anonymous_function) + (parenthesized_expression) + (if_statement) + (else_statement) + (while_statement) + (do_while_statement) + (switch_statement) + (for_statement) + (foreach_statement) + (try_statement) + (catch_statement) +] @local.scope + +; References +[ + (identifier) + (global_variable) +] @local.reference + +; Definitions +(const_declaration + . + (identifier) @local.definition.constant) + +(enum_declaration + . + (identifier) @local.definition.enum) + +(member_declaration + (identifier) @local.definition.field + . + "=") + +(table_slot + . + (identifier) @local.definition.field + . + [ + "=" + ":" + ]) + +((function_declaration + . + (identifier) @local.definition.function) + (#not-has-ancestor? @local.definition.function member_declaration)) + +(member_declaration + (function_declaration + . + (identifier) @local.definition.method)) + +(class_declaration + . + (identifier) @local.definition.type) + +(var_statement + "var" + . + (identifier) @local.definition.var) + +(local_declaration + (identifier) @local.definition.var + . + "=") diff --git a/runtime/queries/ssh_config/folds.scm b/runtime/queries/ssh_config/folds.scm new file mode 100644 index 000000000..659835657 --- /dev/null +++ b/runtime/queries/ssh_config/folds.scm @@ -0,0 +1,4 @@ +[ + (host_declaration) + (match_declaration) +] @fold diff --git a/runtime/queries/ssh_config/highlights.scm b/runtime/queries/ssh_config/highlights.scm new file mode 100644 index 000000000..b58360b69 --- /dev/null +++ b/runtime/queries/ssh_config/highlights.scm @@ -0,0 +1,108 @@ +; Literals +(string) @string + +(pattern) @string.regexp + +(token) @character + +[ + (number) + (bytes) + (time) +] @number + +[ + (kex) + (mac) + (cipher) + (key_sig) +] @variable.parameter + +[ + ; generic + "yes" + "no" + "ask" + "auto" + "none" + "any" + ; CanonicalizeHostname + "always" + ; ControlMaster + "autoask" + ; FingerprintHash + "md5" + "sha256" + ; PubkeyAuthentication + "unbound" + "host-bound" + ; RequestTTY + "force" + ; SessionType + "subsystem" + "default" + ; StrictHostKeyChecking + "accept-new" + "off" + ; Tunnel + "point-to-point" + "ethernet" + (ipqos) + (verbosity) + (facility) + (authentication) +] @constant.builtin + +(uri) @string.special.url + +; Keywords +[ + "Host" + "Match" +] @keyword + +(parameter + keyword: _ @keyword) + +(host_declaration + argument: _ @module) + +(match_declaration + (condition + criteria: _ @attribute)) + +"all" @attribute + +; Misc +[ + "SSH_AUTH_SOCK" + (variable) +] @constant + +(comment) @comment @spell + +; Punctuation +[ + "${" + "}" +] @punctuation.special + +[ + "\"" + "," + ":" + "@" +] @punctuation.delimiter + +[ + "=" + "!" + "+" + "-" + "^" +] @operator + +[ + "*" + "?" +] @character.special diff --git a/runtime/queries/ssh_config/indents.scm b/runtime/queries/ssh_config/indents.scm new file mode 100644 index 000000000..760707f17 --- /dev/null +++ b/runtime/queries/ssh_config/indents.scm @@ -0,0 +1,12 @@ +[ + (host_declaration) + (match_declaration) +] @indent.begin + +; incomplete declarations +(ERROR + . + [ + "Host" + "Match" + ]) @indent.begin diff --git a/runtime/queries/ssh_config/injections.scm b/runtime/queries/ssh_config/injections.scm new file mode 100644 index 000000000..d1b24be61 --- /dev/null +++ b/runtime/queries/ssh_config/injections.scm @@ -0,0 +1,17 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((condition + criteria: "exec" + argument: (string) @injection.content) + (#set! injection.language "bash")) + +((parameter + keyword: [ + "KnownHostsCommand" + "LocalCommand" + "RemoteCommand" + "ProxyCommand" + ] + argument: (string) @injection.content) + (#set! injection.language "bash")) diff --git a/runtime/queries/ssh_config/locals.scm b/runtime/queries/ssh_config/locals.scm new file mode 100644 index 000000000..a3309a9a6 --- /dev/null +++ b/runtime/queries/ssh_config/locals.scm @@ -0,0 +1,7 @@ +(parameter + keyword: "Tag" + argument: (string) @local.reference) + +(condition + criteria: "tagged" + argument: (pattern) @local.definition) diff --git a/runtime/queries/starlark/folds.scm b/runtime/queries/starlark/folds.scm new file mode 100644 index 000000000..0c9d2a260 --- /dev/null +++ b/runtime/queries/starlark/folds.scm @@ -0,0 +1,17 @@ +[ + (function_definition) + (for_statement) + (if_statement) + (while_statement) + (with_statement) + (match_statement) + (parameters) + (argument_list) + (parenthesized_expression) + (list_comprehension) + (dictionary_comprehension) + (tuple) + (list) + (dictionary) + (string) +] @fold diff --git a/runtime/queries/starlark/highlights.scm b/runtime/queries/starlark/highlights.scm new file mode 100644 index 000000000..fe3dce89b --- /dev/null +++ b/runtime/queries/starlark/highlights.scm @@ -0,0 +1,337 @@ +; From tree-sitter-python licensed under MIT License +; Copyright (c) 2016 Max Brunsfeld +; Variables +(identifier) @variable + +; Reset highlighting in f-string interpolations +(interpolation) @none + +; Identifier naming conventions +((identifier) @type + (#lua-match? @type "^[A-Z].*[a-z]")) + +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + +((identifier) @constant.builtin + (#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$")) + +((identifier) @constant.builtin + (#any-of? @constant.builtin + ; https://docs.python.org/3/library/constants.html + "NotImplemented" "Ellipsis" "quit" "exit" "copyright" "credits" "license")) + +((attribute + attribute: (identifier) @variable.member) + (#lua-match? @variable.member "^[%l_].*$")) + +((assignment + left: (identifier) @type.definition + (type + (identifier) @_annotation)) + (#eq? @_annotation "TypeAlias")) + +((assignment + left: (identifier) @type.definition + right: (call + function: (identifier) @_func)) + (#any-of? @_func "TypeVar" "NewType")) + +; Decorators +((decorator + "@" @attribute) + (#set! priority 101)) + +(decorator + (identifier) @attribute) + +(decorator + (attribute + attribute: (identifier) @attribute)) + +(decorator + (call + (identifier) @attribute)) + +(decorator + (call + (attribute + attribute: (identifier) @attribute))) + +((decorator + (identifier) @attribute.builtin) + (#any-of? @attribute.builtin "classmethod" "property")) + +; Builtin functions +((call + function: (identifier) @function.builtin) + (#any-of? @function.builtin + "abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" "bytes" "callable" "chr" + "classmethod" "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "exec" + "fail" "filter" "float" "format" "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" + "id" "input" "int" "isinstance" "issubclass" "iter" "len" "list" "locals" "map" "max" + "memoryview" "min" "next" "object" "oct" "open" "ord" "pow" "print" "property" "range" "repr" + "reversed" "round" "set" "setattr" "slice" "sorted" "staticmethod" "str" "struct" "sum" "super" + "tuple" "type" "vars" "zip" "__import__")) + +; Function definitions +(function_definition + name: (identifier) @function) + +(type + (identifier) @type) + +(type + (subscript + (identifier) @type)) ; type subscript: Tuple[int] + +((call + function: (identifier) @_isinstance + arguments: (argument_list + (_) + (identifier) @type)) + (#eq? @_isinstance "isinstance")) + +((identifier) @type.builtin + (#any-of? @type.builtin + ; https://docs.python.org/3/library/exceptions.html + "ArithmeticError" "BufferError" "LookupError" "AssertionError" "AttributeError" "EOFError" + "FloatingPointError" "ModuleNotFoundError" "IndexError" "KeyError" "KeyboardInterrupt" + "MemoryError" "NameError" "NotImplementedError" "OSError" "OverflowError" "RecursionError" + "ReferenceError" "RuntimeError" "StopIteration" "StopAsyncIteration" "SyntaxError" + "IndentationError" "TabError" "SystemError" "SystemExit" "TypeError" "UnboundLocalError" + "UnicodeError" "UnicodeEncodeError" "UnicodeDecodeError" "UnicodeTranslateError" "ValueError" + "ZeroDivisionError" "EnvironmentError" "IOError" "WindowsError" "BlockingIOError" + "ChildProcessError" "ConnectionError" "BrokenPipeError" "ConnectionAbortedError" + "ConnectionRefusedError" "ConnectionResetError" "FileExistsError" "FileNotFoundError" + "InterruptedError" "IsADirectoryError" "NotADirectoryError" "PermissionError" + "ProcessLookupError" "TimeoutError" "Warning" "UserWarning" "DeprecationWarning" + "PendingDeprecationWarning" "SyntaxWarning" "RuntimeWarning" "FutureWarning" "UnicodeWarning" + "BytesWarning" "ResourceWarning" + ; https://docs.python.org/3/library/stdtypes.html + "bool" "int" "float" "complex" "list" "tuple" "range" "str" "bytes" "bytearray" "memoryview" + "set" "frozenset" "dict" "type")) + +; Normal parameters +(parameters + (identifier) @variable.parameter) + +; Lambda parameters +(lambda_parameters + (identifier) @variable.parameter) + +(lambda_parameters + (tuple_pattern + (identifier) @variable.parameter)) + +; Default parameters +(keyword_argument + name: (identifier) @variable.parameter) + +; Naming parameters on call-site +(default_parameter + name: (identifier) @variable.parameter) + +(typed_parameter + (identifier) @variable.parameter) + +(typed_default_parameter + (identifier) @variable.parameter) + +; Variadic parameters *args, **kwargs +(parameters + (list_splat_pattern + ; *args + (identifier) @variable.parameter)) + +(parameters + (dictionary_splat_pattern + ; **kwargs + (identifier) @variable.parameter)) + +; Literals +(none) @constant.builtin + +[ + (true) + (false) +] @boolean + +((identifier) @variable.builtin + (#eq? @variable.builtin "self")) + +((identifier) @variable.builtin + (#eq? @variable.builtin "cls")) + +(integer) @number + +(float) @number.float + +(comment) @comment @spell + +((module + . + (comment) @keyword.directive @nospell) + (#lua-match? @keyword.directive "^#!/")) + +(string) @string + +[ + (escape_sequence) + (escape_interpolation) +] @string.escape + +; doc-strings +(module + . + (expression_statement + (string) @string.documentation @spell)) + +(function_definition + body: (block + . + (expression_statement + (string) @string.documentation @spell))) + +; Tokens +[ + "-" + "-=" + ":=" + "!=" + "*" + "**" + "**=" + "*=" + "/" + "//" + "//=" + "/=" + "&" + "&=" + "%" + "%=" + "^" + "^=" + "+" + "+=" + "<" + "<<" + "<<=" + "<=" + "<>" + "=" + "==" + ">" + ">=" + ">>" + ">>=" + "@" + "@=" + "|" + "|=" + "~" + "->" +] @operator + +; Keywords +[ + "and" + "in" + "not" + "or" + "del" +] @keyword.operator + +[ + "def" + "lambda" +] @keyword.function + +[ + "async" + "exec" + "pass" + "print" + "with" + "as" +] @keyword + +"async" @keyword.coroutine + +"return" @keyword.return + +((call + function: (identifier) @keyword.import + arguments: (argument_list + (string) @string)) + (#eq? @keyword.import "load")) + +[ + "if" + "elif" + "else" + "match" + "case" +] @keyword.conditional + +[ + "for" + "while" + "break" + "continue" +] @keyword.repeat + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(interpolation + "{" @punctuation.special + "}" @punctuation.special) + +(type_conversion) @function.macro + +[ + "," + "." + ":" + ";" + (ellipsis) +] @punctuation.delimiter + +; Starlark-specific +; Assertion calls +(assert_keyword) @keyword + +(assert_builtin) @function.builtin + +; Struct definitions +((call + function: (identifier) @_func + arguments: (argument_list + (keyword_argument + name: (identifier) @variable.member))) + (#eq? @_func "struct")) + +; Function calls +(call + function: (identifier) @function.call) + +(call + function: (attribute + attribute: (identifier) @function.method.call)) + +((call + function: (identifier) @constructor) + (#lua-match? @constructor "^[A-Z]")) + +((call + function: (attribute + attribute: (identifier) @constructor)) + (#lua-match? @constructor "^[A-Z]")) diff --git a/runtime/queries/starlark/indents.scm b/runtime/queries/starlark/indents.scm new file mode 100644 index 000000000..1aeb9f60e --- /dev/null +++ b/runtime/queries/starlark/indents.scm @@ -0,0 +1,56 @@ +[ + (list) + (dictionary) + (set) + (for_statement) + (if_statement) + (while_statement) + (with_statement) + (parenthesized_expression) + (dictionary_comprehension) + (list_comprehension) + (set_comprehension) + (tuple_pattern) + (list_pattern) + (binary_operator) + (lambda) + (function_definition) +] @indent.begin + +(if_statement + condition: (parenthesized_expression) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +((ERROR + "(" + . + (_)) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +((argument_list) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +((argument_list) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +((parameters) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +((tuple) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +[ + ")" + "]" + "}" + (elif_clause) + (else_clause) +] @indent.branch + +(string) @indent.auto diff --git a/runtime/queries/starlark/injections.scm b/runtime/queries/starlark/injections.scm new file mode 100644 index 000000000..2b60646e2 --- /dev/null +++ b/runtime/queries/starlark/injections.scm @@ -0,0 +1 @@ +; inherits python diff --git a/runtime/queries/starlark/locals.scm b/runtime/queries/starlark/locals.scm new file mode 100644 index 000000000..82ec0b5d2 --- /dev/null +++ b/runtime/queries/starlark/locals.scm @@ -0,0 +1,96 @@ +; Program structure +(module) @local.scope + +; Function with parameters, defines parameters +(parameters + (identifier) @local.definition.parameter) + +(default_parameter + (identifier) @local.definition.parameter) + +(typed_parameter + (identifier) @local.definition.parameter) + +(typed_default_parameter + (identifier) @local.definition.parameter) + +; *args parameter +(parameters + (list_splat_pattern + (identifier) @local.definition.parameter)) + +; **kwargs parameter +(parameters + (dictionary_splat_pattern + (identifier) @local.definition.parameter)) + +; Function defines function and scope +((function_definition + name: (identifier) @local.definition.function) @local.scope + (#set! definition.function.scope "parent")) + +; Loops +; not a scope! +(for_statement + left: (pattern_list + (identifier) @local.definition.var)) + +(for_statement + left: (tuple_pattern + (identifier) @local.definition.var)) + +(for_statement + left: (identifier) @local.definition.var) + +; for in list comprehension +(for_in_clause + left: (identifier) @local.definition.var) + +(for_in_clause + left: (tuple_pattern + (identifier) @local.definition.var)) + +(for_in_clause + left: (pattern_list + (identifier) @local.definition.var)) + +(dictionary_comprehension) @local.scope + +(list_comprehension) @local.scope + +(set_comprehension) @local.scope + +; Assignments +(assignment + left: (identifier) @local.definition.var) + +(assignment + left: (pattern_list + (identifier) @local.definition.var)) + +(assignment + left: (tuple_pattern + (identifier) @local.definition.var)) + +(assignment + left: (attribute + (identifier) + (identifier) @local.definition.field)) + +; Walrus operator x := 1 +(named_expression + (identifier) @local.definition.var) + +(as_pattern + alias: (as_pattern_target) @local.definition.var) + +; REFERENCES +(identifier) @local.reference + +; Starlark-specific +; Loads +((call + function: (identifier) @_fn + arguments: (argument_list + (string) @local.definition.import)) + (#eq? @_fn "load")) diff --git a/runtime/queries/strace/highlights.scm b/runtime/queries/strace/highlights.scm new file mode 100644 index 000000000..70a14fd2d --- /dev/null +++ b/runtime/queries/strace/highlights.scm @@ -0,0 +1,56 @@ +[ + "killed" + "by" + "exited" + "with" + "<unfinished ...>" + "<..." + "resumed>" +] @keyword + +[ + (errorName) + (errorDescription) +] @keyword.exception + +(syscall) @function.builtin + +; Literals +[ + (integer) + (pointer) +] @number + +(value) @label + +(string) @string + +[ + "=" + "|" + "*" + "&&" + "==" +] @operator + +; Punctuation +[ + "+++" + "---" + "..." + "~" +] @punctuation.special + +[ + "(" + ")" + "[" + "]" +] @punctuation.bracket + +[ + "," + "=>" +] @punctuation.delimiter + +(comment) @comment @spell diff --git a/runtime/queries/strace/injections.scm b/runtime/queries/strace/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/strace/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/styled/folds.scm b/runtime/queries/styled/folds.scm new file mode 100644 index 000000000..cbe41875e --- /dev/null +++ b/runtime/queries/styled/folds.scm @@ -0,0 +1 @@ +; inherits: css diff --git a/runtime/queries/styled/highlights.scm b/runtime/queries/styled/highlights.scm new file mode 100644 index 000000000..cbe41875e --- /dev/null +++ b/runtime/queries/styled/highlights.scm @@ -0,0 +1 @@ +; inherits: css diff --git a/runtime/queries/styled/indents.scm b/runtime/queries/styled/indents.scm new file mode 100644 index 000000000..cbe41875e --- /dev/null +++ b/runtime/queries/styled/indents.scm @@ -0,0 +1 @@ +; inherits: css diff --git a/runtime/queries/styled/injections.scm b/runtime/queries/styled/injections.scm new file mode 100644 index 000000000..cbe41875e --- /dev/null +++ b/runtime/queries/styled/injections.scm @@ -0,0 +1 @@ +; inherits: css diff --git a/runtime/queries/supercollider/folds.scm b/runtime/queries/supercollider/folds.scm new file mode 100644 index 000000000..2f5f1043a --- /dev/null +++ b/runtime/queries/supercollider/folds.scm @@ -0,0 +1,6 @@ +[ + (function_call) + (code_block) + (function_block) + (control_structure) +] @fold diff --git a/runtime/queries/supercollider/highlights.scm b/runtime/queries/supercollider/highlights.scm new file mode 100644 index 000000000..c56bce69a --- /dev/null +++ b/runtime/queries/supercollider/highlights.scm @@ -0,0 +1,103 @@ +; highlights.scm +; See this for full list: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md +; comments +(line_comment) @comment @spell + +(block_comment) @comment @spell + +; Argument definition +(argument + name: (identifier) @variable.parameter) + +; Variables +(local_var + name: (identifier) @variable) + +(environment_var + name: (identifier) @variable.builtin) + +(builtin_var) @constant.builtin + +; (variable) @variable +; Functions +(function_definition + name: (variable) @function) + +; For function calls +(named_argument + name: (identifier) @function.call) + +; Methods +(method_call + name: (method_name) @function.method.call) + +; Classes +(class) @type + +; Literals +(number) @number + +(float) @number.float + +(string) @string + +(symbol) @string.special.symbol + +; Operators +[ + "&&" + "||" + "&" + "|" + "^" + "==" + "!=" + "<" + "<=" + ">" + ">=" + "<<" + ">>" + "+" + "-" + "*" + "/" + "%" + "=" +] @operator + +; Keywords +[ + "arg" + "classvar" + "const" + ; "super" + ; "this" + "var" +] @keyword + +; Brackets +[ + "(" + ")" + "[" + "]" + "{" + "}" + "|" +] @punctuation.bracket + +; Delimiters +[ + ";" + "." + "," +] @punctuation.delimiter + +; control structure +(control_structure) @keyword.conditional + +(escape_sequence) @string.escape + +; SinOsc.ar()!2 +(duplicated_statement) @keyword.repeat diff --git a/runtime/queries/supercollider/indents.scm b/runtime/queries/supercollider/indents.scm new file mode 100644 index 000000000..c0cffab3c --- /dev/null +++ b/runtime/queries/supercollider/indents.scm @@ -0,0 +1,33 @@ +[ + (function_block) + (binary_expression) + (collection) + (indexed_collection) + (parameter_call_list) + (function_call) + (class_def) + (classvar) + (const) + (instance_var) + (variable_definition) + (variable_definition_sequence + (variable_definition)) + (control_structure) + (return_statement) +] @indent.begin + +[ + (parameter_call_list + (argument_calls)) + "(" + ")" + "{" + "}" + "[" + "]" +] @indent.branch + +[ + (block_comment) + (line_comment) +] @indent.ignore diff --git a/runtime/queries/supercollider/injections.scm b/runtime/queries/supercollider/injections.scm new file mode 100644 index 000000000..3cd6aac8e --- /dev/null +++ b/runtime/queries/supercollider/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/supercollider/locals.scm b/runtime/queries/supercollider/locals.scm new file mode 100644 index 000000000..066bbf9ab --- /dev/null +++ b/runtime/queries/supercollider/locals.scm @@ -0,0 +1,29 @@ +; Scopes +[ + (function_call) + (code_block) + (function_block) + (control_structure) +] @local.scope + +; Definitions +(argument + name: (identifier) @local.definition.parameter + (#set! definition.var.scope "local")) + +(variable_definition + name: (variable + (local_var + (identifier) @local.definition.var))) + +(variable_definition + name: (variable + (environment_var + (identifier) @local.definition.var)) + (#set! definition.var.scope "global")) + +(function_definition + name: (variable) @local.definition.var + (#set! definition.var.scope "parent")) + +(identifier) @local.reference diff --git a/runtime/queries/superhtml/highlights.scm b/runtime/queries/superhtml/highlights.scm new file mode 100644 index 000000000..cbf366d1c --- /dev/null +++ b/runtime/queries/superhtml/highlights.scm @@ -0,0 +1,44 @@ +(doctype) @constant + +(comment) @comment + +(tag_name) @tag + +((tag_name) @string.special + (#any-of? @string.special "super" "extend")) + +(attribute_name) @attribute + +(attribute_value) @string + +((element + (start_tag + (attribute + (attribute_name) @_attribute + [ + (attribute_value) @markup.link.url + (quoted_attribute_value + (attribute_value) @markup.link.url) + ])) + (element + (start_tag + (tag_name) @tag))) + (#eq? @tag "super") + (#eq? @_attribute "id")) + +(element + (start_tag + (tag_name) @string.special) + (#eq? @string.special "super")) + +"\"" @string + +[ + "<" + ">" + "</" + "/>" + "<!" +] @punctuation.bracket + +"=" @punctuation.delimiter diff --git a/runtime/queries/superhtml/injections.scm b/runtime/queries/superhtml/injections.scm new file mode 100644 index 000000000..138fe7c23 --- /dev/null +++ b/runtime/queries/superhtml/injections.scm @@ -0,0 +1,7 @@ +((script_element + (raw_text) @injection.content) + (#set! injection.language "javascript")) + +((style_element + (raw_text) @injection.content) + (#set! injection.language "css")) diff --git a/runtime/queries/surface/folds.scm b/runtime/queries/surface/folds.scm new file mode 100644 index 000000000..994f12e1e --- /dev/null +++ b/runtime/queries/surface/folds.scm @@ -0,0 +1,6 @@ +; Surface folds similar to HTML and includes blocks +[ + (tag) + (component) + (block) +] @fold diff --git a/runtime/queries/surface/highlights.scm b/runtime/queries/surface/highlights.scm new file mode 100644 index 000000000..b874b8c1d --- /dev/null +++ b/runtime/queries/surface/highlights.scm @@ -0,0 +1,44 @@ +; Surface text is not highlighted +(text) @none + +; Surface has two types of comments, both are highlighted as such +(comment) @comment @spell + +; Surface attributes are highlighted as HTML attributes +(attribute_name) @tag.attribute + +; Attributes are highlighted as strings +(quoted_attribute_value) @string + +; Surface blocks are highlighted as keywords +[ + (start_block) + (end_block) + (subblock) +] @keyword + +; Surface supports HTML tags and are highlighted as such +[ + "<" + ">" + "</" + "/>" + "{" + "}" + "<!--" + "-->" + "{!--" + "--}" +] @tag.delimiter + +; Surface tags are highlighted as HTML +(tag_name) @tag + +; Surface components are highlighted as types (Elixir modules) +(component_name) @type + +; Surface directives are highlighted as keywords +(directive_name) @keyword + +; Surface operators +"=" @operator diff --git a/runtime/queries/surface/indents.scm b/runtime/queries/surface/indents.scm new file mode 100644 index 000000000..1df9fe6fd --- /dev/null +++ b/runtime/queries/surface/indents.scm @@ -0,0 +1,14 @@ +; Surface indents like HTML, with the addition of blocks +[ + (component) + (tag) + (block) +] @indent.begin + +; Dedent at the end of each tag, as well as a subblock +[ + (end_tag) + (end_component) + (end_block) + (subblock) +] @indent.branch diff --git a/runtime/queries/surface/injections.scm b/runtime/queries/surface/injections.scm new file mode 100644 index 000000000..72cab5e80 --- /dev/null +++ b/runtime/queries/surface/injections.scm @@ -0,0 +1,10 @@ +; Surface expressions and components are Elixir code +([ + (expression_value) + (component_name) +] @injection.content + (#set! injection.language "elixir")) + +; Surface comments are nvim-treesitter comments +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/svelte/folds.scm b/runtime/queries/svelte/folds.scm new file mode 100644 index 000000000..6440301af --- /dev/null +++ b/runtime/queries/svelte/folds.scm @@ -0,0 +1,13 @@ +; inherits: html + +[ + (if_statement) + (else_if_block) + (else_block) + (each_statement) + (await_statement) + (then_block) + (catch_block) + (key_statement) + (snippet_statement) +] @fold diff --git a/runtime/queries/svelte/highlights.scm b/runtime/queries/svelte/highlights.scm new file mode 100644 index 000000000..dc98290dd --- /dev/null +++ b/runtime/queries/svelte/highlights.scm @@ -0,0 +1,43 @@ +; inherits: html + +(raw_text) @none + +[ + "as" + "key" + "html" + "snippet" + "render" +] @keyword + +"const" @keyword.modifier + +[ + "if" + "else if" + "else" + "then" +] @keyword.conditional + +"each" @keyword.repeat + +[ + "await" + "then" +] @keyword.coroutine + +"catch" @keyword.exception + +"debug" @keyword.debug + +[ + "{" + "}" +] @punctuation.bracket + +[ + "#" + ":" + "/" + "@" +] @tag.delimiter diff --git a/runtime/queries/svelte/indents.scm b/runtime/queries/svelte/indents.scm new file mode 100644 index 000000000..0c67647d7 --- /dev/null +++ b/runtime/queries/svelte/indents.scm @@ -0,0 +1,34 @@ +; inherits: html + +[ + (if_statement) + (each_statement) + (await_statement) + (key_statement) + (snippet_statement) +] @indent.begin + +(if_end + "}" @indent.end) + +(each_end + "}" @indent.end) + +(await_end + "}" @indent.end) + +(key_end + "}" @indent.end) + +(snippet_end + "}" @indent.end) + +[ + (if_end) + (else_if_block) + (else_block) + (each_end) + (await_end) + (key_end) + (snippet_end) +] @indent.branch diff --git a/runtime/queries/svelte/injections.scm b/runtime/queries/svelte/injections.scm new file mode 100644 index 000000000..f20ae66c8 --- /dev/null +++ b/runtime/queries/svelte/injections.scm @@ -0,0 +1,47 @@ +; inherits: html_tags + +((style_element + (start_tag + (attribute + (attribute_name) @_attr + (quoted_attribute_value + (attribute_value) @_lang))) + (raw_text) @injection.content) + (#eq? @_attr "lang") + (#any-of? @_lang "scss" "postcss" "less") + (#set! injection.language "scss")) + +((svelte_raw_text) @injection.content + (#set! injection.language "javascript")) + +((script_element + (start_tag + (attribute + (attribute_name) @_attr + (quoted_attribute_value + (attribute_value) @_lang))) + (raw_text) @injection.content) + (#eq? @_attr "lang") + (#any-of? @_lang "ts" "typescript") + (#set! injection.language "typescript")) + +((script_element + (start_tag + (attribute + (attribute_name) @_attr + (quoted_attribute_value + (attribute_value) @_lang))) + (raw_text) @injection.content) + (#eq? @_attr "lang") + (#any-of? @_lang "js" "javascript") + (#set! injection.language "javascript")) + +((element + (start_tag + (attribute + (attribute_name) @_attr + (quoted_attribute_value + (attribute_value) @injection.language))) + (text) @injection.content) + (#eq? @_attr "lang") + (#eq? @injection.language "pug")) diff --git a/runtime/queries/svelte/locals.scm b/runtime/queries/svelte/locals.scm new file mode 100644 index 000000000..1f2129cf9 --- /dev/null +++ b/runtime/queries/svelte/locals.scm @@ -0,0 +1 @@ +; inherits: html diff --git a/runtime/queries/sway/folds.scm b/runtime/queries/sway/folds.scm new file mode 100644 index 000000000..ba8474aa2 --- /dev/null +++ b/runtime/queries/sway/folds.scm @@ -0,0 +1,20 @@ +[ + (mod_item) + (function_item) + (struct_item) + (trait_item) + (enum_item) + (impl_item) + (type_item) + (const_item) + (let_declaration) + (for_expression) + (while_expression) + (if_expression) + (match_expression) + (call_expression) + (array_expression) + (attribute_item) + (block) + (use_declaration)+ +] @fold diff --git a/runtime/queries/sway/highlights.scm b/runtime/queries/sway/highlights.scm new file mode 100644 index 000000000..e408464fe --- /dev/null +++ b/runtime/queries/sway/highlights.scm @@ -0,0 +1,336 @@ +(type_identifier) @type + +(identifier) @variable + +(field_identifier) @variable.member + +(escape_sequence) @string.escape + +(primitive_type) @type.builtin + +(boolean_literal) @boolean + +(integer_literal) @number + +(float_literal) @number.float + +(char_literal) @character + +; ------- +; Paths +; ------- +(use_declaration + argument: (identifier) @module) + +(use_wildcard + (identifier) @module) + +(mod_item + name: (identifier) @module) + +(scoped_use_list + path: (identifier)? @module) + +(use_list + (identifier) @module) + +(use_as_clause + path: (identifier)? @module + alias: (identifier) @module) + +; --- +; Remaining Paths +; --- +(scoped_identifier + path: (identifier)? @module + name: (identifier) @module) + +(scoped_type_identifier + path: (identifier) @module) + +[ + "*" + "'" + "->" + "=>" + "<=" + "=" + "==" + "!" + "!=" + "%" + "%=" + "&" + "&=" + "&&" + "|" + "|=" + "||" + "^" + "^=" + "*" + "*=" + "-" + "-=" + "+" + "+=" + "/" + "/=" + ">" + "<" + ">=" + ">>" + "<<" + ">>=" + "<<=" + "@" + ".." + "..=" + "'" + "?" +] @operator + +(use_wildcard + "*" @character.special) + +[ + (string_literal) + (raw_string_literal) +] @string + +[ + (line_comment) + (block_comment) +] @comment + +; --- +; Extraneous +; --- +(self) @variable.builtin + +(enum_variant + (identifier) @constant) + +(field_initializer + (field_identifier) @variable.member) + +(shorthand_field_initializer + (identifier) @variable.member) + +(shorthand_field_identifier) @variable.member + +(loop_label + "'" @label + (identifier) @label) + +; --- +; Punctuation +; --- +[ + "::" + ":" + "." + ";" + "," +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "#" +] @punctuation.bracket + +(type_arguments + [ + "<" + ">" + ] @punctuation.bracket) + +(type_parameters + [ + "<" + ">" + ] @punctuation.bracket) + +(closure_parameters + "|" @punctuation.bracket) + +(let_declaration + pattern: [ + (identifier) @variable + (tuple_pattern + (identifier) @variable) + ]) + +; It needs to be anonymous to not conflict with `call_expression` further below. +(_ + value: (field_expression + value: (identifier)? @variable + field: (field_identifier) @variable.member)) + +(parameter + pattern: (identifier) @variable.parameter) + +(parameter + pattern: (ref_pattern + [ + (mut_pattern + (identifier) @variable.parameter) + (identifier) @variable.parameter + ])) + +(closure_parameters + (identifier) @variable.parameter) + +(for_expression + "for" @keyword.repeat) + +"in" @keyword.repeat + +[ + "match" + "if" + "else" +] @keyword.conditional + +"while" @keyword.repeat + +[ + "break" + "continue" + "return" + "yield" +] @keyword.return + +"use" @keyword.import + +(mod_item + "mod" @keyword.import + !body) + +(use_as_clause + "as" @keyword.import) + +(type_cast_expression + "as" @keyword.operator) + +[ + "as" + "mod" + "abi" + "impl" + "where" + "trait" + "for" + "let" + "contract" + "script" + "predicate" + "library" +] @keyword + +[ + "struct" + "enum" + "storage" + "configurable" + "type" +] @keyword.type + +[ + "fn" + "abi" +] @keyword.function + +[ + (mutable_specifier) + "const" + "ref" + "deref" + "move" + "pub" +] @keyword.modifier + +(reference_type + "&" @keyword.modifier) + +(self_parameter + "&" @keyword.modifier) + +; ------- +; Guess Other Types +; ------- +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z%d_]*$")) + +; --- +; PascalCase identifiers in call_expressions (e.g. `Ok()`) +; are assumed to be enum constructors. +; --- +(call_expression + function: [ + ((identifier) @constant + (#lua-match? @constant "^[A-Z]")) + (scoped_identifier + name: ((identifier) @constant + (#lua-match? @constant "^[A-Z]"))) + ]) + +; --- +; Assume that types in match arms are enums and not +; tuple structs. Same for `if let` expressions. +; --- +(match_pattern + (scoped_identifier + name: (identifier) @constructor)) + +(tuple_struct_pattern + type: [ + (identifier) @constructor + (scoped_identifier + name: (identifier) @constructor) + ]) + +(struct_pattern + type: [ + (type_identifier) @constructor + (scoped_type_identifier + name: (type_identifier) @constructor) + ]) + +; --- +; Other PascalCase identifiers are assumed to be structs. +; --- +((identifier) @type + (#lua-match? @type "^[A-Z]")) + +; ------- +; Functions +; ------- +(call_expression + function: [ + (identifier) @function.call + (scoped_identifier + name: (identifier) @function.call) + (field_expression + field: (field_identifier) @function.method.call) + ]) + +(generic_function + function: [ + (identifier) @function.call + (scoped_identifier + name: (identifier) @function.call) + (field_expression + field: (field_identifier) @function.method.call) + ]) + +(function_item + name: (identifier) @function) + +(function_signature_item + name: (identifier) @function) diff --git a/runtime/queries/sway/indents.scm b/runtime/queries/sway/indents.scm new file mode 100644 index 000000000..151d8b20b --- /dev/null +++ b/runtime/queries/sway/indents.scm @@ -0,0 +1,95 @@ +[ + (mod_item) + (struct_item) + (enum_item) + (impl_item) + (struct_expression) + (struct_pattern) + (tuple_struct_pattern) + (tuple_expression) + (tuple_type) + (tuple_pattern) + (match_block) + (call_expression) + (asm_block) + (asm_parameters) + (assignment_expression) + (arguments) + (block) + (where_clause) + (use_list) + (array_expression) + (ordered_field_declaration_list) + (field_declaration_list) + (enum_variant_list) + (parameters) + (token_tree) +] @indent.begin + +(trait_item + body: (_) @indent.begin) + +(string_literal + (escape_sequence)) @indent.begin + +(block + "}" @indent.end) + +(asm_block + "}" @indent.end) + +(enum_item + body: (enum_variant_list + "}" @indent.end)) + +(impl_item + body: (declaration_list + "}" @indent.end)) + +(match_expression + body: (match_block + "}" @indent.end)) + +(struct_item + body: (field_declaration_list + "}" @indent.end)) + +(struct_expression + body: (field_initializer_list + "}" @indent.end)) + +(struct_pattern + "}" @indent.end) + +(tuple_struct_pattern + ")" @indent.end) + +(tuple_type + ")" @indent.end) + +(tuple_pattern + ")" @indent.end) + +(trait_item + body: (declaration_list + "}" @indent.end)) + +(impl_item + (where_clause) @indent.dedent) + +[ + "where" + ")" + "]" + "}" +] @indent.branch + +(impl_item + (declaration_list) @indent.branch) + +[ + (line_comment) + (string_literal) +] @indent.ignore + +(raw_string_literal) @indent.auto diff --git a/runtime/queries/sway/injections.scm b/runtime/queries/sway/injections.scm new file mode 100644 index 000000000..3cd6aac8e --- /dev/null +++ b/runtime/queries/sway/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/sway/locals.scm b/runtime/queries/sway/locals.scm new file mode 100644 index 000000000..5c2ade83a --- /dev/null +++ b/runtime/queries/sway/locals.scm @@ -0,0 +1,16 @@ +; Scopes +[ + (function_item) + (closure_expression) + (block) +] @local.scope + +; Definitions +(parameter + (identifier) @local.definition) + +(closure_parameters + (identifier) @local.definition) + +; References +(identifier) @local.reference diff --git a/runtime/queries/swift/folds.scm b/runtime/queries/swift/folds.scm new file mode 100644 index 000000000..cfbc6d0b1 --- /dev/null +++ b/runtime/queries/swift/folds.scm @@ -0,0 +1,35 @@ +; format-ignore +[ + (protocol_body) ; protocol Foo { ... } + (class_body) ; class Foo { ... } + (enum_class_body) ; enum Foo { ... } + (function_body) ; func Foo (...) {...} + (computed_property) ; { ... } + + (computed_getter) ; get { ... } + (computed_setter) ; set { ... } + + (do_statement) + (if_statement) + (for_statement) + (switch_statement) + (while_statement) + (guard_statement) + (switch_entry) + + (type_parameters) ; x<Foo> + (tuple_type) ; (...) + (array_type) ; [String] + (dictionary_type) ; [Foo: Bar] + + (call_expression) ; callFunc(...) + (tuple_expression) ; ( foo + bar ) + (array_literal) ; [ foo, bar ] + (dictionary_literal) ; [ foo: bar, x: y ] + (lambda_literal) + (willset_didset_block) + (willset_clause) + (didset_clause) + + (import_declaration)+ +] @fold diff --git a/runtime/queries/swift/highlights.scm b/runtime/queries/swift/highlights.scm new file mode 100644 index 000000000..5c52ee9d6 --- /dev/null +++ b/runtime/queries/swift/highlights.scm @@ -0,0 +1,347 @@ +[ + "." + ";" + ":" + "," +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; Identifiers +(type_identifier) @type + +[ + (self_expression) + (super_expression) +] @variable.builtin + +; Declarations +[ + "func" + "deinit" +] @keyword.function + +[ + (visibility_modifier) + (member_modifier) + (function_modifier) + (property_modifier) + (parameter_modifier) + (inheritance_modifier) + (mutation_modifier) +] @keyword.modifier + +(simple_identifier) @variable + +(function_declaration + (simple_identifier) @function.method) + +(protocol_function_declaration + name: (simple_identifier) @function.method) + +(init_declaration + "init" @constructor) + +(parameter + external_name: (simple_identifier) @variable.parameter) + +(parameter + name: (simple_identifier) @variable.parameter) + +(type_parameter + (type_identifier) @variable.parameter) + +(inheritance_constraint + (identifier + (simple_identifier) @variable.parameter)) + +(equality_constraint + (identifier + (simple_identifier) @variable.parameter)) + +[ + "protocol" + "extension" + "indirect" + "nonisolated" + "override" + "convenience" + "required" + "some" + "any" + "weak" + "unowned" + "didSet" + "willSet" + "subscript" + "let" + "var" + (throws) + (where_keyword) + (getter_specifier) + (setter_specifier) + (modify_specifier) + (else) + (as_operator) +] @keyword + +[ + "enum" + "struct" + "class" + "typealias" +] @keyword.type + +[ + "async" + "await" +] @keyword.coroutine + +(shebang_line) @keyword.directive + +(class_body + (property_declaration + (pattern + (simple_identifier) @variable.member))) + +(protocol_property_declaration + (pattern + (simple_identifier) @variable.member)) + +(navigation_expression + (navigation_suffix + (simple_identifier) @variable.member)) + +(value_argument + name: (value_argument_label + (simple_identifier) @variable.member)) + +(import_declaration + "import" @keyword.import) + +(enum_entry + "case" @keyword) + +(modifiers + (attribute + "@" @attribute + (user_type + (type_identifier) @attribute))) + +; Function calls +(call_expression + (simple_identifier) @function.call) ; foo() + +(call_expression + ; foo.bar.baz(): highlight the baz() + (navigation_expression + (navigation_suffix + (simple_identifier) @function.call))) + +(call_expression + (prefix_expression + (simple_identifier) @function.call)) ; .foo() + +((navigation_expression + (simple_identifier) @type) ; SomeType.method(): highlight SomeType as a type + (#lua-match? @type "^[A-Z]")) + +(directive) @keyword.directive + +; See https://docs.swift.org/swift-book/documentation/the-swift-programming-language/lexicalstructure/#Keywords-and-Punctuation +[ + (diagnostic) + "#available" + "#unavailable" + "#fileLiteral" + "#colorLiteral" + "#imageLiteral" + "#keyPath" + "#selector" + "#externalMacro" +] @function.macro + +[ + "#column" + "#dsohandle" + "#fileID" + "#filePath" + "#file" + "#function" + "#line" +] @constant.macro + +; Statements +(for_statement + "for" @keyword.repeat) + +(for_statement + "in" @keyword.repeat) + +[ + "while" + "repeat" + "continue" + "break" +] @keyword.repeat + +(guard_statement + "guard" @keyword.conditional) + +(if_statement + "if" @keyword.conditional) + +(switch_statement + "switch" @keyword.conditional) + +(switch_entry + "case" @keyword) + +(switch_entry + "fallthrough" @keyword) + +(switch_entry + (default_keyword) @keyword) + +"return" @keyword.return + +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +[ + (try_operator) + "do" + (throw_keyword) + (catch_keyword) +] @keyword.exception + +(statement_label) @label + +; Comments +[ + (comment) + (multiline_comment) +] @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) + +((multiline_comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +; String literals +(line_str_text) @string + +(str_escaped_char) @string.escape + +(multi_line_str_text) @string + +(raw_str_part) @string + +(raw_str_end_part) @string + +(line_string_literal + [ + "\\(" + ")" + ] @punctuation.special) + +(multi_line_string_literal + [ + "\\(" + ")" + ] @punctuation.special) + +(raw_str_interpolation + [ + (raw_str_interpolation_start) + ")" + ] @punctuation.special) + +[ + "\"" + "\"\"\"" +] @string + +; Lambda literals +(lambda_literal + "in" @keyword.operator) + +; Basic literals +[ + (integer_literal) + (hex_literal) + (oct_literal) + (bin_literal) +] @number + +(real_literal) @number.float + +(boolean_literal) @boolean + +"nil" @constant.builtin + +(wildcard_pattern) @character.special + +; Regex literals +(regex_literal) @string.regexp + +; Operators +(custom_operator) @operator + +[ + "+" + "-" + "*" + "/" + "%" + "=" + "+=" + "-=" + "*=" + "/=" + "<" + ">" + "<<" + ">>" + "<=" + ">=" + "++" + "--" + "^" + "&" + "&&" + "|" + "||" + "~" + "%=" + "!=" + "!==" + "==" + "===" + "?" + "??" + "->" + "..<" + "..." + (bang) +] @operator + +(type_arguments + [ + "<" + ">" + ] @punctuation.bracket) diff --git a/runtime/queries/swift/indents.scm b/runtime/queries/swift/indents.scm new file mode 100644 index 000000000..2366c3bd6 --- /dev/null +++ b/runtime/queries/swift/indents.scm @@ -0,0 +1,122 @@ +; format-ignore +[ + ; ... refers to the section that will get affected by this indent.begin capture + (protocol_body) ; protocol Foo { ... } + (class_body) ; class Foo { ... } + (enum_class_body) ; enum Foo { ... } + (function_declaration) ; func Foo (...) {...} + (init_declaration) ; init(...) {...} + (deinit_declaration) ; deinit {...} + (computed_property) ; { ... } + (subscript_declaration) ; subscript Foo(...) { ... } + + (computed_getter) ; get { ... } + (computed_setter) ; set { ... } + + (assignment) ; a = b + + (control_transfer_statement) ; return ... + (for_statement) + (while_statement) + (repeat_while_statement) + (do_statement) + (if_statement) + (switch_statement) + (guard_statement) + + (type_parameters) ; x<Foo> + (tuple_type) ; (...) + (array_type) ; [String] + (dictionary_type) ; [Foo: Bar] + + (call_expression) ; callFunc(...) + (tuple_expression) ; ( foo + bar ) + (array_literal) ; [ foo, bar ] + (dictionary_literal) ; [ foo: bar, x: y ] + (lambda_literal) + (willset_didset_block) + (willset_clause) + (didset_clause) +] @indent.begin + +(init_declaration) @indent.begin + +(init_declaration + [ + "init" + "(" + ] @indent.branch) + +; indentation for init parameters +(init_declaration + ")" @indent.branch @indent.end) + +(init_declaration + (parameter) @indent.begin + (#set! indent.immediate)) + +; @something(...) +(modifiers + (attribute) @indent.begin) + +(function_declaration + (modifiers + . + (attribute) + (_)* @indent.branch) + . + _ @indent.branch + (#not-kind-eq? @indent.branch "type_parameters" "parameter")) + +(ERROR + [ + "<" + "{" + "(" + "[" + ]) @indent.begin + +; if-elseif +(if_statement + (if_statement) @indent.dedent) + +; case Foo: +; default Foo: +; @attribute default Foo: +(switch_entry + . + _ @indent.branch) + +(function_declaration + ")" @indent.branch) + +(type_parameters + ">" @indent.branch @indent.end .) + +(tuple_expression + ")" @indent.branch @indent.end) + +(value_arguments + ")" @indent.branch @indent.end) + +(tuple_type + ")" @indent.branch @indent.end) + +(modifiers + (attribute + ")" @indent.branch @indent.end)) + +[ + "}" + "]" +] @indent.branch @indent.end + +[ + ; (ERROR) + (comment) + (multiline_comment) + (raw_str_part) + (multi_line_string_literal) +] @indent.auto + +(directive) @indent.ignore diff --git a/runtime/queries/swift/injections.scm b/runtime/queries/swift/injections.scm new file mode 100644 index 000000000..19aae904e --- /dev/null +++ b/runtime/queries/swift/injections.scm @@ -0,0 +1,5 @@ +([ + (comment) + (multiline_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/swift/locals.scm b/runtime/queries/swift/locals.scm new file mode 100644 index 000000000..dc8a62e9e --- /dev/null +++ b/runtime/queries/swift/locals.scm @@ -0,0 +1,21 @@ +(import_declaration + (identifier) @local.definition.import) + +(function_declaration + name: (simple_identifier) @local.definition.function) + +; Scopes +[ + (statements) + (for_statement) + (while_statement) + (repeat_while_statement) + (do_statement) + (if_statement) + (guard_statement) + (switch_statement) + (property_declaration) + (function_declaration) + (class_declaration) + (protocol_declaration) +] @local.scope diff --git a/runtime/queries/sxhkdrc/folds.scm b/runtime/queries/sxhkdrc/folds.scm new file mode 100644 index 000000000..c6634aaef --- /dev/null +++ b/runtime/queries/sxhkdrc/folds.scm @@ -0,0 +1 @@ +(binding) @fold diff --git a/runtime/queries/sxhkdrc/highlights.scm b/runtime/queries/sxhkdrc/highlights.scm new file mode 100644 index 000000000..3f633a73d --- /dev/null +++ b/runtime/queries/sxhkdrc/highlights.scm @@ -0,0 +1,19 @@ +(modifier) @keyword + +(operator) @operator + +(attribute) @attribute + +(command_sync_prefix) @type + +(punctuation) @punctuation.bracket + +(delimiter) @punctuation.delimiter + +(keysym) @variable + +(comment) @comment @spell + +(range) @number + +"\\\n" @punctuation.special diff --git a/runtime/queries/sxhkdrc/injections.scm b/runtime/queries/sxhkdrc/injections.scm new file mode 100644 index 000000000..d962c7a84 --- /dev/null +++ b/runtime/queries/sxhkdrc/injections.scm @@ -0,0 +1,5 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((command) @injection.content + (#set! injection.language "bash")) diff --git a/runtime/queries/systemtap/folds.scm b/runtime/queries/systemtap/folds.scm new file mode 100644 index 000000000..58bb03e51 --- /dev/null +++ b/runtime/queries/systemtap/folds.scm @@ -0,0 +1,18 @@ +[ + (preprocessor_macro_definition) + (preprocessor_macro_expansion) + (conditional_preprocessing) + (embedded_code) + (probe_point_definition) + (probe_point_alias_prologue) + (probe_point_alias_epilogue) + (variable_declaration) + (function_definition) + (if_statement) + (while_statement) + (for_statement) + (foreach_statement) + (try_statement) + (catch_clause) + (comment) +] @fold diff --git a/runtime/queries/systemtap/highlights.scm b/runtime/queries/systemtap/highlights.scm new file mode 100644 index 000000000..d1348dc91 --- /dev/null +++ b/runtime/queries/systemtap/highlights.scm @@ -0,0 +1,158 @@ +(identifier) @variable + +(preprocessor_macro_definition + name: (identifier) @function.macro) + +(preprocessor_macro_expansion) @function.macro + +(preprocessor_constant) @constant.macro + +(number) @number + +(string) @string + +(escape_sequence) @string.escape + +[ + (script_argument_string) + (script_argument_number) +] @constant + +(probe_point_component) @function + +(function_definition + name: (identifier) @function) + +(parameter + name: (identifier) @variable.parameter) + +(type) @type.builtin + +(aggregation_operator) @attribute + +(member_expression + member: (identifier) @variable.member) + +(call_expression + function: (identifier) @function.call) + +((call_expression + function: (identifier) @function.builtin) + (#any-of? @function.builtin + "print" "printd" "printdln" "printf" "println" "sprint" "sprintd" "sprintdln" "sprintf" + "sprintln")) + +((identifier) @variable.builtin + (#lua-match? @variable.builtin "^\$+[0-9A-Z_a-z]+\$*$")) + +(shebang_line) @keyword.directive + +(comment) @comment @spell + +[ + "!" + "!=" + "!~" + "$" + "$$" + "%" + "%=" + "&" + "&&" + "&=" + "*" + "*=" + "+" + "++" + "+=" + "-" + "--" + "-=" + "->" + "." + ".=" + "/" + "/=" + ":" + "<" + "<<" + "<<<" + "<<=" + "<=" + "=" + "==" + "=~" + ">" + ">=" + ">>" + ">>=" + "?" + "^" + "^=" + "|" + "|=" + "||" + "~" +] @operator + +[ + "," + (null_statement) +] @punctuation.delimiter + +[ + "%{" + "%}" + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "delete" + "limit" + "next" + "probe" +] @keyword + +"function" @keyword.function + +"in" @keyword.operator + +"return" @keyword.return + +[ + "if" + "else" +] @keyword.conditional + +[ + "break" + "continue" + "for" + "foreach" + "while" +] @keyword.repeat + +[ + "try" + "catch" +] @keyword.exception + +[ + "%(" + "%)" + "%:" + "%?" + (preprocessor_tokens) + (embedded_code) +] @keyword.directive + +"@define" @keyword.directive.define + +"private" @keyword.modifier + +"global" @keyword.modifier diff --git a/runtime/queries/systemtap/injections.scm b/runtime/queries/systemtap/injections.scm new file mode 100644 index 000000000..591df6012 --- /dev/null +++ b/runtime/queries/systemtap/injections.scm @@ -0,0 +1,5 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((embedded_code) @injection.content + (#set! injection.language "c")) diff --git a/runtime/queries/systemtap/locals.scm b/runtime/queries/systemtap/locals.scm new file mode 100644 index 000000000..15056808c --- /dev/null +++ b/runtime/queries/systemtap/locals.scm @@ -0,0 +1,35 @@ +[ + (function_definition) + (statement_block) + (if_statement) + (while_statement) + (for_statement) + (foreach_statement) + (catch_clause) +] @local.scope + +(init_declarator + name: (identifier) @local.definition.var) + +(array_declarator + name: (identifier) @local.definition.var) + +(function_definition + name: (identifier) @local.definition.function) + +(parameter + name: (identifier) @local.definition.parameter) + +(tuple_capture + (identifier) @local.definition.var) + +(catch_clause + parameter: (identifier) @local.definition.var) + +(assignment_expression + left: (identifier) @local.definition.var) + +(call_expression + function: (identifier) @local.reference) + +(identifier) @local.reference diff --git a/runtime/queries/t32/folds.scm b/runtime/queries/t32/folds.scm new file mode 100644 index 000000000..fd7d23999 --- /dev/null +++ b/runtime/queries/t32/folds.scm @@ -0,0 +1 @@ +(block) @fold diff --git a/runtime/queries/t32/highlights.scm b/runtime/queries/t32/highlights.scm new file mode 100644 index 000000000..9211a49d2 --- /dev/null +++ b/runtime/queries/t32/highlights.scm @@ -0,0 +1,223 @@ +; Keywords, punctuation and operators +[ + "=" + "^^" + "||" + "&&" + "+" + "-" + "*" + "/" + "%" + "|" + "^" + "==" + "!=" + ">" + ">=" + "<=" + "<" + "<<" + ">>" + ".." + "--" + "++" + "+" + "-" + "~" + "!" + "&" + "->" + "*" + "-=" + "+=" + "*=" + "/=" + "%=" + "|=" + "&=" + "^=" + ">>=" + "<<=" + "--" + "++" +] @operator + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + "," + "." +] @punctuation.delimiter + +[ + "enum" + "struct" + "union" +] @keyword.type + +"sizeof" @keyword.operator + +[ + "const" + "volatile" +] @keyword.modifier + +; Operators in comma and conditional HLL expressions +(hll_comma_expression + "," @operator) + +(hll_conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +; Strings and others literal types +(access_class) @constant.builtin + +[ + (address) + (bitmask) + (file_handle) + (integer) + (hll_number_literal) +] @number + +[ + (float) + (frequency) + (percentage) + (time) +] @number.float + +[ + (string) + (hll_string_literal) +] @string + +(hll_escape_sequence) @string.escape + +(path) @string.special.path + +(symbol) @string.special.symbol + +[ + (character) + (hll_char_literal) +] @character + +; Types in HLL expressions +[ + (hll_type_identifier) + (hll_type_descriptor) +] @type + +(hll_type_qualifier) @keyword.modifier + +(hll_primitive_type) @type.builtin + +; HLL expressions +(hll_call_expression + function: (identifier) @function.call) + +(hll_call_expression + function: (hll_field_expression + field: (hll_field_identifier) @function.call)) + +; HLL variables +(identifier) @variable + +(hll_field_identifier) @variable.member + +; Commands +(command_expression + command: (identifier) @keyword) + +(macro_definition + command: (identifier) @keyword) + +(call_expression + function: (identifier) @function.builtin) + +; Returns +((command_expression + command: (identifier) @keyword.return) + (#match? @keyword.return "^[eE][nN][dD]([dD][oO])?$")) + +((command_expression + command: (identifier) @keyword.return) + (#lua-match? @keyword.return "^[rR][eE][tT][uU][rR][nN]$")) + +; Subroutine calls +(subroutine_call_expression + command: (identifier) @keyword + subroutine: (identifier) @function.call) + +; Variables, constants and labels +(macro) @variable.builtin + +(trace32_hll_variable) @variable.builtin + +(argument_list + (identifier) @constant.builtin) + +((argument_list + (identifier) @constant.builtin) + (#lua-match? @constant.builtin "^[%%/][%l%u][%l%u%d.]*$")) + +((command_expression + command: (identifier) @keyword + arguments: (argument_list + . + (identifier) @label)) + (#lua-match? @keyword "^[gG][oO][tT][oO]$")) + +(labeled_expression + label: (identifier) @label) + +(option_expression + (identifier) @constant.builtin) + +(format_expression + (identifier) @constant.builtin) + +; Subroutine blocks +(subroutine_block + command: (identifier) @keyword.function + subroutine: (identifier) @function) + +(labeled_expression + label: (identifier) @function + (block)) + +; Parameter declarations +(parameter_declaration + command: (identifier) @keyword + (identifier)? @constant.builtin + macro: (macro) @variable.parameter) + +; Control flow +(if_block + command: (identifier) @keyword.conditional) + +(elif_block + command: (identifier) @keyword.conditional) + +(else_block + command: (identifier) @keyword.conditional) + +(while_block + command: (identifier) @keyword.repeat) + +(repeat_block + command: (identifier) @keyword.repeat) + +(comment) @comment @spell diff --git a/runtime/queries/t32/indents.scm b/runtime/queries/t32/indents.scm new file mode 100644 index 000000000..01d5f3967 --- /dev/null +++ b/runtime/queries/t32/indents.scm @@ -0,0 +1,22 @@ +(block + ")" @indent.branch .) @indent.begin + +(if_block) @indent.begin + +(if_block + (block)) @indent.dedent + +(elif_block) @indent.branch + +(else_block) @indent.branch + +(else_block + (if_block) @indent.dedent) + +(while_block + (command_expression)) @indent.auto + +(repeat_block + (command_expression)) @indent.auto + +(comment) @indent.auto diff --git a/runtime/queries/t32/injections.scm b/runtime/queries/t32/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/t32/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/t32/locals.scm b/runtime/queries/t32/locals.scm new file mode 100644 index 000000000..91bf7660e --- /dev/null +++ b/runtime/queries/t32/locals.scm @@ -0,0 +1,36 @@ +(block) @local.scope + +; Parameter definitions +(parameter_declaration + command: (identifier) + macro: (macro) @local.definition.parameter) + +; Variable definitions +(macro_definition + command: (identifier) + macro: (macro) @local.definition.var) + +(command_expression + command: (identifier) + arguments: (argument_list + declarator: (trace32_hll_variable) @local.definition.var)) + +; Function definitions +(subroutine_block + command: (identifier) + subroutine: (identifier) @local.definition.function) + +(labeled_expression + label: (identifier) @local.definition.function + (block)) + +; References +((subroutine_call_expression + command: (identifier) + subroutine: (identifier) @local.reference) + (#set! reference.kind "function")) + +[ + (macro) + (trace32_hll_variable) +] @local.reference diff --git a/runtime/queries/tablegen/folds.scm b/runtime/queries/tablegen/folds.scm new file mode 100644 index 000000000..0e95ca527 --- /dev/null +++ b/runtime/queries/tablegen/folds.scm @@ -0,0 +1,13 @@ +[ + (assert) + (class) + (multiclass) + (def) + (defm) + (defset) + (defvar) + (foreach) + (if) + (let) + (value_suffix) +] @fold diff --git a/runtime/queries/tablegen/highlights.scm b/runtime/queries/tablegen/highlights.scm new file mode 100644 index 000000000..c2f63b093 --- /dev/null +++ b/runtime/queries/tablegen/highlights.scm @@ -0,0 +1,159 @@ +; Preprocs +(preprocessor_directive) @keyword.directive + +; Includes +"include" @keyword.import + +; Keywords +[ + "assert" + "field" + "let" + "def" + "defm" + "defset" + "defvar" +] @keyword + +[ + "multiclass" + "class" +] @keyword.type + +"in" @keyword.operator + +; Conditionals +[ + "if" + "else" + "then" +] @keyword.conditional + +; Repeats +"foreach" @keyword.repeat + +; Variables +(identifier) @variable + +(var) @variable.builtin + +; Parameters +(template_arg + (identifier) @variable.parameter) + +; Types +(type) @type + +[ + "bit" + "int" + "string" + "dag" + "bits" + "list" + "code" +] @type.builtin + +(class + name: (identifier) @type) + +(multiclass + name: (identifier) @type) + +(def + name: (value + (_) @type)) + +(defm + name: (value + (_) @type)) + +(defset + name: (identifier) @type) + +(parent_class_list + (identifier) @type + (value + (_) @type)?) + +(anonymous_record + (identifier) @type) + +(anonymous_record + (value + (_) @type)) + +((identifier) @type + (#lua-match? @type "^_*[A-Z][A-Z0-9_]+$")) + +; Fields +(instruction + (identifier) @variable.member) + +(let_instruction + (identifier) @variable.member) + +; Functions +([ + (bang_operator) + (cond_operator) +] @function + (#set! priority 105)) + +; Operators +[ + "=" + "#" + "-" + ":" + "..." +] @operator + +; Literals +(string) @string + +(code) @string.special + +(integer) @number + +(boolean) @boolean + +(uninitialized_value) @constant.builtin + +; Punctuation +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "<" + ">" +] @punctuation.bracket + +[ + "." + "," + ";" +] @punctuation.delimiter + +"!" @punctuation.special + +; Comments +[ + (comment) + (multiline_comment) +] @comment @spell + +((comment) @keyword.directive @nospell + (#lua-match? @keyword.directive "^.*RUN")) diff --git a/runtime/queries/tablegen/indents.scm b/runtime/queries/tablegen/indents.scm new file mode 100644 index 000000000..16748edf1 --- /dev/null +++ b/runtime/queries/tablegen/indents.scm @@ -0,0 +1,39 @@ +[ + (assert) + (class) + (multiclass) + (def) + (defm) + (defvar) + (foreach) + (if) + (let) + (value_suffix) +] @indent.begin + +[ + "}" + "]" + ")" + ">" +] @indent.end + +[ + "{" + "}" +] @indent.branch + +[ + "[" + "]" +] @indent.branch + +[ + "(" + ")" +] @indent.branch + +[ + "<" + ">" +] @indent.branch diff --git a/runtime/queries/tablegen/injections.scm b/runtime/queries/tablegen/injections.scm new file mode 100644 index 000000000..99f7919b6 --- /dev/null +++ b/runtime/queries/tablegen/injections.scm @@ -0,0 +1,9 @@ +((code) @injection.content + (#set! injection.language "cpp") + (#offset! @injection.content 0 2 0 -2)) + +((tablegen_file + (comment) @injection.content) + (#lua-match? @injection.content "^.*RUN") + (#set! injection.language "bash") + (#offset! @injection.content 0 8 0 0)) diff --git a/runtime/queries/tablegen/locals.scm b/runtime/queries/tablegen/locals.scm new file mode 100644 index 000000000..c73100193 --- /dev/null +++ b/runtime/queries/tablegen/locals.scm @@ -0,0 +1,51 @@ +; Scopes +[ + (class) + (multiclass) + (def) + (defm) + (defset) + (defvar) + (foreach) + (if) + (let) +] @local.scope + +; References +[ + (var) + (identifier) +] @local.reference + +; Definitions +(instruction + (identifier) @local.definition.field) + +(let_instruction + (identifier) @local.definition.field) + +(include_directive + (string) @local.definition.import) + +(template_arg + (identifier) @local.definition.parameter) + +(class + name: (identifier) @local.definition.type) + +(multiclass + name: (identifier) @local.definition.type) + +(def + name: (value + (_) @local.definition.type)) + +(defm + name: (value + (_) @local.definition.type)) + +(defset + name: (identifier) @local.definition.type) + +(def_var + name: (identifier) @local.definition.var) diff --git a/runtime/queries/tact/folds.scm b/runtime/queries/tact/folds.scm new file mode 100644 index 000000000..adade3f1c --- /dev/null +++ b/runtime/queries/tact/folds.scm @@ -0,0 +1,20 @@ +[ + ; import … + (import)+ + ; (…, …) + (parameter_list) + (argument_list) + ; {…, …} + (instance_argument_list) + (destruct_bind_list) + ; {…; …} + (message_body) + (struct_body) + (contract_body) + (trait_body) + (function_body) + (block_statement) + (asm_function_body) + ; <{ … }> + (asm_sequence) +] @fold diff --git a/runtime/queries/tact/highlights.scm b/runtime/queries/tact/highlights.scm new file mode 100644 index 000000000..345ca299c --- /dev/null +++ b/runtime/queries/tact/highlights.scm @@ -0,0 +1,342 @@ +; variable +; -------- +(identifier) @variable + +(destruct_bind + name: (identifier) @variable.member + bind: (identifier) @variable) + +; variable.builtin +; ---------------- +(self) @variable.builtin + +; variable.parameter +; ------------------ +(parameter + name: (identifier) @variable.parameter) + +; punctuation.delimiter +; --------------------- +[ + ";" + "," + "." + ":" + "?" +] @punctuation.delimiter + +; punctuation.bracket +; ------------------- +[ + "(" + ")" + "{" + "}" +] @punctuation.bracket + +; operator +; -------- +[ + "-" + "-=" + "+" + "+=" + "*" + "*=" + "/" + "/=" + "%" + "%=" + "=" + "==" + "!" + "!=" + "!!" + "<" + "<=" + "<<" + "<<=" + ">" + ">=" + ">>" + ">>=" + "&" + "&=" + "|" + "|=" + "^" + "^=" + "&&" + "&&=" + "||" + "||=" + "->" + ".." +] @operator + +; constructor +; ----------- +(instance_expression + name: (identifier) @constructor) + +(initOf + name: (identifier) @constructor) + +(codeOf + name: (identifier) @constructor) + +; type +; ---- +(type_identifier) @type + +; type.builtin +; ------------ +((identifier) @type.builtin + (#any-of? @type.builtin "Context" "SendParameters" "StateInit" "StdAddress" "VarAddress")) + +(generic_parameter_list + "<" @punctuation.bracket + ">" @punctuation.bracket) + +(bounced_type + "bounced" @type.builtin + "<" @punctuation.bracket + ">" @punctuation.bracket) + +(map_type + "map" @type.builtin + "<" @punctuation.bracket + ">" @punctuation.bracket) + +((type_identifier) @type.builtin + (#any-of? @type.builtin "Address" "Bool" "Builder" "Cell" "Int" "Slice" "String" "StringBuilder")) + +(tlb_serialization + "as" @keyword + type: (identifier) @type) + +; string +; ------ +(string) @string + +; string.escape +; ------------- +(escape_sequence) @string.escape + +; string.special.path +; ------------------- +(import + name: (string) @string.special.path) + +; boolean +; ------- +(boolean) @boolean + +; constant +; -------- +(global_constant + name: (identifier) @constant) + +(storage_constant + name: (identifier) @constant) + +; constant.builtin +; ---------------- +(null) @constant.builtin + +((identifier) @constant.builtin + (#any-of? @constant.builtin + "SendDefaultMode" "SendBounceIfActionFail" "SendPayGasSeparately" "SendIgnoreErrors" + "SendDestroyIfZero" "SendRemainingValue" "SendRemainingBalance" "SendOnlyEstimateFee" + "ReserveExact" "ReserveAllExcept" "ReserveAtMost" "ReserveAddOriginalBalance" + "ReserveInvertSign" "ReserveBounceIfActionFail")) + +; property +; -------- +(instance_argument + name: (identifier) @variable.member) + +(field_access_expression + name: (identifier) @variable.member) + +(field + name: (identifier) @variable.member) + +(storage_variable + name: (identifier) @variable.member) + +; number +; ------ +(integer) @number + +; keyword +; ------- +[ + "with" + "const" + "let" + ; "public" ; -- not used, but declared in grammar.ohm + ; "extend" ; -- not used, but declared in grammar.ohm +] @keyword + +; keyword.type +; ------------ +[ + "contract" + "trait" + "struct" + "message" +] @keyword.type + +; keyword.function +; ---------------- +[ + "fun" + "native" + "asm" +] @keyword.function + +; keyword.operator +; ---------------- +"initOf" @keyword.operator + +"codeOf" @keyword.operator + +; keyword.import +; -------------- +"import" @keyword.import + +; keyword.modifier +; --------------- +[ + "get" + "mutates" + "extends" + "virtual" + "override" + "inline" + "abstract" +] @keyword.modifier + +; keyword.repeat +; -------------- +(foreach_statement + . + (_) + . + (_) + . + "in" @keyword.repeat) + +[ + "while" + "repeat" + "do" + "until" + "foreach" +] @keyword.repeat + +; keyword.return +; -------------- +"return" @keyword.return + +; keyword.exception +; ----------------- +[ + "try" + "catch" +] @keyword.exception + +; keyword.conditional +; ------------------- +[ + "if" + "else" +] @keyword.conditional + +; keyword.directive.define +; ------------------------ +"primitive" @keyword.directive.define + +; function +; -------- +(native_function + name: (identifier) @function) + +(asm_function + name: (identifier) @function) + +(global_function + name: (identifier) @function) + +(func_identifier) @function + +; function.method +; --------------- +(init_function + "init" @function.method) + +(receive_function + "receive" @function.method) + +(bounced_function + "bounced" @function.method) + +(external_function + "external" @function.method) + +(storage_function + name: (identifier) @function.method) + +; function.call +; ------------- +(static_call_expression + name: (identifier) @function.call) + +; function.method.call +; --------------- +(method_call_expression + name: (identifier) @function.method.call) + +; asm-specific +; ------------ +(tvm_instruction) @function.call + +(asm_integer) @number + +(asm_string) @string + +(asm_control_register) @string.special.symbol + +(asm_stack_register) @string.special.symbol + +(asm_hex_bitstring) @function.macro + +(asm_bin_bitstring) @function.macro + +(asm_boc_hex) @function.macro + +(asm_cont_name) @variable + +; within asm_sequence +[ + "<{" + "}>" + "}>c" + "}>s" + "}>CONT" +] @punctuation.bracket + +; attribute +; --------- +[ + "@name" + "@interface" +] @attribute + +; comment +; ------- +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) diff --git a/runtime/queries/tact/indents.scm b/runtime/queries/tact/indents.scm new file mode 100644 index 000000000..1d05d4d82 --- /dev/null +++ b/runtime/queries/tact/indents.scm @@ -0,0 +1,52 @@ +; indent.begin ; indent children when matching this node +; ------------ +[ + ; (..., ...) + (parameter_list) + (argument_list) + ; {..., ...} + (instance_argument_list) + (destruct_bind_list) + ; {...; ...} + (message_body) + (struct_body) + (contract_body) + (trait_body) + (function_body) + (block_statement) + (asm_function_body) + ; misc. + (binary_expression) + (ternary_expression) + (return_statement) + (static_call_expression) + (method_call_expression) +] @indent.begin + +; indent.branch ; dedent itself when matching this node +; ------------- +[ + "}" + ")" + ">" +] @indent.branch + +; indent.end ; marks the end of indented block +; ---------- +[ + "}" + ")" + ">" +] @indent.end + +; indent.auto ; behaves like 'autoindent' buffer option +; ----------- +[ + (comment) + (ERROR) +] @indent.auto + +; indent.align ; behaves like python aligned/hanging indent +; indent.dedent ; dedent children when matching this node +; indent.ignore ; do not indent in this node +; indent.zero ; sets this node at position 0 (no indent) diff --git a/runtime/queries/tact/injections.scm b/runtime/queries/tact/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/tact/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/tact/locals.scm b/runtime/queries/tact/locals.scm new file mode 100644 index 000000000..547ee42c8 --- /dev/null +++ b/runtime/queries/tact/locals.scm @@ -0,0 +1,83 @@ +; Scopes @local.scope +; ------------------------- +[ + (asm_function) + (global_function) + (init_function) + (bounced_function) + (receive_function) + (external_function) + (storage_function) + (block_statement) +] @local.scope + +; Definitions @local.definition +; ------------------------------ +; variables +(storage_variable + name: (identifier) @local.definition.var) + +(let_statement + name: (identifier) @local.definition.var) + +; constants +(global_constant + name: (identifier) @local.definition.constant) + +(storage_constant + name: (identifier) @local.definition.constant) + +; functions +(asm_function + name: (identifier) @local.definition.function + (#set! definition.var.scope parent)) + +(global_function + name: (identifier) @local.definition.function + (#set! definition.var.scope parent)) + +; methods (functions off of contracts and traits) +(init_function + "init" @local.definition.method + (#set! definition.var.scope parent)) + +(bounced_function + "bounced" @local.definition.method + (#set! definition.var.scope parent)) + +(receive_function + "receive" @local.definition.method + (#set! definition.var.scope parent)) + +(external_function + "external" @local.definition.method + (#set! definition.var.scope parent)) + +(storage_function + name: (identifier) @local.definition.method + (#set! definition.var.scope parent)) + +; parameters +(parameter + name: (identifier) @local.definition.parameter) + +; user-defined types (structs and messages) +(type_identifier) @local.definition.type + +; fields (of messages and structs) +(field + name: (identifier) @local.definition.field) + +; imports +(import + name: (string) @local.definition.import) + +; References @local.reference +; ----------------------------- +(self) @local.reference + +(value_expression + (identifier) @local.reference) + +(field_access_expression + name: (identifier) @local.reference) diff --git a/runtime/queries/tcl/folds.scm b/runtime/queries/tcl/folds.scm new file mode 100644 index 000000000..9084c662c --- /dev/null +++ b/runtime/queries/tcl/folds.scm @@ -0,0 +1 @@ +(braced_word) @fold diff --git a/runtime/queries/tcl/highlights.scm b/runtime/queries/tcl/highlights.scm new file mode 100644 index 000000000..c5f1f4c36 --- /dev/null +++ b/runtime/queries/tcl/highlights.scm @@ -0,0 +1,114 @@ +(comment) @comment @spell + +(command + name: (simple_word) @function) + +"proc" @keyword.function + +(procedure + name: (_) @variable) + +(set + (simple_word) @variable) + +(argument + name: (_) @variable.parameter) + +((simple_word) @variable.builtin + (#any-of? @variable.builtin + "argc" "argv" "argv0" "auto_path" "env" "errorCode" "errorInfo" "tcl_interactive" "tcl_library" + "tcl_nonwordchars" "tcl_patchLevel" "tcl_pkgPath" "tcl_platform" "tcl_precision" + "tcl_rcFileName" "tcl_traceCompile" "tcl_traceExec" "tcl_wordchars" "tcl_version")) + +"expr" @function.builtin + +(command + name: (simple_word) @function.builtin + (#any-of? @function.builtin + "cd" "exec" "exit" "incr" "info" "join" "puts" "regexp" "regsub" "split" "subst" "trace" + "source")) + +(command + name: (simple_word) @keyword + (#any-of? @keyword + "append" "break" "catch" "continue" "default" "dict" "error" "eval" "global" "lappend" "lassign" + "lindex" "linsert" "list" "llength" "lmap" "lrange" "lrepeat" "lreplace" "lreverse" "lsearch" + "lset" "lsort" "package" "return" "switch" "throw" "unset" "variable")) + +[ + "error" + "on" + "set" + "try" +] @keyword + +"namespace" @keyword.type + +(unpack) @operator + +[ + "while" + "foreach" +] @keyword.repeat + +[ + "if" + "else" + "elseif" +] @keyword.conditional + +[ + "**" + "/" + "*" + "%" + "+" + "-" + "<<" + ">>" + ">" + "<" + ">=" + "<=" + "==" + "!=" + "eq" + "ne" + "in" + "ni" + "&" + "^" + "|" + "&&" + "||" +] @operator + +(variable_substitution) @variable + +(quoted_word) @string + +(escaped_character) @string.escape + +[ + "{" + "}" + "[" + "]" + ";" +] @punctuation.delimiter + +((simple_word) @number + (#lua-match? @number "^[0-9]+$")) + +((simple_word) @boolean + (#any-of? @boolean "true" "false")) + +; after apply array auto_execok auto_import auto_load auto_mkindex auto_qualify +; auto_reset bgerror binary chan clock close coroutine dde encoding eof fblocked +; fconfigure fcopy file fileevent filename flush format gets glob history http +; interp load mathfunc mathop memory msgcat my next nextto open parray pid +; pkg::create pkg_mkIndex platform platform::shell pwd re_syntax read refchan +; registry rename safe scan seek self socket source string tailcall tcl::prefix +; tcl_endOfWord tcl_findLibrary tcl_startOfNextWord tcl_startOfPreviousWord +; tcl_wordBreakAfter tcl_wordBreakBefore tcltest tell time timerate tm +; transchan unknown unload update uplevel upvar vwait yield yieldto zlib diff --git a/runtime/queries/tcl/indents.scm b/runtime/queries/tcl/indents.scm new file mode 100644 index 000000000..bc0355372 --- /dev/null +++ b/runtime/queries/tcl/indents.scm @@ -0,0 +1,25 @@ +[ + (braced_word_simple) + (namespace) + (command) + (conditional) + (foreach) + (while) + (try) + (procedure) + (command_substitution) +] @indent.begin + +(quoted_word) @indent.align + +([ + (expr) + (arguments) +] @indent.align + (#set! indent.open_delimiter "{") + (#set! indent.close_delimiter "}")) + +[ + "}" + "]" +] @indent.branch @indent.end diff --git a/runtime/queries/tcl/injections.scm b/runtime/queries/tcl/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/tcl/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/teal/folds.scm b/runtime/queries/teal/folds.scm new file mode 100644 index 000000000..27755de20 --- /dev/null +++ b/runtime/queries/teal/folds.scm @@ -0,0 +1,13 @@ +[ + (do_statement) + (numeric_for_statement) + (generic_for_statement) + (while_statement) + (repeat_statement) + (if_statement) + (function_statement) + (record_declaration) + (enum_declaration) + (anon_function) + (table_constructor) +] @fold diff --git a/runtime/queries/teal/highlights.scm b/runtime/queries/teal/highlights.scm new file mode 100644 index 000000000..e58d588bb --- /dev/null +++ b/runtime/queries/teal/highlights.scm @@ -0,0 +1,237 @@ +; Primitives +(boolean) @boolean + +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[-][-][-]")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[-][-](%s?)@")) + +(shebang_comment) @keyword.directive + +(identifier) @variable + +((identifier) @variable.builtin + (#eq? @variable.builtin "self")) + +(nil) @constant.builtin + +(number) @number + +(string) @string + +(table_constructor + [ + "{" + "}" + ] @constructor) + +(varargs + "..." @constant.builtin) + +[ + "," + "." + ":" + ";" +] @punctuation.delimiter + +(escape_sequence) @string.escape + +(format_specifier) @string.escape + +; Basic statements/Keywords +[ + "if" + "then" + "elseif" + "else" +] @keyword.conditional + +[ + "for" + "while" + "repeat" + "until" +] @keyword.repeat + +"return" @keyword.return + +[ + "in" + "local" + (break) + (goto) + "do" + "end" +] @keyword + +(label) @label + +; Global isn't a real keyword, but it gets special treatment in these places +(var_declaration + "global" @keyword) + +(type_declaration + "global" @keyword) + +(function_statement + "global" @keyword) + +(record_declaration + "global" @keyword) + +(enum_declaration + "global" @keyword) + +; Ops +(bin_op + (op) @operator) + +(unary_op + (op) @operator) + +[ + "=" + "as" +] @operator + +; Functions +(function_statement + "function" @keyword.function + . + name: (_) @function) + +(anon_function + "function" @keyword.function) + +(function_body + "end" @keyword.function) + +(arg + name: (identifier) @variable.parameter) + +(function_signature + (arguments + . + (arg + name: (identifier) @variable.builtin)) + (#eq? @variable.builtin "self")) + +(typeargs + "<" @punctuation.bracket + . + (_) @variable.parameter + . + ("," + . + (_) @variable.parameter)* + . + ">" @punctuation.bracket) + +(function_call + (identifier) @function + . + (arguments)) + +(function_call + (index + (_) + key: (identifier) @function) + . + (arguments)) + +(function_call + (method_index + (_) + key: (identifier) @function) + . + (arguments)) + +; Types +(record_declaration + . + "record" @keyword.type + name: (identifier) @type) + +(anon_record + . + "record" @keyword.type) + +(record_body + (record_declaration + . + "record" @keyword.type + . + name: (identifier) @type)) + +(record_body + (enum_declaration + . + "enum" @keyword.type + . + name: (identifier) @type)) + +(record_body + (typedef + . + "type" @keyword + . + name: (identifier) @type + . + "=")) + +(record_body + (metamethod + "metamethod" @keyword)) + +(record_body + (userdata) @keyword) + +(enum_declaration + "enum" @keyword.type + name: (identifier) @type) + +(type_declaration + "type" @keyword) + +(type_declaration + (identifier) @type) + +(simple_type + name: (identifier) @type) + +(type_index + (identifier) @type) + +(type_union + "|" @operator) + +(function_type + "function" @type) + +; The rest of it +(var_declaration + declarators: (var_declarators + (var + name: (identifier) @variable))) + +(var_declaration + declarators: (var_declarators + (var + "<" @punctuation.bracket + . + attribute: (attribute) @attribute + . + ">" @punctuation.bracket))) + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket diff --git a/runtime/queries/teal/indents.scm b/runtime/queries/teal/indents.scm new file mode 100644 index 000000000..77b269cd9 --- /dev/null +++ b/runtime/queries/teal/indents.scm @@ -0,0 +1,18 @@ +[ + (record_declaration) + (anon_function) + (function_body) + (table_constructor) + (if_statement) + (return_statement) + (while_statement) +] @indent.begin + +[ + "{" + "}" + "(" + ")" + "end" + "then" +] @indent.branch diff --git a/runtime/queries/teal/injections.scm b/runtime/queries/teal/injections.scm new file mode 100644 index 000000000..decb4831c --- /dev/null +++ b/runtime/queries/teal/injections.scm @@ -0,0 +1,43 @@ +((function_call + (index + (identifier) @_cdef_identifier) + (arguments + (string) @injection.content)) + (#eq? @_cdef_identifier "cdef") + (#lua-match? @injection.content "^[\"']") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "c")) + +((function_call + (index + (identifier) @_cdef_identifier) + (arguments + (string) @injection.content)) + (#eq? @_cdef_identifier "cdef") + (#lua-match? @injection.content "^%[%[") + (#offset! @injection.content 0 2 0 -2) + (#set! injection.language "c")) + +; string.format('...') +((function_call + (index + (identifier) @_base + key: (identifier) @_entry) + (arguments + . + (string) @injection.content)) + (#eq? @_base "string") + (#eq? @_entry "format") + (#set! injection.language "printf")) + +; ('...'):format() +((function_call + (method_index + (parenthesized_expression + (string) @injection.content) + key: (identifier) @_func)) + (#eq? @_func "format") + (#set! injection.language "printf")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/teal/locals.scm b/runtime/queries/teal/locals.scm new file mode 100644 index 000000000..c2386c632 --- /dev/null +++ b/runtime/queries/teal/locals.scm @@ -0,0 +1,36 @@ +(var_declaration + declarators: (var_declarators + (var + (identifier)) @local.definition.var)) + +(var_assignment + variables: (assignment_variables + (var + (identifier) @local.definition.var) @local.definition.associated)) + +(arg + name: (identifier) @local.definition.parameter) + +(anon_function) @local.scope + +(function_statement + (function_name) @local.definition.function) @local.scope + +(program) @local.scope + +(if_statement) @local.scope + +(generic_for_statement + (for_body) @local.scope) + +(numeric_for_statement + (for_body) @local.scope) + +(repeat_statement) @local.scope + +(while_statement + (while_body) @local.scope) + +(do_statement) @local.scope + +(identifier) @local.reference diff --git a/runtime/queries/templ/folds.scm b/runtime/queries/templ/folds.scm new file mode 100644 index 000000000..adbbb103f --- /dev/null +++ b/runtime/queries/templ/folds.scm @@ -0,0 +1,15 @@ +[ + (component_block) + (css_declaration) + (script_declaration) + (element) + (style_element) + (script_element) + (component_switch_statement) + (field_declaration_list) + (block) + (interface_type) + (comment) + (const_declaration) + (var_declaration) +] @fold diff --git a/runtime/queries/templ/highlights.scm b/runtime/queries/templ/highlights.scm new file mode 100644 index 000000000..034c91d5b --- /dev/null +++ b/runtime/queries/templ/highlights.scm @@ -0,0 +1,60 @@ +; inherits: go + +(component_declaration + name: (component_identifier) @function) + +[ + (tag_start) + (tag_end) + (self_closing_tag) + (style_element) +] @tag + +(doctype) @constant + +(attribute + name: (attribute_name) @tag.attribute) + +(attribute + value: (quoted_attribute_value) @string) + +[ + (element_text) + (style_element_text) +] @string.special + +(css_identifier) @function + +(css_property + name: (css_property_name) @property) + +(css_property + value: (css_property_value) @string) + +[ + (expression) + (dynamic_class_attribute_value) +] @function.method + +(component_import + name: (component_identifier) @function) + +(component_render) @function.call + +(element_comment) @comment @spell + +[ + "<" + ">" + "</" + "/>" + "<!" +] @tag.delimiter + +"@" @operator + +[ + "templ" + "css" + "script" +] @keyword diff --git a/runtime/queries/templ/injections.scm b/runtime/queries/templ/injections.scm new file mode 100644 index 000000000..b9cf5a06a --- /dev/null +++ b/runtime/queries/templ/injections.scm @@ -0,0 +1,13 @@ +; inherits: go + +((element_comment) @injection.content + (#set! injection.language "comment")) + +((script_block_text) @injection.content + (#set! injection.language "javascript")) + +((script_element_text) @injection.content + (#set! injection.language "javascript")) + +((style_element_text) @injection.content + (#set! injection.language "css")) diff --git a/runtime/queries/tera/highlights.scm b/runtime/queries/tera/highlights.scm new file mode 100644 index 000000000..f41ad826f --- /dev/null +++ b/runtime/queries/tera/highlights.scm @@ -0,0 +1,153 @@ +; Variables +;---------- +(identifier) @variable + +((identifier) @variable.builtin + (#any-of? @variable.builtin "loop" "__tera_context")) + +; Properties +;----------- +(member_expression + property: (identifier)? @variable.member) + +; Literals +;----------- +(string) @string + +(bool) @boolean + +(number) @number + +; Tokens +;----------- +[ + "." + "," + "::" + (frontmatter_delimiter) +] @punctuation.delimiter + +[ + "*" + "/" + "%" + "|" + "+" + "-" + "~" + "=" + "==" + "!=" + "<" + ">" + "<=" + ">=" +] @operator + +[ + "(" + ")" + "[" + "]" + "{%" + "%}" + "-%}" + "{%-" + "}}" + "{{" + "-}}" + "{{-" +] @punctuation.bracket + +; Tags +;----------- +(comment_tag) @comment @spell + +; Keywords +;----------- +[ + "if" + "elif" + "else" + "endif" +] @keyword.conditional + +[ + "for" + "endfor" +] @keyword.repeat + +[ + "include" + "import" + "extends" +] @keyword.import + +[ + "in" + "and" + "or" + "not" + "is" +] @keyword.operator + +[ + "break" + "continue" +] @keyword.return + +[ + "set" + "set_global" + "filter" + "endfilter" + "block" + "endblock" + "macro" + "endmacro" + "raw" + "endraw" + "as" +] @keyword + +; Functions +;----------- +(macro_statement + name: (identifier) @function + (parameter_list + parameter: (identifier) @variable.parameter + (optional_parameter + name: (identifier) @variable.parameter))) + +(call_expression + scope: (identifier)? @module + name: (identifier) @function.call) + +(call_expression + scope: (identifier) @module.builtin + name: (identifier) @function.call + (#eq? @module.builtin "self")) + +(call_expression + name: (identifier) @function.builtin + (#any-of? @function.builtin + ; Functions - https://keats.github.io/tera/docs/#built-in-functions + "range" "now" "throw" "get_random" "get_env")) + +(test_expression + test: (identifier) @function.call) + +(test_expression + test: (identifier) @function.builtin + (#any-of? @function.builtin + ; Tests - https://keats.github.io/tera/docs/#built-in-tests + "defined" "undefined" "odd" "even" "string" "number" "divisibleby" "iterable" "object" + "starting_with" "ending_with" "containing" "matching")) + +(filter_expression + filter: (identifier) @function.method.call) + +; Namespaces +;----------- +(import_statement + scope: (identifier) @module) diff --git a/runtime/queries/tera/injections.scm b/runtime/queries/tera/injections.scm new file mode 100644 index 000000000..394142081 --- /dev/null +++ b/runtime/queries/tera/injections.scm @@ -0,0 +1,7 @@ +(frontmatter + (content) @injection.content + (#set! injection.language "yaml") + (#set! injection.combined)) + +((comment_tag) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/terraform/folds.scm b/runtime/queries/terraform/folds.scm new file mode 100644 index 000000000..0e5ffc2db --- /dev/null +++ b/runtime/queries/terraform/folds.scm @@ -0,0 +1 @@ +; inherits: hcl diff --git a/runtime/queries/terraform/highlights.scm b/runtime/queries/terraform/highlights.scm new file mode 100644 index 000000000..a6bf83cdb --- /dev/null +++ b/runtime/queries/terraform/highlights.scm @@ -0,0 +1,41 @@ +; inherits: hcl + +; Terraform specific references +; +; +; local/module/data/var/output +(expression + (variable_expr + (identifier) @variable.builtin + (#any-of? @variable.builtin "data" "var" "local" "module" "output")) + (get_attr + (identifier) @variable.member)) + +; path.root/cwd/module +(expression + (variable_expr + (identifier) @type.builtin + (#eq? @type.builtin "path")) + (get_attr + (identifier) @variable.builtin + (#any-of? @variable.builtin "root" "cwd" "module"))) + +; terraform.workspace +(expression + (variable_expr + (identifier) @type.builtin + (#eq? @type.builtin "terraform")) + (get_attr + (identifier) @variable.builtin + (#any-of? @variable.builtin "workspace"))) + +; Terraform specific keywords +; FIXME: ideally only for identifiers under a `variable` block to minimize false positives +((identifier) @type.builtin + (#any-of? @type.builtin "bool" "string" "number" "object" "tuple" "list" "map" "set" "any")) + +(object_elem + val: (expression + (variable_expr + (identifier) @type.builtin + (#any-of? @type.builtin "bool" "string" "number" "object" "tuple" "list" "map" "set" "any")))) diff --git a/runtime/queries/terraform/indents.scm b/runtime/queries/terraform/indents.scm new file mode 100644 index 000000000..0e5ffc2db --- /dev/null +++ b/runtime/queries/terraform/indents.scm @@ -0,0 +1 @@ +; inherits: hcl diff --git a/runtime/queries/terraform/injections.scm b/runtime/queries/terraform/injections.scm new file mode 100644 index 000000000..0e5ffc2db --- /dev/null +++ b/runtime/queries/terraform/injections.scm @@ -0,0 +1 @@ +; inherits: hcl diff --git a/runtime/queries/textproto/folds.scm b/runtime/queries/textproto/folds.scm new file mode 100644 index 000000000..f6eeead9a --- /dev/null +++ b/runtime/queries/textproto/folds.scm @@ -0,0 +1,5 @@ +[ + (message_value) + (scalar_list) + (message_list) +] @fold diff --git a/runtime/queries/textproto/highlights.scm b/runtime/queries/textproto/highlights.scm new file mode 100644 index 000000000..527af0398 --- /dev/null +++ b/runtime/queries/textproto/highlights.scm @@ -0,0 +1,23 @@ +(string) @string + +(field_name) @variable.member + +(comment) @comment @spell + +(number) @number + +; For stuff like "inf" and "-inf". +(scalar_value + [ + (identifier) + (signed_identifier) + ]) @number + +[ + (open_squiggly) + (close_squiggly) + (open_square) + (close_square) + (open_arrow) + (close_arrow) +] @punctuation.bracket diff --git a/runtime/queries/textproto/indents.scm b/runtime/queries/textproto/indents.scm new file mode 100644 index 000000000..155299e39 --- /dev/null +++ b/runtime/queries/textproto/indents.scm @@ -0,0 +1,14 @@ +(message_value) @indent.begin + +(message_value + (close_squiggly) @indent.branch) + +(scalar_list) @indent.begin + +(scalar_list + (close_square) @indent.branch) + +(message_list) @indent.begin + +(message_list + (close_square) @indent.branch) diff --git a/runtime/queries/textproto/injections.scm b/runtime/queries/textproto/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/textproto/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/thrift/folds.scm b/runtime/queries/thrift/folds.scm new file mode 100644 index 000000000..62880f98c --- /dev/null +++ b/runtime/queries/thrift/folds.scm @@ -0,0 +1,12 @@ +[ + (annotation_definition) + (enum_definition) + (exception_definition) + (function_definition) + (senum_definition) + (service_definition) + (struct_definition) + (union_definition) + (comment) + (include_statement)+ +] @fold diff --git a/runtime/queries/thrift/highlights.scm b/runtime/queries/thrift/highlights.scm new file mode 100644 index 000000000..96136d7b5 --- /dev/null +++ b/runtime/queries/thrift/highlights.scm @@ -0,0 +1,237 @@ +; Variables +((identifier) @variable + (#set! priority 95)) + +; Includes +[ + "include" + "cpp_include" +] @keyword.import + +; Function +(function_definition + (identifier) @function) + +; Fields +(field + (identifier) @property) + +; Parameters +(function_definition + (parameters + (parameter + (identifier) @variable.parameter))) + +(throws + (parameters + (parameter + (identifier) @variable.parameter))) + +; Types +(typedef_identifier) @type + +(struct_definition + "struct" + (identifier) @type) + +(union_definition + "union" + (identifier) @type) + +(exception_definition + "exception" + (identifier) @type) + +(service_definition + "service" + (identifier) @type) + +(interaction_definition + "interaction" + (identifier) @type) + +(type + type: (identifier) @type) + +(definition_type + type: (identifier) @type) + +((identifier) @type + (#lua-match? @type "^[_]*[A-Z]")) + +; Constants +(const_definition + (identifier) @constant) + +((identifier) @constant + (#lua-match? @constant "^[_A-Z][A-Z0-9_]*$")) + +(enum_definition + type: (identifier) @type) + +(enum_definition + "{" + (identifier) @constant) + +; Builtin Types +[ + (primitive) + "list" + "map" + "set" + "sink" + "stream" + "void" +] @type.builtin + +; Namespace +(namespace_declaration + (namespace_scope) @string.special) + +(namespace_declaration + (namespace_scope) + [ + type: (namespace) @module + (_ + (identifier) @module) + ]) + +; Attributes +(annotation_definition + (annotation_identifier + (identifier) @attribute)) + +(fb_annotation_definition + "@" @attribute + (annotation_identifier + (identifier) @attribute) + (identifier)? @attribute) + +(namespace_uri + (string) @attribute) + +; Operators +[ + "=" + "&" +] @operator + +; Exceptions +"throws" @keyword.exception + +; Keywords +[ + "exception" + "extends" + "typedef" + "uri" +] @keyword + +[ + "enum" + "struct" + "union" + "senum" + "interaction" + "namespace" + "service" +] @keyword.type + +; Deprecated Keywords +[ + "cocoa_prefix" + "cpp_namespace" + "csharp_namespace" + "delphi_namespace" + "java_package" + "perl_package" + "php_namespace" + "py_module" + "ruby_namespace" + "smalltalk_category" + "smalltalk_prefix" + "xsd_all" + "xsd_attrs" + "xsd_namespace" + "xsd_nillable" + "xsd_optional" +] @keyword + +; Extended Keywords +[ + "package" + "performs" +] @keyword + +[ + "async" + "oneway" +] @keyword.coroutine + +; Qualifiers +[ + "client" + "const" + "idempotent" + "optional" + "permanent" + "readonly" + "required" + "safe" + "server" + "stateful" + "transient" +] @keyword.modifier + +; Literals +(string) @string + +(escape_sequence) @string.escape + +(namespace_uri + (string) @string.special.url) + +(number) @number + +(double) @number.float + +(boolean) @boolean + +; Typedefs +(typedef_identifier) @type.definition + +; Punctuation +"*" @punctuation.special + +[ + "{" + "}" + "(" + ")" + "[" + "]" + "<" + ">" +] @punctuation.bracket + +[ + "." + "," + ";" + ":" +] @punctuation.delimiter + +; Comments +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) + +((comment) @keyword.directive @nospell + (#lua-match? @keyword.directive "#!.*")) diff --git a/runtime/queries/thrift/indents.scm b/runtime/queries/thrift/indents.scm new file mode 100644 index 000000000..db49c0712 --- /dev/null +++ b/runtime/queries/thrift/indents.scm @@ -0,0 +1,23 @@ +(definition) @indent.begin + +((parameters + (parameter)) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +"}" @indent.end + +[ + "{" + "}" +] @indent.branch + +[ + "(" + ")" +] @indent.branch + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/runtime/queries/thrift/injections.scm b/runtime/queries/thrift/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/thrift/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/thrift/locals.scm b/runtime/queries/thrift/locals.scm new file mode 100644 index 000000000..49f25bdde --- /dev/null +++ b/runtime/queries/thrift/locals.scm @@ -0,0 +1,70 @@ +; Scopes +[ + (document) + (definition) +] @local.scope + +; References +(identifier) @local.reference + +; Definitions +(annotation_identifier) @local.definition + +(const_definition + (identifier) @local.definition.constant) + +(enum_definition + "enum" + . + (identifier) @local.definition.enum + "{" + (identifier) @local.definition.constant + "}") + +(senum_definition + "senum" + . + (identifier) @local.definition.enum) + +(field + (identifier) @local.definition.field) + +(function_definition + (identifier) @local.definition.function) + +(namespace_declaration + "namespace" + (namespace_scope) + . + (_) @local.definition.namespace + (namespace_uri)?) + +(parameter + (identifier) @local.definition.parameter) + +(struct_definition + "struct" + . + (identifier) @local.definition.type) + +(union_definition + "union" + . + (identifier) @local.definition.type) + +(exception_definition + "exception" + . + (identifier) @local.definition.type) + +(service_definition + "service" + . + (identifier) @local.definition.type) + +(interaction_definition + "interaction" + . + (identifier) @local.definition.type) + +(typedef_identifier) @local.definition.type diff --git a/runtime/queries/tiger/folds.scm b/runtime/queries/tiger/folds.scm new file mode 100644 index 000000000..3b076bc18 --- /dev/null +++ b/runtime/queries/tiger/folds.scm @@ -0,0 +1,17 @@ +[ + (array_expression) + (record_expression) + (sequence_expression) + (if_expression) + (while_expression) + (for_expression) + (let_expression) + (function_declaration) + (primitive_declaration) + (record_type) + (class_declaration) + (class_type) + (method_declaration) +] @fold + +; vim: sw=2 foldmethod=marker diff --git a/runtime/queries/tiger/highlights.scm b/runtime/queries/tiger/highlights.scm new file mode 100644 index 000000000..cbb1f2310 --- /dev/null +++ b/runtime/queries/tiger/highlights.scm @@ -0,0 +1,121 @@ +; Built-ins {{{ +((function_call + function: (identifier) @function.builtin) + (#any-of? @function.builtin + "chr" "concat" "exit" "flush" "getchar" "not" "ord" "print" "print_err" "print_int" "size" + "strcmp" "streq" "substring")) + +((type_identifier) @type.builtin + (#any-of? @type.builtin "int" "string" "Object")) + +((identifier) @variable.builtin + (#eq? @variable.builtin "self")) + +; }}} +; Keywords {{{ +[ + "function" + "primitive" + "method" +] @keyword.function + +[ + "do" + "for" + "to" + "while" +] @keyword.repeat + +"new" @keyword.operator + +"import" @keyword.import + +[ + "array" + (break_expression) + "else" + "end" + "if" + "in" + "let" + "of" + "then" + "type" + "var" + "extends" + "_cast" + "_chunks" + "_exp" + "_lvalue" + "_namety" +] @keyword + +"class" @keyword.type + +; }}} +; Operators {{{ +(operator) @operator + +[ + "," + ";" + ":" + "." +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; }}} +; Functions and methods {{{ +(function_call + function: (identifier) @function) + +(function_declaration + name: (identifier) @function) + +(primitive_declaration + name: (identifier) @function) + +(method_call + method: (identifier) @function.method) + +(method_declaration + name: (identifier) @function.method) + +(parameters + name: (identifier) @variable.parameter) + +; }}} +; Declarations {{{ +(import_declaration + file: (string_literal) @string.special.path) + +; }}} +; Literals {{{ +(nil_literal) @constant.builtin + +(integer_literal) @number + +(string_literal) @string + +(escape_sequence) @string.escape + +; }}} +; Misc {{{ +(comment) @comment @spell + +(type_identifier) @type + +(field_identifier) @variable.member + +(identifier) @variable + +; }}} +; vim: sw=2 foldmethod=marker diff --git a/runtime/queries/tiger/indents.scm b/runtime/queries/tiger/indents.scm new file mode 100644 index 000000000..686bfde16 --- /dev/null +++ b/runtime/queries/tiger/indents.scm @@ -0,0 +1,104 @@ +; Control flow {{{ +(if_expression) @indent.begin + +"then" @indent.branch + +"else" @indent.branch + +(while_expression) @indent.begin + +"do" @indent.branch + +(for_expression) @indent.begin + +"to" @indent.branch + +; }}} +; Class {{{ +(class_declaration) @indent.begin + +(class_declaration + "}" @indent.end) + +(class_type) @indent.begin + +(class_type + "}" @indent.end) + +; }}} +; Groups {{{ +(let_expression) @indent.begin + +"in" @indent.branch + +"end" @indent.branch + +(let_expression + "end" @indent.end) + +(sequence_expression) @indent.begin + +")" @indent.branch + +(sequence_expression + ")" @indent.end) + +; }}} +; Functions and methods {{{ +(parameters) @indent.begin + +(parameters + ")" @indent.end) + +(function_call) @indent.begin + +(function_call + ")" @indent.end) + +(method_call) @indent.begin + +")" @indent.branch + +(function_declaration) @indent.begin + +(primitive_declaration) @indent.begin + +(method_declaration) @indent.begin + +; }}} +; Values and expressions {{{ +(array_value) @indent.begin + +"]" @indent.branch + +(array_value + "]" @indent.end) + +(array_expression) @indent.begin + +"of" @indent.branch + +(record_expression) @indent.begin + +"}" @indent.branch + +(record_expression + "}" @indent.end) + +(record_type) @indent.begin + +"}" @indent.branch + +(record_type + "}" @indent.end) + +(variable_declaration) @indent.begin + +; }}} +; Misc{{{ +(comment) @indent.ignore + +(string_literal) @indent.ignore + +; }}} +; vim: sw=2 foldmethod=marker diff --git a/runtime/queries/tiger/injections.scm b/runtime/queries/tiger/injections.scm new file mode 100644 index 000000000..9735c5935 --- /dev/null +++ b/runtime/queries/tiger/injections.scm @@ -0,0 +1,4 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; vim: sw=2 foldmethod=marker diff --git a/runtime/queries/tiger/locals.scm b/runtime/queries/tiger/locals.scm new file mode 100644 index 000000000..cd8dcd65f --- /dev/null +++ b/runtime/queries/tiger/locals.scm @@ -0,0 +1,39 @@ +; See this issue [1] for support for "lazy scoping" which is somewhat needed +; for Tiger semantics (e.g: one can call a function before it has been defined +; top-to-bottom). +; +; [1]: https://github.com/tree-sitter/tree-sitter/issues/918 +; Scopes {{{ +[ + (for_expression) + (let_expression) + (function_declaration) +] @local.scope + +; }}} +; Definitions {{{ +(type_declaration + name: (identifier) @local.definition.type + (#set! definition.var.scope "parent")) + +(parameters + name: (identifier) @local.definition.parameter) + +(function_declaration + name: (identifier) @local.definition.function + (#set! definition.var.scope "parent")) + +(primitive_declaration + name: (identifier) @local.definition.function + (#set! definition.var.scope "parent")) + +(variable_declaration + name: (identifier) @local.definition.var + (#set! definition.var.scope "parent")) + +; }}} +; References {{{ +(identifier) @local.reference + +; }}} +; vim: sw=2 foldmethod=marker diff --git a/runtime/queries/tlaplus/folds.scm b/runtime/queries/tlaplus/folds.scm new file mode 100644 index 000000000..2ca0168c0 --- /dev/null +++ b/runtime/queries/tlaplus/folds.scm @@ -0,0 +1,5 @@ +[ + (extramodular_text) + (block_comment) + (non_terminal_proof) +] @fold diff --git a/runtime/queries/tlaplus/highlights.scm b/runtime/queries/tlaplus/highlights.scm new file mode 100644 index 000000000..2eca927e7 --- /dev/null +++ b/runtime/queries/tlaplus/highlights.scm @@ -0,0 +1,380 @@ +; Keywords +[ + "ACTION" + "ASSUME" + "ASSUMPTION" + "AXIOM" + "BY" + "CASE" + "CHOOSE" + "CONSTANT" + "CONSTANTS" + "COROLLARY" + "DEF" + "DEFINE" + "DEFS" + "ELSE" + "EXCEPT" + "EXTENDS" + "HAVE" + "HIDE" + "IF" + "IN" + "INSTANCE" + "LAMBDA" + "LEMMA" + "LET" + "LOCAL" + "MODULE" + "NEW" + "OBVIOUS" + "OMITTED" + "ONLY" + "OTHER" + "PICK" + "PROOF" + "PROPOSITION" + "PROVE" + "QED" + "RECURSIVE" + "SF_" + "STATE" + "SUFFICES" + "TAKE" + "TEMPORAL" + "THEN" + "THEOREM" + "USE" + "VARIABLE" + "VARIABLES" + "WF_" + "WITH" + "WITNESS" + (address) + (all_map_to) + (assign) + (case_arrow) + (case_box) + (def_eq) + (exists) + (forall) + (gets) + (label_as) + (maps_to) + (set_in) + (temporal_exists) + (temporal_forall) +] @keyword + +; Pluscal keywords +[ + (pcal_algorithm_start) + "algorithm" + "assert" + "begin" + "call" + "define" + "end" + "fair" + "goto" + "macro" + "or" + "procedure" + "process" + (pcal_skip) + "variable" + "variables" + "when" + "with" +] @keyword + +"await" @keyword.coroutine + +(pcal_with + "=" @keyword) + +(pcal_process + "=" @keyword) + +[ + "if" + "then" + "else" + "elsif" + (pcal_end_if) + "either" + (pcal_end_either) +] @keyword.conditional + +[ + "while" + "do" + (pcal_end_while) + "with" + (pcal_end_with) +] @keyword.repeat + +(pcal_return) @keyword.return + +"print" @function.macro + +; Literals +(binary_number + (format) @keyword) + +(binary_number + (value) @number) + +(boolean) @boolean + +(boolean_set) @type + +(hex_number + (format) @keyword) + +(hex_number + (value) @number) + +(int_number_set) @type + +(nat_number) @number + +(nat_number_set) @type + +(octal_number + (format) @keyword) + +(octal_number + (value) @number) + +(real_number) @number + +(real_number_set) @type + +(string) @string + +(escape_char) @string.escape + +(string_set) @type + +; Namespaces +(extends + (identifier_ref) @module) + +(instance + (identifier_ref) @module) + +(module + name: (identifier) @module) + +(pcal_algorithm + name: (identifier) @module) + +; Operators, functions, and macros +(bound_infix_op + symbol: (_) @operator) + +(bound_nonfix_op + symbol: (_) @operator) + +(bound_postfix_op + symbol: (_) @operator) + +(bound_prefix_op + symbol: (_) @operator) + +(prefix_op_symbol) @operator + +(infix_op_symbol) @operator + +(postfix_op_symbol) @operator + +(function_definition + name: (identifier) @function) + +(module_definition + name: (_) @keyword.import) + +(operator_definition + name: (_) @function.macro) + +(pcal_macro_decl + name: (identifier) @function.macro) + +(pcal_macro_call + name: (identifier) @function.macro) + +(pcal_proc_decl + name: (identifier) @function.macro) + +(pcal_process + name: (identifier) @function) + +(recursive_declaration + (identifier) @function.macro) + +(recursive_declaration + (operator_declaration + name: (_) @function.macro)) + +; Constants and variables +(constant_declaration + (identifier) @constant) + +(constant_declaration + (operator_declaration + name: (_) @constant)) + +(pcal_var_decl + (identifier) @variable) + +(pcal_with + (identifier) @variable.parameter) + +("." + . + (identifier) @attribute) + +(record_literal + (identifier) @attribute) + +(set_of_records + (identifier) @attribute) + +(variable_declaration + (identifier) @variable) + +; Parameters +(choose + (identifier) @variable.parameter) + +(choose + (tuple_of_identifiers + (identifier) @variable.parameter)) + +(lambda + (identifier) @variable.parameter) + +(module_definition + (operator_declaration + name: (_) @variable.parameter)) + +(module_definition + parameter: (identifier) @variable.parameter) + +(operator_definition + (operator_declaration + name: (_) @variable.parameter)) + +(operator_definition + parameter: (identifier) @variable.parameter) + +(pcal_macro_decl + parameter: (identifier) @variable.parameter) + +(pcal_proc_var_decl + (identifier) @variable.parameter) + +(quantifier_bound + (identifier) @variable.parameter) + +(quantifier_bound + (tuple_of_identifiers + (identifier) @variable.parameter)) + +(unbounded_quantification + (identifier) @variable.parameter) + +; Delimiters +[ + (langle_bracket) + (rangle_bracket) + (rangle_bracket_sub) + "{" + "}" + "[" + "]" + "]_" + "(" + ")" +] @punctuation.bracket + +[ + "," + ":" + "." + "!" + ";" + (bullet_conj) + (bullet_disj) + (prev_func_val) + (placeholder) +] @punctuation.delimiter + +; Proofs +(assume_prove + (new + (identifier) @variable.parameter)) + +(assume_prove + (new + (operator_declaration + name: (_) @variable.parameter))) + +(assumption + name: (identifier) @constant) + +(pick_proof_step + (identifier) @variable.parameter) + +(proof_step_id + "<" @punctuation.bracket) + +(proof_step_id + (level) @label) + +(proof_step_id + (name) @label) + +(proof_step_id + ">" @punctuation.bracket) + +(proof_step_ref + "<" @punctuation.bracket) + +(proof_step_ref + (level) @label) + +(proof_step_ref + (name) @label) + +(proof_step_ref + ">" @punctuation.bracket) + +(take_proof_step + (identifier) @variable.parameter) + +(theorem + name: (identifier) @constant) + +; Comments and tags +(block_comment + "(*" @comment) + +(block_comment + "*)" @comment) + +(block_comment_text) @comment @spell + +(comment) @comment @spell + +(single_line) @comment + +(_ + label: (identifier) @label) + +(label + name: (_) @label) + +(pcal_goto + statement: (identifier) @label) diff --git a/runtime/queries/tlaplus/injections.scm b/runtime/queries/tlaplus/injections.scm new file mode 100644 index 000000000..fbeff500b --- /dev/null +++ b/runtime/queries/tlaplus/injections.scm @@ -0,0 +1,5 @@ +([ + (comment) + (block_comment_text) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/tlaplus/locals.scm b/runtime/queries/tlaplus/locals.scm new file mode 100644 index 000000000..e105351ef --- /dev/null +++ b/runtime/queries/tlaplus/locals.scm @@ -0,0 +1,167 @@ +; TLA+ scopes and definitions +[ + (bounded_quantification) + (choose) + (function_definition) + (function_literal) + (lambda) + (let_in) + (module) + (module_definition) + (operator_definition) + (set_filter) + (set_map) + (unbounded_quantification) +] @local.scope + +(choose + (identifier) @local.definition.parameter) + +(choose + (tuple_of_identifiers + (identifier) @local.definition.parameter)) + +(constant_declaration + (identifier) @local.definition.constant) + +(constant_declaration + (operator_declaration + name: (_) @local.definition.constant)) + +(function_definition + name: (identifier) @local.definition.function + (#set! definition.function.scope "parent")) + +(lambda + (identifier) @local.definition.parameter) + +(module_definition + name: (_) @local.definition.import + (#set! definition.import.scope "parent")) + +(module_definition + parameter: (identifier) @local.definition.parameter) + +(module_definition + parameter: (operator_declaration + name: (_) @local.definition.parameter)) + +(operator_definition + name: (_) @local.definition.macro + (#set! definition.macro.scope "parent")) + +(operator_definition + parameter: (identifier) @local.definition.parameter) + +(operator_definition + parameter: (operator_declaration + name: (_) @local.definition.parameter)) + +(quantifier_bound + (identifier) @local.definition.parameter) + +(quantifier_bound + (tuple_of_identifiers + (identifier) @local.definition.parameter)) + +(unbounded_quantification + (identifier) @local.definition.parameter) + +(variable_declaration + (identifier) @local.definition.var) + +; Proof scopes and definitions +[ + (non_terminal_proof) + (suffices_proof_step) + (theorem) +] @local.scope + +(assume_prove + (new + (identifier) @local.definition.parameter)) + +(assume_prove + (new + (operator_declaration + name: (_) @local.definition.parameter))) + +(assumption + name: (identifier) @local.definition.constant) + +(pick_proof_step + (identifier) @local.definition.parameter) + +(take_proof_step + (identifier) @local.definition.parameter) + +(theorem + name: (identifier) @local.definition.constant + (#set! definition.constant.scope "parent")) + +; PlusCal scopes and definitions +[ + (pcal_algorithm) + (pcal_macro) + (pcal_procedure) + (pcal_with) +] @local.scope + +(pcal_macro_decl + parameter: (identifier) @local.definition.parameter) + +(pcal_proc_var_decl + (identifier) @local.definition.parameter) + +(pcal_var_decl + (identifier) @local.definition.var) + +(pcal_with + (identifier) @local.definition.parameter) + +; Built-in PlusCal variables +(pcal_algorithm_body + [ + (_ + (identifier_ref) @local.definition.var) + (_ + (_ + (identifier_ref) @local.definition.var)) + (_ + (_ + (_ + (identifier_ref) @local.definition.var))) + (_ + (_ + (_ + (_ + (identifier_ref) @local.definition.var)))) + (_ + (_ + (_ + (_ + (_ + (identifier_ref) @local.definition.var))))) + ] + (#any-of? @local.definition.var "self" "pc" "stack")) + +; References +(identifier_ref) @local.reference + +(prefix_op_symbol) @local.reference + +(bound_prefix_op + symbol: (_) @local.reference) + +(infix_op_symbol) @local.reference + +(bound_infix_op + symbol: (_) @local.reference) + +(postfix_op_symbol) @local.reference + +(bound_postfix_op + symbol: (_) @local.reference) + +(bound_nonfix_op + symbol: (_) @local.reference) diff --git a/runtime/queries/tmux/highlights.scm b/runtime/queries/tmux/highlights.scm new file mode 100644 index 000000000..50da7d7d8 --- /dev/null +++ b/runtime/queries/tmux/highlights.scm @@ -0,0 +1,52 @@ +; Comments +(comment) @comment @spell + +; General +[ + (string) + (raw_string) +] @string + +(int) @number + +(path) @string.special.path + +[ + (option) + (variable_name) +] @variable + +(command_line_option) @variable.builtin + +((option) @variable.builtin + (#not-lua-match? @variable.builtin "^@")) + +(command) @keyword + +(source_file_directive + (command) @keyword.import) + +(attribute) @attribute + +(function_name) @function.call + +"=" @operator + +[ + "," + ":" +] @punctuation.delimiter + +[ + "#" + "?" +] @punctuation.special + +[ + "#{" + "}" + "#[" + "]" + "[" + "{" +] @punctuation.bracket diff --git a/runtime/queries/tmux/injections.scm b/runtime/queries/tmux/injections.scm new file mode 100644 index 000000000..5bf6e27d2 --- /dev/null +++ b/runtime/queries/tmux/injections.scm @@ -0,0 +1,5 @@ +((shell) @injection.content + (#set! injection.language "bash")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/todotxt/highlights.scm b/runtime/queries/todotxt/highlights.scm new file mode 100644 index 000000000..1da096201 --- /dev/null +++ b/runtime/queries/todotxt/highlights.scm @@ -0,0 +1,16 @@ +(done_task) @comment + +(task + (priority) @keyword) + +(task + (date) @comment) + +(task + (kv) @comment) + +(task + (project) @string) + +(task + (context) @type) diff --git a/runtime/queries/toml/folds.scm b/runtime/queries/toml/folds.scm new file mode 100644 index 000000000..a58aae4ca --- /dev/null +++ b/runtime/queries/toml/folds.scm @@ -0,0 +1,5 @@ +[ + (table) + (array) + (table_array_element) +] @fold diff --git a/runtime/queries/toml/highlights.scm b/runtime/queries/toml/highlights.scm new file mode 100644 index 000000000..f4eaf3f77 --- /dev/null +++ b/runtime/queries/toml/highlights.scm @@ -0,0 +1,39 @@ +(bare_key) @property + +[ + (string) + (quoted_key) +] @string + +(boolean) @boolean + +(comment) @comment @spell + +(escape_sequence) @string.escape + +(integer) @number + +(float) @number.float + +[ + (local_date) + (local_date_time) + (local_time) + (offset_date_time) +] @string.special + +"=" @operator + +[ + "." + "," +] @punctuation.delimiter + +[ + "[" + "]" + "[[" + "]]" + "{" + "}" +] @punctuation.bracket diff --git a/runtime/queries/toml/indents.scm b/runtime/queries/toml/indents.scm new file mode 100644 index 000000000..a2391a4bd --- /dev/null +++ b/runtime/queries/toml/indents.scm @@ -0,0 +1,11 @@ +[ + (array) + (inline_table) +] @indent.begin + +[ + "[" + "]" + "{" + "}" +] @indent.branch diff --git a/runtime/queries/toml/injections.scm b/runtime/queries/toml/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/toml/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/toml/locals.scm b/runtime/queries/toml/locals.scm new file mode 100644 index 000000000..2ca4e5404 --- /dev/null +++ b/runtime/queries/toml/locals.scm @@ -0,0 +1,4 @@ +[ + (table) + (table_array_element) +] @local.scope diff --git a/runtime/queries/tsv/highlights.scm b/runtime/queries/tsv/highlights.scm new file mode 100644 index 000000000..f00f13da3 --- /dev/null +++ b/runtime/queries/tsv/highlights.scm @@ -0,0 +1,7 @@ +(text) @string + +(number) @number + +(float) @number.float + +(boolean) @boolean diff --git a/runtime/queries/tsx/folds.scm b/runtime/queries/tsx/folds.scm new file mode 100644 index 000000000..07391231c --- /dev/null +++ b/runtime/queries/tsx/folds.scm @@ -0,0 +1 @@ +; inherits: typescript,jsx diff --git a/runtime/queries/tsx/highlights.scm b/runtime/queries/tsx/highlights.scm new file mode 100644 index 000000000..07391231c --- /dev/null +++ b/runtime/queries/tsx/highlights.scm @@ -0,0 +1 @@ +; inherits: typescript,jsx diff --git a/runtime/queries/tsx/indents.scm b/runtime/queries/tsx/indents.scm new file mode 100644 index 000000000..07391231c --- /dev/null +++ b/runtime/queries/tsx/indents.scm @@ -0,0 +1 @@ +; inherits: typescript,jsx diff --git a/runtime/queries/tsx/injections.scm b/runtime/queries/tsx/injections.scm new file mode 100644 index 000000000..b6d9b28bf --- /dev/null +++ b/runtime/queries/tsx/injections.scm @@ -0,0 +1 @@ +; inherits: ecma,jsx diff --git a/runtime/queries/tsx/locals.scm b/runtime/queries/tsx/locals.scm new file mode 100644 index 000000000..07391231c --- /dev/null +++ b/runtime/queries/tsx/locals.scm @@ -0,0 +1 @@ +; inherits: typescript,jsx diff --git a/runtime/queries/turtle/folds.scm b/runtime/queries/turtle/folds.scm new file mode 100644 index 000000000..f932a3731 --- /dev/null +++ b/runtime/queries/turtle/folds.scm @@ -0,0 +1,5 @@ +[ + (directive) + (triple) + (blank_node_property_list) +] @fold diff --git a/runtime/queries/turtle/highlights.scm b/runtime/queries/turtle/highlights.scm new file mode 100644 index 000000000..30d1f4513 --- /dev/null +++ b/runtime/queries/turtle/highlights.scm @@ -0,0 +1,62 @@ +(string) @string + +(lang_tag) @type + +[ + "_:" + "<" + ">" + (namespace) +] @module + +[ + (iri_reference) + (prefixed_name) +] @variable + +(blank_node_label) @variable + +"a" @variable.builtin + +(integer) @number + +[ + (decimal) + (double) +] @number.float + +(boolean_literal) @boolean + +[ + "BASE" + "PREFIX" + "@prefix" + "@base" +] @keyword + +[ + "." + "," + ";" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + (anon) +] @punctuation.bracket + +(comment) @comment @spell + +(echar) @string.escape + +(rdf_literal + "^^" @type + datatype: (_ + [ + "<" + ">" + (namespace) + ] @type) @type) diff --git a/runtime/queries/turtle/indents.scm b/runtime/queries/turtle/indents.scm new file mode 100644 index 000000000..a60105667 --- /dev/null +++ b/runtime/queries/turtle/indents.scm @@ -0,0 +1,11 @@ +[ + (directive) + (triple) + (blank_node_property_list) + (collection) +] @indent.begin + +[ + "]" + ")" +] @indent.branch diff --git a/runtime/queries/turtle/injections.scm b/runtime/queries/turtle/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/turtle/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/turtle/locals.scm b/runtime/queries/turtle/locals.scm new file mode 100644 index 000000000..0e251e2fa --- /dev/null +++ b/runtime/queries/turtle/locals.scm @@ -0,0 +1,12 @@ +(document) @local.scope + +(subject + [ + (prefixed_name) + (iri_reference) + ] @local.definition.var) + +[ + (prefixed_name) + (iri_reference) +] @local.reference diff --git a/runtime/queries/twig/highlights.scm b/runtime/queries/twig/highlights.scm new file mode 100644 index 000000000..435fdc0f1 --- /dev/null +++ b/runtime/queries/twig/highlights.scm @@ -0,0 +1,81 @@ +(comment) @comment @spell + +(filter_identifier) @function.call + +(function_identifier) @function.call + +(test) @function.builtin + +(variable) @variable + +(string) @string + +(interpolated_string) @string + +(operator) @operator + +(number) @number + +(boolean) @boolean + +(null) @constant.builtin + +(keyword) @keyword + +(attribute) @attribute + +(tag) @tag + +(conditional) @keyword.conditional + +(repeat) @keyword.repeat + +(method) @function.method + +(parameter) @variable.parameter + +[ + "{{" + "}}" + "{{-" + "-}}" + "{{~" + "~}}" + "{%" + "%}" + "{%-" + "-%}" + "{%~" + "~%}" +] @tag.delimiter + +[ + "," + "." +] @punctuation.delimiter + +[ + "?" + ":" + "=" + "|" +] @operator + +(interpolated_string + [ + "#{" + "}" + ] @punctuation.special) + +[ + "(" + ")" + "[" + "]" +] @punctuation.bracket + +(hash + [ + "{" + "}" + ] @punctuation.bracket) diff --git a/runtime/queries/twig/injections.scm b/runtime/queries/twig/injections.scm new file mode 100644 index 000000000..3fd93feb7 --- /dev/null +++ b/runtime/queries/twig/injections.scm @@ -0,0 +1,6 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((content) @injection.content + (#set! injection.language "html") + (#set! injection.combined)) diff --git a/runtime/queries/typescript/folds.scm b/runtime/queries/typescript/folds.scm new file mode 100644 index 000000000..df0b8942a --- /dev/null +++ b/runtime/queries/typescript/folds.scm @@ -0,0 +1,8 @@ +; inherits: ecma + +[ + (interface_declaration) + (internal_module) + (type_alias_declaration) + (enum_declaration) +] @fold diff --git a/runtime/queries/typescript/highlights.scm b/runtime/queries/typescript/highlights.scm new file mode 100644 index 000000000..2fb13d800 --- /dev/null +++ b/runtime/queries/typescript/highlights.scm @@ -0,0 +1,208 @@ +; inherits: ecma + +"require" @keyword.import + +(import_require_clause + source: (string) @string.special.url) + +[ + "declare" + "implements" + "type" + "override" + "module" + "asserts" + "infer" + "is" + "using" +] @keyword + +[ + "namespace" + "interface" + "enum" +] @keyword.type + +[ + "keyof" + "satisfies" +] @keyword.operator + +(as_expression + "as" @keyword.operator) + +(mapped_type_clause + "as" @keyword.operator) + +[ + "abstract" + "private" + "protected" + "public" + "readonly" +] @keyword.modifier + +; types +(type_identifier) @type + +(predefined_type) @type.builtin + +(import_statement + "type" + (import_clause + (named_imports + (import_specifier + name: (identifier) @type)))) + +(template_literal_type) @string + +(non_null_expression + "!" @operator) + +; punctuation +(type_arguments + [ + "<" + ">" + ] @punctuation.bracket) + +(type_parameters + [ + "<" + ">" + ] @punctuation.bracket) + +(object_type + [ + "{|" + "|}" + ] @punctuation.bracket) + +(union_type + "|" @punctuation.delimiter) + +(intersection_type + "&" @punctuation.delimiter) + +(type_annotation + ":" @punctuation.delimiter) + +(type_predicate_annotation + ":" @punctuation.delimiter) + +(index_signature + ":" @punctuation.delimiter) + +(omitting_type_annotation + "-?:" @punctuation.delimiter) + +(adding_type_annotation + "+?:" @punctuation.delimiter) + +(opting_type_annotation + "?:" @punctuation.delimiter) + +"?." @punctuation.delimiter + +(abstract_method_signature + "?" @punctuation.special) + +(method_signature + "?" @punctuation.special) + +(method_definition + "?" @punctuation.special) + +(property_signature + "?" @punctuation.special) + +(optional_parameter + "?" @punctuation.special) + +(optional_type + "?" @punctuation.special) + +(public_field_definition + [ + "?" + "!" + ] @punctuation.special) + +(flow_maybe_type + "?" @punctuation.special) + +(template_type + [ + "${" + "}" + ] @punctuation.special) + +(conditional_type + [ + "?" + ":" + ] @keyword.conditional.ternary) + +; Parameters +(required_parameter + pattern: (identifier) @variable.parameter) + +(optional_parameter + pattern: (identifier) @variable.parameter) + +(required_parameter + (rest_pattern + (identifier) @variable.parameter)) + +; ({ a }) => null +(required_parameter + (object_pattern + (shorthand_property_identifier_pattern) @variable.parameter)) + +; ({ a = b }) => null +(required_parameter + (object_pattern + (object_assignment_pattern + (shorthand_property_identifier_pattern) @variable.parameter))) + +; ({ a: b }) => null +(required_parameter + (object_pattern + (pair_pattern + value: (identifier) @variable.parameter))) + +; ([ a ]) => null +(required_parameter + (array_pattern + (identifier) @variable.parameter)) + +; a => null +(arrow_function + parameter: (identifier) @variable.parameter) + +; global declaration +(ambient_declaration + "global" @module) + +; function signatures +(ambient_declaration + (function_signature + name: (identifier) @function)) + +; method signatures +(method_signature + name: (_) @function.method) + +(abstract_method_signature + name: (property_identifier) @function.method) + +; property signatures +(property_signature + name: (property_identifier) @function.method + type: (type_annotation + [ + (union_type + (parenthesized_type + (function_type))) + (function_type) + ])) diff --git a/runtime/queries/typescript/indents.scm b/runtime/queries/typescript/indents.scm new file mode 100644 index 000000000..9a269ba75 --- /dev/null +++ b/runtime/queries/typescript/indents.scm @@ -0,0 +1,7 @@ +; inherits: ecma + +[ + (enum_declaration) + (interface_declaration) + (object_type) +] @indent.begin diff --git a/runtime/queries/typescript/injections.scm b/runtime/queries/typescript/injections.scm new file mode 100644 index 000000000..04328f099 --- /dev/null +++ b/runtime/queries/typescript/injections.scm @@ -0,0 +1 @@ +; inherits: ecma diff --git a/runtime/queries/typescript/locals.scm b/runtime/queries/typescript/locals.scm new file mode 100644 index 000000000..b89d9a0c0 --- /dev/null +++ b/runtime/queries/typescript/locals.scm @@ -0,0 +1,31 @@ +; inherits: ecma + +(required_parameter + (identifier) @local.definition) + +(optional_parameter + (identifier) @local.definition) + +; x => x +(arrow_function + parameter: (identifier) @local.definition.parameter) + +; ({ a }) => null +(required_parameter + (object_pattern + (shorthand_property_identifier_pattern) @local.definition.parameter)) + +; ({ a: b }) => null +(required_parameter + (object_pattern + (pair_pattern + value: (identifier) @local.definition.parameter))) + +; ([ a ]) => null +(required_parameter + (array_pattern + (identifier) @local.definition.parameter)) + +(required_parameter + (rest_pattern + (identifier) @local.definition.parameter)) diff --git a/runtime/queries/typespec/highlights.scm b/runtime/queries/typespec/highlights.scm new file mode 100644 index 000000000..68c67c0d1 --- /dev/null +++ b/runtime/queries/typespec/highlights.scm @@ -0,0 +1,135 @@ +(identifier_or_member_expression) @type + +[ + "is" + "extends" + "valueof" +] @keyword.operator + +[ + "namespace" + "model" + "scalar" + "interface" + "enum" + "union" + "alias" +] @keyword.type + +[ + "op" + "fn" + "dec" +] @keyword.function + +"extern" @keyword.modifier + +[ + "import" + "using" +] @keyword.import + +[ + "(" + ")" + "{" + "}" + "<" + ">" + "[" + "]" +] @punctuation.bracket + +[ + "," + ";" + "." + ":" +] @punctuation.delimiter + +[ + "|" + "&" + "=" + "..." +] @operator + +"?" @punctuation.special + +[ + (single_line_comment) + (multi_line_comment) +] @comment @spell + +[ + (quoted_string_literal) + (triple_quoted_string_literal) +] @string + +(boolean_literal) @boolean + +[ + (decimal_literal) + (hex_integer_literal) + (binary_integer_literal) +] @number + +(escape_sequence) @string.escape + +(builtin_type) @type.builtin + +(decorator + "@" @attribute + name: (identifier_or_member_expression) @attribute) + +(augment_decorator_statement + name: (identifier_or_member_expression) @attribute) + +(using_statement + module: (identifier_or_member_expression) @module) + +(namespace_statement + name: (identifier_or_member_expression) @module) + +(model_statement + name: (identifier) @type) + +(model_property + name: (identifier) @variable.member) + +(union_statement + name: (identifier) @type) + +(union_variant + name: (identifier) @variable.member) + +(scalar_statement + name: (identifier) @type) + +(interface_statement + name: (identifier) @type) + +(enum_statement + name: (identifier) @type) + +(enum_member + name: (identifier) @constant) + +(operation_statement + name: (identifier) @function) + +(template_parameter + name: (identifier) @type) + +(alias_statement + name: (identifier) @type) + +(decorator_declaration_statement + name: (identifier) @attribute) + +(function_parameter + name: (identifier) @variable.parameter) + +(operation_arguments + (model_property + name: (identifier) @variable.parameter)) diff --git a/runtime/queries/typespec/indents.scm b/runtime/queries/typespec/indents.scm new file mode 100644 index 000000000..aee01f35a --- /dev/null +++ b/runtime/queries/typespec/indents.scm @@ -0,0 +1,18 @@ +[ + (model_expression) + (tuple_expression) + (namespace_body) + (interface_body) + (union_body) + (enum_body) + (template_arguments) + (template_parameters) + (operation_arguments) +] @indent.begin + +[ + "}" + ")" + ">" + "]" +] @indent.end diff --git a/runtime/queries/typespec/injections.scm b/runtime/queries/typespec/injections.scm new file mode 100644 index 000000000..81d7734cb --- /dev/null +++ b/runtime/queries/typespec/injections.scm @@ -0,0 +1,5 @@ +([ + (single_line_comment) + (multi_line_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/typoscript/folds.scm b/runtime/queries/typoscript/folds.scm new file mode 100644 index 000000000..fd7d23999 --- /dev/null +++ b/runtime/queries/typoscript/folds.scm @@ -0,0 +1 @@ +(block) @fold diff --git a/runtime/queries/typoscript/highlights.scm b/runtime/queries/typoscript/highlights.scm new file mode 100644 index 000000000..63327f178 --- /dev/null +++ b/runtime/queries/typoscript/highlights.scm @@ -0,0 +1,47 @@ +(identifier) @variable.member + +(constant) @constant + +(modifier_function) @function + +(modifier_predefined) @function.builtin + +[ + (condition) + (condition_end) + (condition_else) +] @keyword.conditional + +(cobject) @type.builtin + +[ + "@import" + "INCLUDE_TYPOSCRIPT" +] @keyword.import + +[ + (comment) + (single_line_comment) +] @comment @spell + +[ + (string) + (multiline_value) +] @string + +[ + "=" + ">" + "<" + ":=" + "=<" + (condition_bool) +] @operator + +"," @punctuation.delimiter + +[ + "(" + ")" + (block_punctuation) +] @punctuation.bracket diff --git a/runtime/queries/typoscript/indents.scm b/runtime/queries/typoscript/indents.scm new file mode 100644 index 000000000..4f5fb4797 --- /dev/null +++ b/runtime/queries/typoscript/indents.scm @@ -0,0 +1,5 @@ +(block) @indent.begin + +"}" @indent.branch @indent.end + +(comment) @indent.ignore diff --git a/runtime/queries/typoscript/injections.scm b/runtime/queries/typoscript/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/typoscript/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/typst/folds.scm b/runtime/queries/typst/folds.scm new file mode 100644 index 000000000..ef0ec7956 --- /dev/null +++ b/runtime/queries/typst/folds.scm @@ -0,0 +1,11 @@ +[ + (set) + (let) + (show) + (call) + (section) + (for) + (branch) + (content) + (raw_blck) +] @fold diff --git a/runtime/queries/typst/highlights.scm b/runtime/queries/typst/highlights.scm new file mode 100644 index 000000000..a0dcc1b89 --- /dev/null +++ b/runtime/queries/typst/highlights.scm @@ -0,0 +1,131 @@ +; punctuation +"#" @punctuation.special + +[ + ":" + ";" + "," +] @punctuation.delimiter + +; TODO: context blocks for "[" "]"? +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +; operators +[ + "-" + "+" + "*" + "/" + "==" + "!=" + "<" + "<=" + ">" + ">=" + "=" + "in" + "and" + "or" + "not" +] @operator + +; keywords +[ + "import" + "include" +] @keyword.import + +[ + "let" + "set" + "show" +] @keyword + +; control flow +[ + "for" + "while" + "break" + "continue" +] @keyword.repeat + +[ + "if" + "else" +] @keyword.conditional + +; special case: #for (ident) in (expr) +(for + "in" @keyword.repeat) + +; type literals +(number) @number + +(string) @string + +(bool) @boolean + +(ident) @constant + +; name-value pairs +(tagged + field: (ident) @variable.member) + +(call + item: (ident) @function.call) + +; text +(text) @spell + +(heading + "=" @markup.heading.1) @markup.heading.1 + +(heading + "==" @markup.heading.2) @markup.heading.2 + +(heading + "===" @markup.heading.3) @markup.heading.3 + +(heading + "====" @markup.heading.4) @markup.heading.4 + +(heading + "=====" @markup.heading.5) @markup.heading.5 + +(heading + "======" @markup.heading.6) @markup.heading.6 + +(strong) @markup.strong + +(emph) @markup.italic + +(url) @markup.link.url + +; code blocks +(raw_span) @markup.raw + +(raw_blck) @markup.raw + +(raw_blck + lang: (ident) @label) + +(raw_blck + (blob) @markup.raw.block) + +; refs and labels +(label) @markup.link.label + +(ref) @markup.link + +; math +(math) @markup.math + +; comments +(comment) @comment @spell diff --git a/runtime/queries/typst/indents.scm b/runtime/queries/typst/indents.scm new file mode 100644 index 000000000..d43c586c1 --- /dev/null +++ b/runtime/queries/typst/indents.scm @@ -0,0 +1,12 @@ +[ + (set) + (let) + (show) + (call) +] @indent.begin + +[ + "]" + "}" + ")" +] @indent.branch @indent.end diff --git a/runtime/queries/typst/injections.scm b/runtime/queries/typst/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/typst/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/udev/highlights.scm b/runtime/queries/udev/highlights.scm new file mode 100644 index 000000000..f95238d70 --- /dev/null +++ b/runtime/queries/udev/highlights.scm @@ -0,0 +1,67 @@ +(match + key: _ @keyword) + +(assignment + key: _ @property) + +(value) @string + +; NOTE: higher priorities override bash highlights +((fmt_sub + . + _ @character.special) + (#set! priority 101)) + +((var_sub + . + _ @variable.builtin) + (#set! priority 101)) + +[ + (system_const) + (run_type) + (import_type) + (kernel_param) + (seclabel) +] @attribute + +((attribute) @attribute + (#set! priority 101)) + +((env_var) @constant + (#set! priority 101)) + +((pattern) @string.special + (#set! priority 101)) + +([ + "\\\"" + (c_escape) +] @string.escape + (#set! priority 101)) + +(octal) @number + +((number) @number + (#set! priority 101)) + +[ + (match_op) + (assignment_op) +] @operator + +("+" @punctuation.special + (#set! priority 101)) + +([ + "{" + "}" +] @punctuation.bracket + (#set! priority 101)) + +[ + "," + (linebreak) +] @punctuation.delimiter + +(comment) @comment @spell diff --git a/runtime/queries/udev/injections.scm b/runtime/queries/udev/injections.scm new file mode 100644 index 000000000..1718349c6 --- /dev/null +++ b/runtime/queries/udev/injections.scm @@ -0,0 +1,14 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((match + key: "PROGRAM" + (value + (content) @injection.content)) + (#set! injection.language "bash")) + +((assignment + key: "RUN" + (value + (content) @injection.content)) + (#set! injection.language "bash")) diff --git a/runtime/queries/udev/locals.scm b/runtime/queries/udev/locals.scm new file mode 100644 index 000000000..e1a2f65d2 --- /dev/null +++ b/runtime/queries/udev/locals.scm @@ -0,0 +1,29 @@ +; labels +(assignment + key: "LABEL" + (value + (content) @local.definition)) + +(assignment + key: "GOTO" + (value + (content) @local.reference)) + +; env vars +(assignment + key: "ENV" + (env_var) @local.definition.var) + +(match + key: "ENV" + (env_var) @local.reference) + +(var_sub + (env_var) @local.reference) + +; misc +[ + (attribute) + (kernel_param) + (seclabel) +] @local.reference diff --git a/runtime/queries/ungrammar/folds.scm b/runtime/queries/ungrammar/folds.scm new file mode 100644 index 000000000..206c4bed8 --- /dev/null +++ b/runtime/queries/ungrammar/folds.scm @@ -0,0 +1 @@ +(node) @fold diff --git a/runtime/queries/ungrammar/highlights.scm b/runtime/queries/ungrammar/highlights.scm new file mode 100644 index 000000000..4ed523c9b --- /dev/null +++ b/runtime/queries/ungrammar/highlights.scm @@ -0,0 +1,26 @@ +(comment) @comment @spell + +(definition) @keyword + +(identifier) @variable + +(label_name) @label + +(token) @string + +[ + "=" + "|" +] @operator + +[ + "*" + "?" +] @keyword.repeat + +":" @punctuation.delimiter + +[ + "(" + ")" +] @punctuation.bracket diff --git a/runtime/queries/ungrammar/indents.scm b/runtime/queries/ungrammar/indents.scm new file mode 100644 index 000000000..a5ececdbe --- /dev/null +++ b/runtime/queries/ungrammar/indents.scm @@ -0,0 +1,6 @@ +(node) @indent.begin + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/runtime/queries/ungrammar/injections.scm b/runtime/queries/ungrammar/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/ungrammar/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/ungrammar/locals.scm b/runtime/queries/ungrammar/locals.scm new file mode 100644 index 000000000..0f745bd14 --- /dev/null +++ b/runtime/queries/ungrammar/locals.scm @@ -0,0 +1,8 @@ +(grammar) @local.scope + +[ + (definition) + (label_name) +] @local.definition + +(identifier) @local.reference diff --git a/runtime/queries/unison/folds.scm b/runtime/queries/unison/folds.scm new file mode 100644 index 000000000..3bfc585c3 --- /dev/null +++ b/runtime/queries/unison/folds.scm @@ -0,0 +1,10 @@ +[ + (fold) + (type_declaration) + (term_declaration) + (literal_list) + (exp_if) + (pattern) + (parenthesized_or_tuple_pattern) + (delay_block) +] @fold diff --git a/runtime/queries/unison/highlights.scm b/runtime/queries/unison/highlights.scm new file mode 100644 index 000000000..5fa721046 --- /dev/null +++ b/runtime/queries/unison/highlights.scm @@ -0,0 +1,125 @@ +; Primitives +(comment) @comment @spell + +(nat) @number + +(unit) @constant.builtin + +(literal_char) @character + +(literal_text) @string + +(literal_boolean) @boolean + +; Keywords +(type_kw) @keyword.type + +[ + (kw_forall) + (do) + (kw_let) + (ability) + (where) +] @keyword + +(structural) @keyword.modifier + +(unique) @keyword.modifier + +(type_constructor) @constructor + +((doc_block) @comment.documentation @spell + (#set! priority 90)) + +[ + (operator) + (pipe) + (arrow_symbol) + (or) + (kw_equals) +] @operator + +[ + "if" + "else" + "then" + (match) + (with) + (cases) +] @keyword.conditional + +(blank_pattern) @variable.builtin + +(pattern) @variable + +(use_clause) @keyword.import + +; Types +(record_field + (field_name) @variable.member + type: (regular_identifier) @type) + +(type_name) @type + +(type_declaration + (regular_identifier) @type) + +(ability_name + (path)? @module + (regular_identifier) @type) + +(ability_declaration + (ability_name) @type + (type_argument) @variable.parameter) + +(constructor + (constructor_name) @constructor) + +(constructor + type: (regular_identifier) @type) + +(effect + (regular_identifier) @attribute) ; NOTE: an effect is a special type + +; Namespaces +(path) @module + +(namespace) @module + +; Terms +(type_signature + term_name: (path) @module + term_name: (regular_identifier) @variable) + +(type_signature + term_name: (regular_identifier) @variable) + +(term_type) @type + +(term_definition + name: (path) @module) + +(term_definition + name: (regular_identifier) @variable) + +(term_definition + param: (regular_identifier) @variable.parameter) + +; Punctuation +[ + (type_signature_colon) + ":" +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +(watch_expression) @keyword.directive + +(test_watch_expression) @keyword.directive diff --git a/runtime/queries/unison/injections.scm b/runtime/queries/unison/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/unison/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/usd/folds.scm b/runtime/queries/usd/folds.scm new file mode 100644 index 000000000..fd7d23999 --- /dev/null +++ b/runtime/queries/usd/folds.scm @@ -0,0 +1 @@ +(block) @fold diff --git a/runtime/queries/usd/highlights.scm b/runtime/queries/usd/highlights.scm new file mode 100644 index 000000000..d6c2a3668 --- /dev/null +++ b/runtime/queries/usd/highlights.scm @@ -0,0 +1,154 @@ +(None) @constant.builtin + +(asset_path) @string.special.url + +(attribute_property) @property + +(bool) @boolean + +(comment) @comment @spell + +(custom) @function.builtin + +(float) @number.float + +(integer) @number + +(orderer) @function.call + +(prim_path) @string.special + +(relationship_type) @type + +(string) @string + +(uniform) @function.builtin + +(variant_set_definition) @keyword + +; Prefer namespace highlighting, if any. +; +; e.g. `rel fizz` - `fizz` uses `@identifier` +; e.g. `rel foo:bar:fizz` - `foo` and `bar` use `@module` and `fizz` uses `@identifier` +; +(identifier) @variable + +(namespace_identifier) @module + +(namespace_identifier + (identifier) @module) + +[ + "def" + "over" +] @keyword.function + +"class" @keyword.type + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + ":" + ";" + "." +] @punctuation.delimiter + +"=" @operator + +(attribute_type) @type + +((attribute_type) @type.builtin + ;format-ignore + (#any-of? @type.builtin + ;; Reference: https://openusd.org/release/api/sdf_page_front.html + ;; Scalar types + "asset" "asset[]" + "bool" "bool[]" + "double" "double[]" + "float" "float[]" + "half" "half[]" + "int" "int[]" + "int64" "int64[]" + "string" "string[]" + "timecode" "timecode[]" + "token" "token[]" + "uchar" "uchar[]" + "uint" "uint[]" + "uint64" "uint64[]" + + ;; Dimensioned Types + "double2" "double2[]" + "double3" "double3[]" + "double4" "double4[]" + "float2" "float2[]" + "float3" "float3[]" + "float4" "float4[]" + "half2" "half2[]" + "half3" "half3[]" + "half4" "half4[]" + "int2" "int2[]" + "int3" "int3[]" + "int4" "int4[]" + "matrix2d" "matrix2d[]" + "matrix3d" "matrix3d[]" + "matrix4d" "matrix4d[]" + "quatd" "quatd[]" + "quatf" "quatf[]" + "quath" "quath[]" + + ;; Extra Types + "color3f" "color3f[]" + "normal3f" "normal3f[]" + "point3f" "point3f[]" + "texCoord2f" "texCoord2f[]" + "vector3d" "vector3d[]" + "vector3f" "vector3f[]" + "vector3h" "vector3h[]" + + "dictionary" + + ;; Deprecated Types + "EdgeIndex" "EdgeIndex[]" + "FaceIndex" "FaceIndex[]" + "Matrix4d" "Matrix4d[]" + "PointIndex" "PointIndex[]" + "PointFloat" "PointFloat[]" + "Transform" "Transform[]" + "Vec3f" "Vec3f[]")) + +((identifier) @keyword + (#any-of? @keyword + ; Reference: https://openusd.org/release/api/sdf_page_front.html + ; LIVRPS names + "inherits" "payload" "references" "specializes" "variantSets" "variants" + ; assetInfo names + "assetInfo" "identifier" "name" "payloadAssetDependencies" "version" + ; clips names + "clips" "active" "assetPaths" "manifestAssetPath" "primPath" "templateAssetPath" + "templateEndTime" "templateStartTime" "templateStride" "times" + ; customData names + "customData" "apiSchemaAutoApplyTo" "apiSchemaOverridePropertyNames" "className" "extraPlugInfo" + "isUsdShadeContainer" "libraryName" "providesUsdShadeConnectableAPIBehavior" + "requiresUsdShadeEncapsulation" "skipCodeGeneration" + ; Layer metadata names + "colorConfiguration" "colorManagementSystem" "customLayerData" "defaultPrim" "doc" "endTimeCode" + "framesPerSecond" "owner" "startTimeCode" "subLayers" + ; Prim metadata + "instanceable")) + +; Common attribute metadata +(layer_offset + (identifier) @keyword + (#any-of? @keyword "offset" "scale")) + +; Docstrings in USD +(metadata + (comment)* + (string) @comment.documentation) diff --git a/runtime/queries/usd/indents.scm b/runtime/queries/usd/indents.scm new file mode 100644 index 000000000..217d12d3f --- /dev/null +++ b/runtime/queries/usd/indents.scm @@ -0,0 +1,42 @@ +; format-ignore +[ + (block) ; The {}s in `def "foo" { ... Attributes / Prims here ... }` + (dictionary) ; The {}s in `dictionary foo = { string "foo" = "bar" }` + (list) + (list_proxy) ; [@foo.usda@, @bar.usda@] + (metadata) ; ( anything = "goes-here" ) + (prim_paths) ; [</foo>, <../bar>] + (timeSamples) ; The {}s in `int value.timeSamples = { 0: 1, -10: 10, ... }` + (tuple) + (variant_set_definition) ; The {}s in `variantSet "foo" = { "vr1" { ... } "vr2" { ... } }` +] @indent.begin + +(block + "}" @indent.end) + +(dictionary + "}" @indent.end) + +(list + "]" @indent.end) + +(list_proxy + "]" @indent.end) + +(metadata + ")" @indent.end) + +(timeSamples + "}" @indent.end) + +(tuple + ")" @indent.end) + +(variant_set_definition + "}" @indent.end) + +[ + ")" + "]" + "}" +] @indent.branch diff --git a/runtime/queries/usd/injections.scm b/runtime/queries/usd/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/usd/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/usd/locals.scm b/runtime/queries/usd/locals.scm new file mode 100644 index 000000000..89eb171d1 --- /dev/null +++ b/runtime/queries/usd/locals.scm @@ -0,0 +1,4 @@ +[ + (block) + (metadata) +] @local.scope diff --git a/runtime/queries/uxntal/folds.scm b/runtime/queries/uxntal/folds.scm new file mode 100644 index 000000000..9e3f27db0 --- /dev/null +++ b/runtime/queries/uxntal/folds.scm @@ -0,0 +1,6 @@ +[ + (macro) + (memory_execution) + (subroutine) + (comment) +] @fold diff --git a/runtime/queries/uxntal/highlights.scm b/runtime/queries/uxntal/highlights.scm new file mode 100644 index 000000000..962b6d7b9 --- /dev/null +++ b/runtime/queries/uxntal/highlights.scm @@ -0,0 +1,87 @@ +; Includes +(include + "~" @keyword.import + _ @string.special.url) + +; Variables +(identifier) @variable + +; Macros +(macro + "%" + (identifier) @function.macro) + +((identifier) @function.macro + (#lua-match? @function.macro "^[a-z]?[0-9]*[A-Z-_]+$")) + +(rune + . + rune_start: (rune_char + ",") + . + (identifier) @function.call) + +(rune + . + rune_start: (rune_char + ";") + . + (identifier) @function.call) + +((identifier) @function.call + (#lua-match? @function.call "^:")) + +; Keywords +(opcode) @keyword + +; Labels +(label + "@" @string.special.symbol + (identifier) @function) + +(sublabel_reference + (identifier) @module + "/" @punctuation.delimiter + (identifier) @label) + +; Repeats +((identifier) @keyword.repeat + (#eq? @keyword.repeat "while")) + +; Literals +(raw_ascii) @string + +(hex_literal + "#" @string.special.symbol + (hex_lit_value) @string.special) + +(number) @number + +; Punctuation +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "%" + "|" + "$" + "," + "_" + "." + "-" + ";" + "=" + "!" + "?" + "&" +] @punctuation.special + +; Comments +(comment) @comment @spell diff --git a/runtime/queries/uxntal/indents.scm b/runtime/queries/uxntal/indents.scm new file mode 100644 index 000000000..b795b89ea --- /dev/null +++ b/runtime/queries/uxntal/indents.scm @@ -0,0 +1,23 @@ +(memory_execution) @indent.auto + +[ + (subroutine) + (brackets) +] @indent.begin + +"}" @indent.end + +[ + "{" + "}" +] @indent.branch + +[ + "[" + "]" +] @indent.branch + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/runtime/queries/uxntal/injections.scm b/runtime/queries/uxntal/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/uxntal/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/uxntal/locals.scm b/runtime/queries/uxntal/locals.scm new file mode 100644 index 000000000..41fbb5b66 --- /dev/null +++ b/runtime/queries/uxntal/locals.scm @@ -0,0 +1,21 @@ +; Scopes +[ + (program) + (macro) + (memory_execution) + (subroutine) +] @local.scope + +; References +(identifier) @local.reference + +; Definitions +(label + "@" + . + (identifier) @local.definition.function) + +(macro + "%" + . + (identifier) @local.definition.macro) diff --git a/runtime/queries/v/folds.scm b/runtime/queries/v/folds.scm new file mode 100644 index 000000000..952b6bbe9 --- /dev/null +++ b/runtime/queries/v/folds.scm @@ -0,0 +1,8 @@ +[ + (function_declaration) + (const_declaration) + (type_declaration) + (import_declaration) + (if_expression) + (struct_declaration) +] @fold diff --git a/runtime/queries/v/highlights.scm b/runtime/queries/v/highlights.scm new file mode 100644 index 000000000..982f3dbd5 --- /dev/null +++ b/runtime/queries/v/highlights.scm @@ -0,0 +1,300 @@ +(shebang) @keyword.directive + +; Includes +[ + "import" + "module" +] @keyword.import + +; Keywords +[ + "asm" + "assert" + "const" + "defer" + "goto" + "sql" + "unsafe" +] @keyword + +[ + "enum" + "union" + "struct" + "interface" + "type" +] @keyword.type + +[ + "as" + "in" + "!in" + "or" + "is" + "!is" +] @keyword.operator + +[ + "match" + "if" + "$if" + "else" + "$else" + "select" +] @keyword.conditional + +[ + "for" + "$for" + "continue" + "break" +] @keyword.repeat + +"fn" @keyword.function + +"return" @keyword.return + +[ + "__global" + "shared" + "static" + "const" +] @keyword.modifier + +[ + "pub" + "mut" +] @keyword.modifier + +[ + "go" + "spawn" + "lock" + "rlock" +] @keyword.coroutine + +; Variables +(identifier) @variable + +; Namespace +(module_clause + (identifier) @module) + +(import_path + (import_name) @module) + +(import_alias + (import_name) @module) + +; Literals +[ + (true) + (false) +] @boolean + +(interpreted_string_literal) @string + +(string_interpolation) @none + +; Types +(struct_declaration + name: (identifier) @type) + +(enum_declaration + name: (identifier) @type) + +(interface_declaration + name: (identifier) @type) + +(type_declaration + name: (identifier) @type) + +(type_reference_expression + (identifier) @type) + +; Labels +(label_reference) @label + +; Fields +(selector_expression + field: (reference_expression + (identifier) @variable.member)) + +(field_name) @variable.member + +(struct_field_declaration + name: (identifier) @variable.member) + +; Parameters +(parameter_declaration + name: (identifier) @variable.parameter) + +(receiver + name: (identifier) @variable.parameter) + +; Constants +((identifier) @constant + (#has-ancestor? @constant compile_time_if_expression)) + +(enum_fetch + (reference_expression) @constant) + +(enum_field_definition + (identifier) @constant) + +(const_definition + name: (identifier) @constant) + +((identifier) @variable.builtin + (#any-of? @variable.builtin "err" "macos" "linux" "windows")) + +; Attributes +(attribute) @attribute + +; Functions +(function_declaration + name: (identifier) @function) + +(function_declaration + receiver: (receiver) + name: (identifier) @function.method) + +(call_expression + name: (selector_expression + field: (reference_expression) @function.method.call)) + +(call_expression + name: (reference_expression) @function.call) + +((identifier) @function.builtin + (#any-of? @function.builtin + "eprint" "eprintln" "error" "exit" "panic" "print" "println" "after" "after_char" "all" + "all_after" "all_after_last" "all_before" "all_before_last" "any" "ascii_str" "before" "bool" + "byte" "byterune" "bytes" "bytestr" "c_error_number_str" "capitalize" "clear" "clone" + "clone_to_depth" "close" "code" "compare" "compare_strings" "contains" "contains_any" + "contains_any_substr" "copy" "count" "cstring_to_vstring" "delete" "delete_last" "delete_many" + "ends_with" "eprint" "eprintln" "eq_epsilon" "error" "error_with_code" "exit" "f32" "f32_abs" + "f32_max" "f32_min" "f64" "f64_max" "fields" "filter" "find_between" "first" "flush_stderr" + "flush_stdout" "free" "gc_check_leaks" "get_str_intp_u32_format" "get_str_intp_u64_format" + "grow_cap" "grow_len" "hash" "hex" "hex2" "hex_full" "i16" "i64" "i8" "index" "index_after" + "index_any" "index_byte" "insert" "int" "is_alnum" "is_bin_digit" "is_capital" "is_digit" + "is_hex_digit" "is_letter" "is_lower" "is_oct_digit" "is_space" "is_title" "is_upper" "isnil" + "join" "join_lines" "keys" "last" "last_index" "last_index_byte" "length_in_bytes" "limit" + "malloc" "malloc_noscan" "map" "match_glob" "memdup" "memdup_noscan" "move" "msg" "panic" + "panic_error_number" "panic_lasterr" "panic_optional_not_set" "parse_int" "parse_uint" + "pointers" "pop" "prepend" "print" "print_backtrace" "println" "proc_pidpath" "ptr_str" + "push_many" "realloc_data" "reduce" "repeat" "repeat_to_depth" "replace" "replace_each" + "replace_once" "reverse" "reverse_in_place" "runes" "sort" "sort_by_len" "sort_ignore_case" + "sort_with_compare" "split" "split_any" "split_into_lines" "split_nth" "starts_with" + "starts_with_capital" "str" "str_escaped" "str_intp" "str_intp_g32" "str_intp_g64" + "str_intp_rune" "str_intp_sq" "str_intp_sub" "strg" "string_from_wide" "string_from_wide2" + "strip_margin" "strip_margin_custom" "strlong" "strsci" "substr" "substr_ni" "substr_with_check" + "title" "to_lower" "to_upper" "to_wide" "tos" "tos2" "tos3" "tos4" "tos5" "tos_clone" "trim" + "trim_left" "trim_pr" "try_pop" "try_push" "utf32_decode_to_buffer" "utf32_to_str" + "utf32_to_str_no_malloc" "utf8_char_len" "utf8_getchar" "utf8_str_len" "utf8_str_visible_length" + "utf8_to_utf32" "v_realloc" "vbytes" "vcalloc" "vcalloc_noscan" "vmemcmp" "vmemcpy" "vmemmove" + "vmemset" "vstring" "vstring_literal" "vstring_literal_with_len" "vstring_with_len" "vstrlen" + "vstrlen_char" "winapi_lasterr_str")) + +; Operators +[ + "++" + "--" + "+" + "-" + "*" + "/" + "%" + "~" + "&" + "|" + "^" + "!" + "&&" + "||" + "!=" + "<<" + ">>" + "<" + ">" + "<=" + ">=" + "+=" + "-=" + "*=" + "/=" + "&=" + "|=" + "^=" + "<<=" + ">>=" + "=" + ":=" + "==" + "?" + "<-" + "$" + ".." + "..." +] @operator + +; Punctuation +[ + "." + "," + ":" + ";" +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +; Literals +(int_literal) @number + +(float_literal) @number.float + +[ + (c_string_literal) + (raw_string_literal) + (interpreted_string_literal) + (string_interpolation) + (rune_literal) +] @string + +(string_interpolation + (interpolation_opening) @punctuation.bracket + (interpolation_expression) @none + (interpolation_closing) @punctuation.bracket) + +(escape_sequence) @string.escape + +[ + (true) + (false) +] @boolean + +(nil) @constant.builtin + +(none) @variable.builtin + +; Comments +[ + (line_comment) + (block_comment) +] @comment @spell + +(_ + (line_comment)+ @comment.documentation + . + [ + (function_declaration) + (type_declaration) + (enum_declaration) + ]) diff --git a/runtime/queries/v/indents.scm b/runtime/queries/v/indents.scm new file mode 100644 index 000000000..bf090efae --- /dev/null +++ b/runtime/queries/v/indents.scm @@ -0,0 +1,20 @@ +[ + (import_declaration) + (const_declaration) + (type_declaration) + (type_initializer) + (block) + (map_init_expression) + (call_expression) + (parameter_list) +] @indent.begin + +"}" @indent.branch + +(parameter_list + ")" @indent.branch) + +[ + (line_comment) + (block_comment) +] @indent.ignore diff --git a/runtime/queries/v/injections.scm b/runtime/queries/v/injections.scm new file mode 100644 index 000000000..2d7618b3e --- /dev/null +++ b/runtime/queries/v/injections.scm @@ -0,0 +1,23 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) + +; asm_statement if asm ever highlighted :) +; #include <...> +((hash_statement) @injection.content + (#set! injection.language "c")) + +; regex for the methods defined in `re` module +((call_expression + name: (selector_expression + field: (reference_expression + (identifier) @_re)) + arguments: (argument_list + (argument + (literal + (raw_string_literal) @injection.content + (#offset! @injection.content 0 2 0 -1))))) + (#any-of? @_re "regex_base" "regex_opt" "compile_opt") + (#set! injection.language "regex")) diff --git a/runtime/queries/v/locals.scm b/runtime/queries/v/locals.scm new file mode 100644 index 000000000..a3423f696 --- /dev/null +++ b/runtime/queries/v/locals.scm @@ -0,0 +1,37 @@ +(function_declaration + name: (identifier) @local.definition.function) ;@function + +(var_declaration + var_list: (expression_list + (reference_expression + (identifier) @local.definition.var))) + +(function_declaration + name: (identifier) @local.definition.function) + +(const_declaration + (const_definition + name: (identifier) @local.definition.var)) + +(identifier) @local.reference + +((call_expression + name: (reference_expression + (identifier)) @local.reference) + (#set! reference.kind "call")) + +((call_expression + name: (selector_expression + field: (reference_expression + (identifier) @local.definition.function))) + (#set! reference.kind "call")) + +(source_file) @local.scope + +(function_declaration) @local.scope + +(if_expression) @local.scope + +(block) @local.scope + +(for_statement) @local.scope diff --git a/runtime/queries/vala/folds.scm b/runtime/queries/vala/folds.scm new file mode 100644 index 000000000..a334e609c --- /dev/null +++ b/runtime/queries/vala/folds.scm @@ -0,0 +1,11 @@ +[ + (namespace_member) + (enum_declaration) + (class_declaration) + (if_statement) + (elseif_statement) + (try_statement) + (catch_clause) + (block) + (class_member) +] @fold diff --git a/runtime/queries/vala/highlights.scm b/runtime/queries/vala/highlights.scm new file mode 100644 index 000000000..0ba11caa1 --- /dev/null +++ b/runtime/queries/vala/highlights.scm @@ -0,0 +1,346 @@ +; highlights.scm +; highlight comments and symbols +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +(symbol) @string.special.symbol + +(member_access_expression + (_) + (identifier) @string.special.symbol) + +; highlight constants +((member_access_expression + (identifier) @constant) + (#lua-match? @constant "^[%u][%u%d_]*$")) + +((member_access_expression + (member_access_expression) @keyword.import + (identifier) @constant) + (#lua-match? @constant "^[%u][%u%d_]*$")) + +; highlight types and probable types +(type + (symbol + (_)? @module + (identifier) @type)) + +((member_access_expression + . + (identifier) @type) + (#match? @type "^[A-Z][A-Za-z_0-9]{2,}$")) + +; highlight creation methods in object creation expressions +((object_creation_expression + (type + (symbol + (symbol + (symbol)? @keyword.import + (identifier) @type) + (identifier) @constructor))) + (#lua-match? @constructor "^[%l][%l%d_]*$")) + +(unqualified_type + (symbol + . + (identifier) @type)) + +(unqualified_type + (symbol + (symbol) @module + (identifier) @type)) + +(attribute) @attribute + +(namespace_declaration + (symbol) @module) + +(method_declaration + (symbol + (symbol) @type + (identifier) @function)) + +(method_declaration + (symbol + (identifier) @function)) + +(local_declaration + (assignment + (identifier) @variable)) + +(local_function_declaration + (identifier) @function) + +(destructor_declaration + (identifier) @function) + +(creation_method_declaration + (symbol + (symbol) @type + (identifier) @constructor)) + +(creation_method_declaration + (symbol + (identifier) @constructor)) + +(constructor_declaration + (_)? + "construct" @keyword.function) + +(enum_declaration + (symbol) @type) + +(enum_value + (identifier) @constant) + +(errordomain_declaration + (symbol) @type) + +(errorcode + (identifier) @constant) + +(constant_declaration + (identifier) @constant) + +(method_call_expression + (member_access_expression + (identifier) @function)) + +; highlight macros +((method_call_expression + (member_access_expression + (identifier) @function.macro)) + (#match? @function.macro "^assert[A-Za-z_0-9]*|error|info|debug|print|warning|warning_once$")) + +(lambda_expression + (identifier) @variable.parameter) + +(parameter + (identifier) @variable.parameter) + +(property_declaration + (symbol + (identifier) @property)) + +(field_declaration + (identifier) @variable.member) + +[ + (this_access) + (base_access) + (value_access) +] @constant.builtin + +(boolean) @boolean + +(character) @character + +(escape_sequence) @string.escape + +(integer) @number + +(null) @constant.builtin + +(real) @number.float + +(regex) @string.regexp + +(string) @string + +(string_formatter) @string.special + +(template_string) @string + +(template_string_expression) @string.special + +(verbatim_string) @string + +[ + "var" + "void" +] @type.builtin + +(if_directive + expression: (_) @keyword.directive) @keyword + +(elif_directive + expression: (_) @keyword.directive) @keyword + +(else_directive) @keyword + +(endif_directive) @keyword + +[ + "abstract" + "construct" + "continue" + "default" + "errordomain" + "get" + "inline" + "new" + "out" + "override" + "partial" + "ref" + "set" + "signal" + "virtual" + "with" +] @keyword + +[ + "enum" + "class" + "struct" + "interface" + "namespace" +] @keyword.type + +"delegate" @keyword.function + +[ + "async" + "yield" +] @keyword.coroutine + +[ + "const" + "dynamic" + "owned" + "weak" + "unowned" +] @keyword.modifier + +[ + "case" + "else" + "if" + "switch" +] @keyword.conditional + +; specially highlight break statements in switch sections +(switch_section + (break_statement + "break" @keyword.conditional)) + +[ + "extern" + "internal" + "private" + "protected" + "public" + "static" +] @keyword.modifier + +[ + "and" + "as" + "delete" + "in" + "is" + "lock" + "not" + "or" + "sizeof" + "typeof" +] @keyword.operator + +"using" @keyword.import + +(using_directive + (symbol) @module) + +(symbol + "global::" @module) + +(array_creation_expression + "new" @keyword.operator) + +(object_creation_expression + "new" @keyword.operator) + +(argument + "out" @keyword.operator) + +(argument + "ref" @keyword.operator) + +[ + "break" + "continue" + "do" + "for" + "foreach" + "while" +] @keyword.repeat + +[ + "catch" + "finally" + "throw" + "throws" + "try" +] @keyword.exception + +"return" @keyword.return + +[ + "=" + "==" + "+" + "+=" + "-" + "-=" + "++" + "--" + "|" + "|=" + "&" + "&=" + "^" + "^=" + "/" + "/=" + "*" + "*=" + "%" + "%=" + "<<" + "<<=" + ">>" + ">>=" + "." + "?." + "->" + "!" + "!=" + "~" + "??" + "?" + ":" + "<" + "<=" + ">" + ">=" + "||" + "&&" + "=>" +] @operator + +[ + "," + ";" +] @punctuation.delimiter + +[ + "$(" + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket diff --git a/runtime/queries/vala/injections.scm b/runtime/queries/vala/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/vala/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/vento/highlights.scm b/runtime/queries/vento/highlights.scm new file mode 100644 index 000000000..9d35b2f66 --- /dev/null +++ b/runtime/queries/vento/highlights.scm @@ -0,0 +1,13 @@ +(comment) @comment @spell + +(keyword) @keyword + +(tag + [ + "{{" + "{{-" + "}}" + "-}}" + ] @punctuation.special) + +"|>" @operator diff --git a/runtime/queries/vento/injections.scm b/runtime/queries/vento/injections.scm new file mode 100644 index 000000000..66023c7f8 --- /dev/null +++ b/runtime/queries/vento/injections.scm @@ -0,0 +1,9 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((content) @injection.content + (#set! injection.language "html") + (#set! injection.combined)) + +((code) @injection.content + (#set! injection.language "javascript")) diff --git a/runtime/queries/verilog/folds.scm b/runtime/queries/verilog/folds.scm new file mode 100644 index 000000000..ea52476a4 --- /dev/null +++ b/runtime/queries/verilog/folds.scm @@ -0,0 +1,23 @@ +[ + (seq_block) + (function_body_declaration) + (task_body_declaration) + (generate_block) + (always_construct) + (property_declaration) + (checker_declaration) + (class_declaration) + (config_declaration) + (covergroup_declaration) + (clocking_declaration) + (interface_declaration) + (module_declaration) + (package_declaration) + (module_instantiation) + (program_declaration) + (specify_block) + (generate_region) + (package_import_declaration) + (text_macro_definition) + (include_compiler_directive)+ +] @fold diff --git a/runtime/queries/verilog/highlights.scm b/runtime/queries/verilog/highlights.scm new file mode 100644 index 000000000..1e004ef76 --- /dev/null +++ b/runtime/queries/verilog/highlights.scm @@ -0,0 +1,605 @@ +; Keywords +[ + "begin" + "end" + "generate" + "endgenerate" + (module_keyword) + "endmodule" + "program" + "endprogram" + "package" + "endpackage" + "checker" + "endchecker" + "config" + "endconfig" + "pure" + "virtual" + "extends" + "implements" + "super" + (class_item_qualifier) + "parameter" + "localparam" + "defparam" + "assign" + "modport" + "fork" + "join" + "join_none" + "join_any" + "default" + "break" + "tagged" + "extern" + "alias" + "posedge" + "negedge" + "bind" + "expect" + "type" + "void" + "coverpoint" + "cross" + "nettype" + "export" + "force" + "release" + "timeunit" + "timeprecision" + "sequence" + "endsequence" + "property" + "endproperty" + "clocking" + "endclocking" + "covergroup" + "endgroup" + "specify" + "endspecify" + "primitive" + "endprimitive" + "wait" + "wait_order" + "const" + "constraint" + "unique" + "do" + "genvar" + "inside" + "rand" + "continue" + "randc" + "event" + "global" + "ref" + "initial" + "string" + (unique_priority) + (bins_keyword) + (always_keyword) +] @keyword + +[ + "class" + "endclass" + "interface" + "endinterface" + "enum" + "struct" + "union" + "typedef" +] @keyword.type + +[ + "function" + "endfunction" + "task" + "endtask" +] @keyword.function + +"return" @keyword.return + +[ + "for" + "foreach" + "repeat" + "forever" + "while" +] @keyword.repeat + +; for +(loop_generate_construct + (generate_block + [ + "begin" + "end" + ] @keyword.conditional)) + +; foreach +(loop_statement + (statement + (statement_item + (seq_block + [ + "begin" + "end" + ] @keyword.conditional)))) + +; repeat forever while +(loop_statement + (statement_or_null + (statement + (statement_item + (seq_block + [ + "begin" + "end" + ] @keyword.conditional))))) + +[ + "if" + "else" + "iff" + (case_keyword) + "endcase" +] @keyword.conditional + +[ + "=" + "-" + "+" + "/" + "*" + "^" + "&" + "|" + "&&" + "||" + "<=" + "==" + "!=" + "===" + "!==" + "-:" + "<" + ">" + ">=" + "%" + ">>" + "<<" + "|=" + "|=>" + "|->" + ">>>" + "<<<" + "->>" + "->" + "=>" + "*>" + ".*" + (unary_operator) + (inc_or_dec_operator) + (queue_dimension) +] @operator + +"#" @constructor + +[ + ";" + "::" + "," + "." + ":" +] @punctuation.delimiter + +(conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +[ + "[" + "]" + "(" + ")" + "{" + "}" + "'{" +] @punctuation.bracket + +[ + "or" + "and" +] @keyword.operator + +[ + "input" + "output" + "inout" + "signed" + "unsigned" + "assert" + "cover" + "assume" + "disable" + "automatic" + "static" + (dpi_function_import_property) + (dpi_task_import_property) +] @keyword.modifier + +[ + "include" + "import" + "directive_include" +] @keyword.import + +(comment) @comment @spell + +[ + "@" + (cycle_delay_range) + (delay_control) + (cycle_delay) + (attribute_instance) +] @attribute + +(attribute_instance + (attr_spec + (simple_identifier) @property)) + +[ + (integral_number) + (unbased_unsized_literal) + (fixed_point_number) + (unsigned_number) +] @number + +[ + (net_type) + (integer_vector_type) + (time_unit) + (integer_atom_type) + (non_integer_type) +] @type.builtin + +(data_type + (simple_identifier) @type.builtin) + +; variable +(list_of_variable_decl_assignments + (variable_decl_assignment + name: (simple_identifier) @variable)) + +(hierarchical_identifier + (simple_identifier) @variable) + +(tf_port_item + (simple_identifier) @variable) + +port_name: (simple_identifier) @variable + +(port + (simple_identifier) @variable) + +(list_of_port_identifiers + (simple_identifier) @variable) + +(net_lvalue + (simple_identifier) @variable) + +(sequence_port_item + (simple_identifier) @variable) + +(property_port_item + (simple_identifier) @variable) + +(net_decl_assignment + (simple_identifier) @variable) + +(ERROR + (simple_identifier) @variable) + +; variable.member +(hierarchical_identifier + (simple_identifier) + (simple_identifier) @variable.member) + +(select + (simple_identifier) @variable.member) + +(named_port_connection + port_name: (simple_identifier) @variable.member) + +(ordered_port_connection + (expression + (primary + (hierarchical_identifier + (simple_identifier) @variable.member)))) + +(coverage_option + (simple_identifier) @variable.member) + +; variable.builtin +(method_call_body + arguments: (list_of_arguments + (expression) @variable.builtin + (#any-of? @variable.builtin "this"))) + +(implicit_class_handle) @variable.builtin + +; variable.parameter +(named_parameter_assignment + (simple_identifier) @variable.parameter) + +(parameter_declaration + (list_of_param_assignments + (param_assignment + (simple_identifier) @variable.parameter))) + +(local_parameter_declaration + (list_of_param_assignments + (param_assignment + (simple_identifier) @variable.parameter))) + +; function builtin +[ + (simulation_control_task) + (system_tf_identifier) + (severity_system_task) + (randomize_call) + (array_or_queue_method_name) + "new" +] @function.builtin + +; declaration +(task_body_declaration + . + name: (simple_identifier) @function + (simple_identifier)? @label) + +(function_body_declaration + . + name: (simple_identifier) @function + (simple_identifier)? @label) + +(function_body_declaration + . + (data_type_or_void) + name: (simple_identifier) @function + (simple_identifier)? @label) + +(clocking_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(sequence_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(property_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(class_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(interface_class_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(covergroup_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(package_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(checker_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(interface_declaration + . + [ + (simple_identifier) @constructor + (interface_nonansi_header + (simple_identifier) @constructor) + (interface_ansi_header + (simple_identifier) @constructor) + ] + (simple_identifier)? @label) + +(module_declaration + . + [ + (simple_identifier) @constructor + (module_nonansi_header + (simple_identifier) @constructor) + (module_ansi_header + (simple_identifier) @constructor) + ] + (simple_identifier)? @label) + +(program_declaration + . + [ + (simple_identifier) @constructor + (program_nonansi_header + (simple_identifier) @constructor) + (program_ansi_header + (simple_identifier) @constructor) + ] + (simple_identifier)? @label) + +(generate_block + name: (simple_identifier) @label) + +; function.call +(method_call_body + name: (simple_identifier) @function.call) + +(tf_call + (hierarchical_identifier + (simple_identifier) @function.call)) + +; instance +(module_instantiation + instance_type: (simple_identifier) @constructor) + +(name_of_instance + instance_name: (simple_identifier) @module) + +(sequence_instance + (hierarchical_identifier + (simple_identifier) @module)) + +(udp_instantiation + (simple_identifier) @constructor) + +(ansi_port_declaration + (interface_port_header + interface_name: (simple_identifier) @variable + modport_name: (simple_identifier) @variable.member) + port_name: (simple_identifier) @variable) + +; bind +(bind_directive + (bind_target_scope + (simple_identifier) @constructor)) + +(bind_target_instance + (hierarchical_identifier + (simple_identifier) @module)) + +; assertion +(concurrent_assertion_item + (simple_identifier) @label) + +; converge +(cover_point + name: (simple_identifier) @label) + +(cover_cross + name: (simple_identifier) @module) + +(list_of_cross_items + (simple_identifier) @constructor) + +;package +(package_import_item + (simple_identifier) @constructor) + +; label +(seq_block + (simple_identifier) @label) + +(statement + block_name: (simple_identifier) @label) + +; dpi +(dpi_spec_string) @string + +c_name: (c_identifier) @function + +(dpi_import_export + name: (simple_identifier) @function) + +; type def +(class_type + (simple_identifier) @constructor) + +(class_type + (simple_identifier) + (simple_identifier) @type) + +(data_type + (class_scope + (class_type + (simple_identifier) @constructor))) + +(task_prototype + name: (simple_identifier) @function) + +(function_prototype + name: (simple_identifier) @function) + +(type_assignment + name: (simple_identifier) @type.definition) + +(interface_class_type + (simple_identifier) @type.definition) + +(package_scope + (simple_identifier) @constructor) + +(data_declaration + (type_declaration + type_name: (simple_identifier) @type.definition)) + +(net_declaration + (simple_identifier) @type) + +(constraint_declaration + (simple_identifier) @constructor) + +(method_call + (primary + (hierarchical_identifier + (simple_identifier) @constructor))) + +(string_literal + (quoted_string) @string) + +; include +(include_statement + (file_path_spec) @string.special.path) + +; directive +[ + "directive_define" + "directive_default_nettype" + "directive_resetall" + "directive_timescale" + "directive_undef" + "directive_undefineall" + "directive_ifdef" + "directive_ifndef" + "directive_elsif" + "directive_endif" + "directive_else" +] @keyword.directive.define + +(include_compiler_directive + (quoted_string) @string.special.path) + +(include_compiler_directive + (system_lib_string) @string) + +(default_nettype_compiler_directive + (default_nettype_value) @type.builtin) + +(text_macro_definition + (text_macro_name + (simple_identifier) @keyword.directive)) + +(text_macro_usage) @keyword.directive + +(ifdef_condition + (simple_identifier) @keyword.directive) + +(undefine_compiler_directive + (simple_identifier) @keyword.directive) diff --git a/runtime/queries/verilog/injections.scm b/runtime/queries/verilog/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/verilog/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/vhdl/folds.scm b/runtime/queries/vhdl/folds.scm new file mode 100644 index 000000000..9fc6deafe --- /dev/null +++ b/runtime/queries/vhdl/folds.scm @@ -0,0 +1,46 @@ +[ + (block_comment) + (architecture_definition) + (architecture_head) + (concurrent_block) + (configuration_declaration) + (component_instantiation_statement) + (generic_map_aspect) + (port_map_aspect) + (process_statement) + (process_head) + (sequential_block) + (block_configuration) + (block_statement) + (block_head) + (component_declaration) + (component_configuration) + (generic_clause) + (port_clause) + (entity_declaration) + (entity_head) + (entity_body) + (package_declaration) + (package_definition) + (function_specification) + (subprogram_declaration) + (subprogram_definition) + (subprogram_head) + (procedure_specification) + (sequential_block) + (loop_statement) + (if_statement_block) + (if_statement) + (elsif_statement) + (else_statement) + (case_statement) + (case_statement_alternative) + (for_generate_statement) + (if_generate_statement) + (if_generate) + (elsif_generate) + (else_generate) + (case_generate_statement) + (case_generate_alternative) + (type_declaration) +] @fold diff --git a/runtime/queries/vhdl/highlights.scm b/runtime/queries/vhdl/highlights.scm new file mode 100644 index 000000000..681dc2664 --- /dev/null +++ b/runtime/queries/vhdl/highlights.scm @@ -0,0 +1,428 @@ +(line_comment + (comment_content) @spell) @comment + +(block_comment + (comment_content) @spell) @comment.documentation + +(identifier) @variable + +[ + "access" + "after" + "alias" + "architecture" + "array" + ; "assume" + "attribute" + "block" + "body" + "component" + "configuration" + "context" + ; "cover" + "disconnect" + "entity" + ; "fairness" + "file" + "force" + "generate" + "generic" + "group" + "label" + "literal" + "map" + "new" + "package" + "parameter" + "port" + "property" + "range" + "reject" + "release" + ; "restrict" + "sequence" + "transport" + "unaffected" + "view" + ; "vmode" + ; "vpkg" + ; "vprop" + "vunit" +] @keyword + +[ + (ALL) + (OTHERS) + "<>" + (DEFAULT) + (OPEN) +] @constant.builtin + +[ + "is" + "begin" + "end" +] @keyword + +(parameter_specification + "in" @keyword) + +[ + "process" + "wait" + "on" + "until" +] @keyword.coroutine + +(end_process + "end" @keyword.coroutine) + +(timeout_clause + "for" @keyword.coroutine) + +[ + "function" + "procedure" +] @keyword.function + +(subprogram_end + "end" @keyword.function) + +[ + "to" + "downto" + "of" +] @keyword.operator + +[ + "library" + "use" +] @keyword.import + +[ + "subtype" + "type" + "record" + "units" + "constant" + "signal" + "variable" +] @keyword.type + +[ + "protected" + "private" + "pure" + "impure" + "inertial" + "postponed" + ; "strong" + "guarded" + "out" + "inout" + "linkage" + "buffer" + "register" + "bus" + "shared" +] @keyword.modifier + +(mode + "in" @keyword.modifier) + +(force_mode + "in" @keyword.modifier) + +[ + "while" + "loop" + "next" + "exit" +] @keyword.repeat + +(end_loop + "end" @keyword.repeat) + +(for_loop + "for" @keyword.repeat) + +(block_configuration + "for" @keyword) + +(configuration_specification + "for" @keyword) + +(component_configuration + "for" @keyword) + +(end_for + "for" @keyword) + +"return" @keyword.return + +[ + "assert" + "report" + "severity" +] @keyword.debug + +[ + "if" + "then" + "elsif" + "case" +] @keyword.conditional + +(end_if + "end" @keyword.conditional) + +(end_case + "end" @keyword.conditional) + +(when_element + "when" @keyword.conditional) + +(case_generate_alternative + "when" @keyword.conditional) + +(else_statement + "else" @keyword.conditional) + +(else_generate + "else" @keyword.conditional) + +[ + "with" + "select" +] @keyword.conditional.ternary + +(when_expression + "when" @keyword.conditional.ternary) + +(else_expression + "else" @keyword.conditional.ternary) + +(else_waveform + "else" @keyword.conditional.ternary) + +(else_expression_or_unaffected + "else" @keyword.conditional.ternary) + +"null" @constant.builtin + +(user_directive) @keyword.directive + +(protect_directive) @keyword.directive + +(warning_directive) @keyword.directive + +(error_directive) @keyword.directive + +(if_conditional_analysis + "if" @keyword.directive) + +(if_conditional_analysis + "then" @keyword.directive) + +(elsif_conditional_analysis + "elsif" @keyword.directive) + +(else_conditional_analysis + "else" @keyword.directive) + +(end_conditional_analysis + "end" @keyword.directive) + +(end_conditional_analysis + "if" @keyword.directive) + +(directive_body) @keyword.directive + +(directive_constant_builtin) @constant.macro + +(directive_error) @comment.error + +(directive_protect) @keyword.directive + +(directive_warning) @comment.warning + +[ + (condition_conversion) + (relational_operator) + (sign) + (adding_operator) + (exponentiate) + (variable_assignment) + (signal_assignment) + "*" + "/" + ":" + "|" + "=>" +] @operator + +[ + (unary_operator) + (logical_operator) + (shift_operator) + "mod" + "not" + "rem" +] @keyword.operator + +[ + "'" + "," + "." + ";" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "<<" + ">>" +] @punctuation.bracket + +"@" @punctuation.special + +[ + (decimal_integer) + (string_literal_std_logic) +] @number + +(decimal_float) @number.float + +(bit_string_length) @property + +(bit_string_base) @type.builtin + +(bit_string_value) @number + +(based_literal + (based_base) @type.builtin + (based_integer) @number) + +(based_literal + (based_base) @type.builtin + (based_float) @number.float) + +(string_literal) @string @spell + +(character_literal) @character + +(library_constant_std_logic) @constant.builtin + +(library_constant) @constant.builtin + +(library_function) @function.builtin + +(library_constant_boolean) @boolean + +(library_constant_character) @character + +(library_constant_debug) @keyword.debug + +(unit) @keyword.modifier + +(library_constant_unit) @keyword.modifier + +(label) @label + +(generic_map_aspect + "generic" @constructor + "map" @constructor) + +(port_map_aspect + "port" @constructor + "map" @constructor) + +(selection + (identifier) @variable.member) + +(_ + view: (_) @type) + +(_ + type: (_) @type) + +(_ + library: (_) @module) + +(_ + package: (_) @module) + +(_ + entity: (_) @module) + +(_ + component: (_) @module) + +(_ + configuration: (_) @property) + +(_ + architecture: (_) @property) + +(_ + function: (_) @function) + +(_ + procedure: (_) @function.method) + +(_ + attribute: (_) @attribute) + +(_ + constant: (_) @constant) + +(_ + generic: (_) @variable.parameter) + +(_ + view: (name + (_)) @type) + +(_ + type: (name + (_)) @type) + +(_ + entity: (name + (_)) @module) + +(_ + component: (name + (_)) @module) + +(_ + configuration: (name + (_)) @module) + +(library_type) @type.builtin + +[ + (attribute_function) + (attribute_impure_function) + (attribute_mode_view) + (attribute_pure_function) + (attribute_range) + (attribute_signal) + (attribute_subtype) + (attribute_type) + (attribute_value) + (library_attribute) +] @attribute.builtin + +(library_namespace) @module.builtin + +(subtype_declaration + (identifier) @type.definition) + +(type_declaration + (identifier) @type.definition) + +(mode_view_declaration + (identifier) @type.definition) diff --git a/runtime/queries/vhdl/injections.scm b/runtime/queries/vhdl/injections.scm new file mode 100644 index 000000000..5cbc06cb4 --- /dev/null +++ b/runtime/queries/vhdl/injections.scm @@ -0,0 +1,7 @@ +(line_comment + (comment_content) @injection.content + (#set! injection.language "comment")) + +(block_comment + (comment_content) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/vhs/highlights.scm b/runtime/queries/vhs/highlights.scm new file mode 100644 index 000000000..469fdd139 --- /dev/null +++ b/runtime/queries/vhs/highlights.scm @@ -0,0 +1,52 @@ +[ + "Output" + "Backspace" + "Down" + "Enter" + "Escape" + "Left" + "Right" + "Space" + "Tab" + "Up" + "Set" + "Type" + "Sleep" + "Hide" + "Show" +] @keyword + +[ + "Shell" + "FontFamily" + "FontSize" + "Framerate" + "PlaybackSpeed" + "Height" + "LetterSpacing" + "TypingSpeed" + "LineHeight" + "Padding" + "Theme" + "LoopOffset" + "Width" +] @type + +"@" @operator + +(control) @function.macro + +(float) @number.float + +(integer) @number + +(comment) @comment @spell + +[ + (string) + (json) +] @string + +(path) @string.special.path + +(time) @string.special diff --git a/runtime/queries/vhs/injections.scm b/runtime/queries/vhs/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/vhs/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/vim/folds.scm b/runtime/queries/vim/folds.scm new file mode 100644 index 000000000..0a1fb695f --- /dev/null +++ b/runtime/queries/vim/folds.scm @@ -0,0 +1,4 @@ +[ + (if_statement) + (function_definition) +] @fold diff --git a/runtime/queries/vim/highlights.scm b/runtime/queries/vim/highlights.scm new file mode 100644 index 000000000..df7b3cf48 --- /dev/null +++ b/runtime/queries/vim/highlights.scm @@ -0,0 +1,354 @@ +(identifier) @variable + +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + +; Keywords +[ + "if" + "else" + "elseif" + "endif" +] @keyword.conditional + +[ + "try" + "catch" + "finally" + "endtry" + "throw" +] @keyword.exception + +[ + "for" + "endfor" + "in" + "while" + "endwhile" + "break" + "continue" +] @keyword.repeat + +[ + "function" + "endfunction" +] @keyword.function + +; Function related +(function_declaration + name: (_) @function) + +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (scoped_identifier + (identifier) @function.call)) + +(parameters + (identifier) @variable.parameter) + +(default_parameter + (identifier) @variable.parameter) + +[ + (bang) + (spread) +] @punctuation.special + +[ + (no_option) + (inv_option) + (default_option) + (option_name) +] @variable.builtin + +[ + (scope) + "a:" + "$" +] @module + +; Commands and user defined commands +[ + "let" + "unlet" + "const" + "call" + "execute" + "normal" + "set" + "setfiletype" + "setlocal" + "silent" + "echo" + "echon" + "echohl" + "echomsg" + "echoerr" + "autocmd" + "augroup" + "return" + "syntax" + "filetype" + "source" + "lua" + "ruby" + "perl" + "python" + "highlight" + "command" + "delcommand" + "comclear" + "colorscheme" + "scriptencoding" + "startinsert" + "stopinsert" + "global" + "runtime" + "wincmd" + "cnext" + "cprevious" + "cNext" + "vertical" + "leftabove" + "aboveleft" + "rightbelow" + "belowright" + "topleft" + "botright" + (unknown_command_name) + "edit" + "enew" + "find" + "ex" + "visual" + "view" + "eval" + "sign" + "abort" +] @keyword + +(map_statement + cmd: _ @keyword) + +(keycode) @character.special + +(command_name) @function.macro + +; Filetype command +(filetype_statement + [ + "detect" + "plugin" + "indent" + "on" + "off" + ] @keyword) + +; Syntax command +(syntax_statement + (keyword) @string) + +(syntax_statement + [ + "enable" + "on" + "off" + "reset" + "case" + "spell" + "foldlevel" + "iskeyword" + "keyword" + "match" + "cluster" + "region" + "clear" + "include" + ] @keyword) + +(syntax_argument + name: _ @keyword) + +[ + "<buffer>" + "<nowait>" + "<silent>" + "<script>" + "<expr>" + "<unique>" +] @constant.builtin + +(augroup_name) @module + +(au_event) @constant + +(normal_statement + (commands) @constant) + +; Highlight command +(hl_attribute + key: _ @property + val: _ @constant) + +(hl_group) @type + +(highlight_statement + [ + "default" + "link" + "clear" + ] @keyword) + +; Command command +(command) @string + +(command_attribute + name: _ @property + val: (behavior + name: _ @constant + val: (identifier)? @function)?) + +; Edit command +(plus_plus_opt + val: _? @constant) @property + +(plus_cmd + "+" @property) @property + +; Runtime command +(runtime_statement + (where) @keyword.operator) + +; Colorscheme command +(colorscheme_statement + (name) @string) + +; Scriptencoding command +(scriptencoding_statement + (encoding) @string.special) + +; Literals +(string_literal) @string + +(integer_literal) @number + +(float_literal) @number.float + +(comment) @comment @spell + +(line_continuation_comment) @comment @spell + +(pattern) @string.special + +(pattern_multi) @string.regexp + +(filename) @string.special.path + +(heredoc + (body) @string) + +(heredoc + (parameter) @keyword) + +[ + (marker_definition) + (endmarker) +] @label + +(literal_dictionary + (literal_key) @property) + +((scoped_identifier + (scope) @_scope + . + (identifier) @boolean) + (#eq? @_scope "v:") + (#any-of? @boolean "true" "false")) + +; Operators +[ + "||" + "&&" + "&" + "+" + "-" + "*" + "/" + "%" + ".." + "==" + "!=" + ">" + ">=" + "<" + "<=" + "=~" + "!~" + "=" + "^=" + "+=" + "-=" + "*=" + "/=" + "%=" + ".=" + "..=" + "<<" + "=<<" + "->" + (match_case) +] @operator + +[ + "is" + "isnot" +] @keyword.operator + +; Some characters have different meanings based on the context +(unary_operation + "!" @operator) + +(binary_operation + "." @operator) + +; Punctuation +[ + "(" + ")" + "{" + "}" + "[" + "]" + "#{" +] @punctuation.bracket + +(field_expression + "." @punctuation.delimiter) + +[ + "," + ":" +] @punctuation.delimiter + +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +; Options +((set_value) @number + (#lua-match? @number "^[%d]+(%.[%d]+)?$")) + +(inv_option + "!" @operator) + +(set_item + "?" @operator) + +((set_item + option: (option_name) @_option + value: (set_value) @function) + (#any-of? @_option "tagfunc" "tfu" "completefunc" "cfu" "omnifunc" "ofu" "operatorfunc" "opfunc")) diff --git a/runtime/queries/vim/injections.scm b/runtime/queries/vim/injections.scm new file mode 100644 index 000000000..30d11cbb4 --- /dev/null +++ b/runtime/queries/vim/injections.scm @@ -0,0 +1,44 @@ +(lua_statement + (script + (body) @injection.content + (#set! injection.language "lua"))) + +(lua_statement + (chunk) @injection.content + (#set! injection.language "lua")) + +(ruby_statement + (script + (body) @injection.content + (#set! injection.language "ruby"))) + +(ruby_statement + (chunk) @injection.content + (#set! injection.language "ruby")) + +(python_statement + (script + (body) @injection.content + (#set! injection.language "python"))) + +(python_statement + (chunk) @injection.content + (#set! injection.language "python")) + +; If we support perl at some point... +; (perl_statement (script (body) @perl)) +; (perl_statement (chunk) @perl) +(autocmd_statement + (pattern) @injection.content + (#set! injection.language "regex")) + +((set_item + option: (option_name) @_option + value: (set_value) @injection.content) + (#any-of? @_option + "includeexpr" "inex" "printexpr" "pexpr" "formatexpr" "fex" "indentexpr" "inde" "foldtext" "fdt" + "foldexpr" "fde" "diffexpr" "dex" "patchexpr" "pex" "charconvert" "ccv") + (#set! injection.language "vim")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/vim/locals.scm b/runtime/queries/vim/locals.scm new file mode 100644 index 000000000..870647279 --- /dev/null +++ b/runtime/queries/vim/locals.scm @@ -0,0 +1,19 @@ +[ + (script_file) + (function_definition) +] @local.scope + +(function_declaration + name: (identifier) @local.definition.function) + +(function_declaration + parameters: (parameters + (identifier) @local.definition.parameter)) + +(let_statement + [ + (scoped_identifier) + (identifier) + ] @local.definition.var) + +(identifier) @local.reference diff --git a/runtime/queries/vimdoc/highlights.scm b/runtime/queries/vimdoc/highlights.scm new file mode 100644 index 000000000..829a643ae --- /dev/null +++ b/runtime/queries/vimdoc/highlights.scm @@ -0,0 +1,74 @@ +(h1 + (delimiter) @markup.heading.1 + (heading) @markup.heading.1) + +(h2 + (delimiter) @markup.heading.2 + (heading) @markup.heading.2) + +(h3 + (heading) @markup.heading.3) + +(column_heading + (heading) @markup.heading.4) + +(column_heading + (delimiter) @markup.heading.4 + (#set! conceal "")) + +(tag + "*" @label + (#set! conceal "")) + +(tag + text: (_) @label) + +(taglink + "|" @markup.link + (#set! conceal "")) + +(taglink + text: (_) @markup.link) + +(optionlink + text: (_) @markup.link) + +(codespan + "`" @markup.raw + (#set! conceal "")) + +(codespan + text: (_) @markup.raw) + +((codeblock) @markup.raw.block + (#set! priority 90)) + +(codeblock + ">" @markup.raw + (#set! conceal "")) + +(codeblock + (language) @label + (#set! conceal "")) + +(block + "<" @markup.raw + (#set! conceal "")) + +(argument) @variable.parameter + +(keycode) @string.special + +((url) @string.special.url + (#set! @string.special.url url @string.special.url)) + +(modeline) @keyword.directive + +((note) @comment.note + (#any-of? @comment.note "Note:" "NOTE:" "Notes:")) + +((note) @comment.warning + (#any-of? @comment.warning "Warning:" "WARNING:")) + +((note) @comment.error + (#any-of? @comment.error "Deprecated:" "DEPRECATED:")) diff --git a/runtime/queries/vimdoc/injections.scm b/runtime/queries/vimdoc/injections.scm new file mode 100644 index 000000000..3b8fbf0f3 --- /dev/null +++ b/runtime/queries/vimdoc/injections.scm @@ -0,0 +1,4 @@ +((codeblock + (language) @injection.language + (code) @injection.content) + (#set! injection.include-children)) diff --git a/runtime/queries/vrl/folds.scm b/runtime/queries/vrl/folds.scm new file mode 100644 index 000000000..6c6d587de --- /dev/null +++ b/runtime/queries/vrl/folds.scm @@ -0,0 +1,6 @@ +[ + (block) + (object) + (array) + (arguments) +] @fold diff --git a/runtime/queries/vrl/highlights.scm b/runtime/queries/vrl/highlights.scm new file mode 100644 index 000000000..f74d6dd55 --- /dev/null +++ b/runtime/queries/vrl/highlights.scm @@ -0,0 +1,108 @@ +(comment) @comment @spell + +(null) @constant.builtin + +(timestamp) @constant + +(closure_variables + (ident) @variable.parameter) + +(integer) @number + +(float) @number.float + +[ + (string) + (raw_string) +] @string + +[ + (raw_string_escape_sequence) + (escape_sequence) + (regex_escape_sequence) +] @string.escape + +(string_template + "{{" @punctuation.special + (_) + "}}" @punctuation.special) + +(regex) @string.regexp + +(boolean) @boolean + +(ident) @variable + +(noop) @variable.builtin + +(function_call + (ident) @function.call) + +; VRL queries +(query + [ + (event) + (metadata) + ] @variable.builtin) + +(query + (path + [ + (field) @variable + (string) @string + (index) @number + "." @punctuation.delimiter + ])) + +"return" @keyword.return + +"abort" @keyword.exception + +[ + "if" + "else" +] @keyword.conditional + +[ + "=" + "==" + "!=" + "|=" + ">" + ">=" + "<" + "<=" + "+" + "-" + "*" + "/" + "&&" + "||" + "??" + "|" + "!" +] @operator + +[ + "->" + ":" + ";" + "," +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(closure_variables + "|" @punctuation.bracket) + +(function_call + (ident) @keyword.exception + "!" + (#any-of? @keyword.exception "assert" "assert_eq")) diff --git a/runtime/queries/vrl/indents.scm b/runtime/queries/vrl/indents.scm new file mode 100644 index 000000000..1fc1249e0 --- /dev/null +++ b/runtime/queries/vrl/indents.scm @@ -0,0 +1,24 @@ +[ + (block) + (object) + (array) + (arguments) +] @indent.begin + +(block + "}" @indent.end) + +(object + "}" @indent.end) + +(array + "]" @indent.end) + +(arguments + ")" @indent.end) + +[ + ")" + "]" + "}" +] @indent.branch diff --git a/runtime/queries/vrl/injections.scm b/runtime/queries/vrl/injections.scm new file mode 100644 index 000000000..5aaf9bcd2 --- /dev/null +++ b/runtime/queries/vrl/injections.scm @@ -0,0 +1,6 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((regex) @injection.content + (#offset! @injection.content 0 2 0 -1) + (#set! injection.language "regex")) diff --git a/runtime/queries/vrl/locals.scm b/runtime/queries/vrl/locals.scm new file mode 100644 index 000000000..786da98c5 --- /dev/null +++ b/runtime/queries/vrl/locals.scm @@ -0,0 +1,16 @@ +(closure_variables + (ident) @local.definition.parameter) + +[ + (ident) + (metadata) +] @local.reference + +(query + (event) @local.reference) + +[ + (block) + (closure) + (if_statement) +] @local.scope diff --git a/runtime/queries/vue/folds.scm b/runtime/queries/vue/folds.scm new file mode 100644 index 000000000..314256e4e --- /dev/null +++ b/runtime/queries/vue/folds.scm @@ -0,0 +1,6 @@ +[ + (element) + (template_element) + (script_element) + (style_element) +] @fold diff --git a/runtime/queries/vue/highlights.scm b/runtime/queries/vue/highlights.scm new file mode 100644 index 000000000..64195c346 --- /dev/null +++ b/runtime/queries/vue/highlights.scm @@ -0,0 +1,43 @@ +; inherits: html_tags + +[ + "[" + "]" +] @punctuation.bracket + +(interpolation) @punctuation.special + +(interpolation + (raw_text) @none) + +(dynamic_directive_inner_value) @variable + +(directive_name) @tag.attribute + +; Accessing a component object's field +(":" + . + (directive_value) @variable.member) + +("." + . + (directive_value) @property) + +; @click is like onclick for HTML +("@" + . + (directive_value) @function.method) + +; Used in v-slot, declaring position the element should be put in +("#" + . + (directive_value) @variable) + +(directive_attribute + (quoted_attribute_value) @punctuation.special) + +(directive_attribute + (quoted_attribute_value + (attribute_value) @none)) + +(directive_modifier) @function.method diff --git a/runtime/queries/vue/indents.scm b/runtime/queries/vue/indents.scm new file mode 100644 index 000000000..6b377f323 --- /dev/null +++ b/runtime/queries/vue/indents.scm @@ -0,0 +1,7 @@ +; inherits: html_tags + +(template_element) @indent.begin + +(template_element + (end_tag + ">" @indent.end) @indent.branch) diff --git a/runtime/queries/vue/injections.scm b/runtime/queries/vue/injections.scm new file mode 100644 index 000000000..586964011 --- /dev/null +++ b/runtime/queries/vue/injections.scm @@ -0,0 +1,77 @@ +; inherits html_tags +; <script lang="css"> +((style_element + (start_tag + (attribute + (attribute_name) @_lang + (quoted_attribute_value + (attribute_value) @injection.language))) + (raw_text) @injection.content) + (#eq? @_lang "lang") + (#any-of? @injection.language "css" "scss")) + +; TODO: When nvim-treesitter has postcss and less parsers, use @injection.language and @injection.content instead +; <script lang="scss"> +(style_element + (start_tag + (attribute + (attribute_name) @_lang + (quoted_attribute_value + (attribute_value) @_scss))) + (raw_text) @injection.content + (#eq? @_lang "lang") + (#any-of? @_scss "less" "postcss" "sass") + (#set! injection.language "scss")) + +; <script lang="js"> +((script_element + (start_tag + (attribute + (attribute_name) @_lang + (quoted_attribute_value + (attribute_value) @_js))) + (raw_text) @injection.content) + (#eq? @_lang "lang") + (#eq? @_js "js") + (#set! injection.language "javascript")) + +; <script lang="ts"> +((script_element + (start_tag + (attribute + (attribute_name) @_lang + (quoted_attribute_value + (attribute_value) @_ts))) + (raw_text) @injection.content) + (#eq? @_lang "lang") + (#eq? @_ts "ts") + (#set! injection.language "typescript")) + +; <script lang="tsx"> +; <script lang="jsx"> +(script_element + (start_tag + (attribute + (attribute_name) @_attr + (quoted_attribute_value + (attribute_value) @injection.language))) + (#eq? @_attr "lang") + (#any-of? @injection.language "tsx" "jsx") + (raw_text) @injection.content) + +((interpolation + (raw_text) @injection.content) + (#set! injection.language "typescript")) + +(directive_attribute + (quoted_attribute_value + (attribute_value) @injection.content + (#set! injection.language "typescript"))) + +(template_element + (start_tag + (attribute + (quoted_attribute_value + (attribute_value) @injection.language))) + (text) @injection.content + (#eq? @injection.language "pug")) diff --git a/runtime/queries/wgsl/folds.scm b/runtime/queries/wgsl/folds.scm new file mode 100644 index 000000000..60b526c53 --- /dev/null +++ b/runtime/queries/wgsl/folds.scm @@ -0,0 +1,10 @@ +[ + (struct_declaration) + (function_declaration) + (if_statement) + (switch_statement) + (switch_body) + (loop_statement) + (for_statement) + (while_statement) +] @fold diff --git a/runtime/queries/wgsl/highlights.scm b/runtime/queries/wgsl/highlights.scm new file mode 100644 index 000000000..854ffe921 --- /dev/null +++ b/runtime/queries/wgsl/highlights.scm @@ -0,0 +1,127 @@ +(identifier) @variable + +(int_literal) @number + +(float_literal) @number.float + +(bool_literal) @boolean + +(type_declaration) @type + +(function_declaration + (identifier) @function) + +(parameter + (variable_identifier_declaration + (identifier) @variable.parameter)) + +(struct_declaration + (identifier) @type) + +(struct_declaration + (struct_member + (variable_identifier_declaration + (identifier) @variable.member))) + +(type_constructor_or_function_call_expression + (type_declaration) @function.call) + +[ + "bitcast" + "discard" + "enable" + "fallthrough" + "let" + "type" + "var" + "override" + (texel_format) +] @keyword + +"struct" @keyword.type + +[ + "private" + "storage" + "uniform" + "workgroup" +] @keyword.modifier + +[ + "read" + "read_write" + "write" +] @keyword.modifier + +"fn" @keyword.function + +"return" @keyword.return + +[ + "," + "." + ":" + ";" + "->" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "loop" + "for" + "while" + "break" + "continue" + "continuing" +] @keyword.repeat + +[ + "if" + "else" + "switch" + "case" + "default" +] @keyword.conditional + +[ + "&" + "&&" + "/" + "!" + "=" + "==" + "!=" + ">" + ">=" + ">>" + "<" + "<=" + "<<" + "%" + "-" + "+" + "|" + "||" + "*" + "~" + "^" + "@" + "++" + "--" +] @operator + +(attribute + (identifier) @attribute) + +[ + (line_comment) + (block_comment) +] @comment @spell diff --git a/runtime/queries/wgsl/indents.scm b/runtime/queries/wgsl/indents.scm new file mode 100644 index 000000000..579c665bc --- /dev/null +++ b/runtime/queries/wgsl/indents.scm @@ -0,0 +1,43 @@ +[ + (compound_statement) + (loop_statement) + (struct_declaration) + (type_constructor_or_function_call_expression) +] @indent.begin + +((parameter_list) @indent.begin + (#set! indent.immediate) + (#set! indent.start_at_same_line)) + +(function_declaration + "(" @indent.begin + (#set! indent.immediate)) + +(ERROR + "fn" + (identifier) + "(" @indent.begin + (#set! indent.immediate)) + +(compound_statement + "}" @indent.end) + +(loop_statement + "}" @indent.end) + +(function_declaration + ")" @indent.end) + +(struct_declaration + "}" @indent.end) + +[ + "else" + ")" + "}" +] @indent.branch + +[ + (line_comment) + (block_comment) +] @indent.auto diff --git a/runtime/queries/wgsl/injections.scm b/runtime/queries/wgsl/injections.scm new file mode 100644 index 000000000..3cd6aac8e --- /dev/null +++ b/runtime/queries/wgsl/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/wgsl_bevy/folds.scm b/runtime/queries/wgsl_bevy/folds.scm new file mode 100644 index 000000000..bb371406d --- /dev/null +++ b/runtime/queries/wgsl_bevy/folds.scm @@ -0,0 +1,2 @@ +; inherits wgsl +(preproc_ifdef) @fold diff --git a/runtime/queries/wgsl_bevy/highlights.scm b/runtime/queries/wgsl_bevy/highlights.scm new file mode 100644 index 000000000..2a6a9740c --- /dev/null +++ b/runtime/queries/wgsl_bevy/highlights.scm @@ -0,0 +1,44 @@ +; inherits wgsl +[ + "virtual" + "override" +] @keyword + +[ + "#import" + "#define_import_path" + "as" +] @keyword.import + +"::" @punctuation.delimiter + +(function_declaration + (import_path + (identifier) @function .)) + +(import_path + (identifier) @module + (identifier)) + +(struct_declaration + (preproc_ifdef + (struct_member + (variable_identifier_declaration + (identifier) @variable.member)))) + +(struct_declaration + (preproc_ifdef + (preproc_else + (struct_member + (variable_identifier_declaration + (identifier) @variable.member))))) + +(preproc_ifdef + name: (identifier) @constant.macro) + +[ + "#ifdef" + "#ifndef" + "#endif" + "#else" +] @keyword.directive diff --git a/runtime/queries/wgsl_bevy/indents.scm b/runtime/queries/wgsl_bevy/indents.scm new file mode 100644 index 000000000..381321877 --- /dev/null +++ b/runtime/queries/wgsl_bevy/indents.scm @@ -0,0 +1,7 @@ +; inherits wgsl +[ + "#ifdef" + "#ifndef" + "#else" + "#endif" +] @indent.zero diff --git a/runtime/queries/wing/folds.scm b/runtime/queries/wing/folds.scm new file mode 100644 index 000000000..0acd8adeb --- /dev/null +++ b/runtime/queries/wing/folds.scm @@ -0,0 +1,17 @@ +[ + (class_definition) + (class_implementation) + (interface_definition) + (interface_implementation) + (for_in_loop) + (while_statement) + (if_statement) + (if_let_statement) + (else_if_block) + (struct_definition) + (enum_definition) + (try_catch_statement) + (method_definition) + (import_statement)+ + (initializer) +] @fold diff --git a/runtime/queries/wing/highlights.scm b/runtime/queries/wing/highlights.scm new file mode 100644 index 000000000..31e914f07 --- /dev/null +++ b/runtime/queries/wing/highlights.scm @@ -0,0 +1,179 @@ +(identifier) @variable + +(reference_identifier) @variable + +(member_identifier) @variable.member + +; Classes +(custom_type) @type + +(class_field + name: (identifier) @property) + +(struct_field + name: (identifier) @property) + +(class_definition + name: (identifier) @type) + +(struct_definition + name: (identifier) @type) + +(interface_definition + name: (identifier) @type) + +(method_definition + name: (identifier) @function.method) + +(json_literal_member + (identifier) @property) + +; Functions +(keyword_argument_key) @variable.parameter + +(parameter_definition + name: (identifier) @variable.parameter) + +(variadic) @variable.parameter.builtin + +(call + caller: (reference + (nested_identifier + property: (member_identifier) @function.method.call))) + +(call + caller: (reference + (reference_identifier) @function.method.call)) + +; Primitives +(number) @number + +(duration) @constant + +(string) @string + +(bool) @boolean + +[ + (builtin_type) + "MutSet" + "MutMap" + "MutArray" + "Json" + "Set" + "Map" + "Array" + "MutJson" +] @type.builtin + +(json_container_type) @type.builtin + +; Special +(comment) @comment @spell + +[ + "-" + "-=" + "+" + "+=" + "*" + "**" + "/" + "%" + "<" + "<=" + "=" + "==" + "!" + "!=" + ">" + ">=" + "&&" + "??" + "||" + "?" +] @operator + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +(mutable_container_type + [ + "<" + ">" + ] @punctuation.bracket) + +(immutable_container_type + [ + "<" + ">" + ] @punctuation.bracket) + +[ + ";" + "." + "," + ":" + "=>" +] @punctuation.delimiter + +[ + "as" + "let" + "new" + (phase_specifier) + "impl" + "test" +] @keyword + +"bring" @keyword.import + +[ + "class" + "struct" + "interface" +] @keyword.type + +[ + "for" + "in" +] @keyword.repeat + +[ + "if" + "else" +] @keyword.conditional + +[ + "pub" + "protected" + "internal" + "extern" + (static) +] @keyword.modifier + +"return" @keyword.return + +(import_statement + module_name: (identifier) @module) + +(import_statement + alias: (identifier) @module) + +(call + (reference + (nested_identifier + object: (reference) @_ref + property: (member_identifier) @_ident)) + (argument_list + (positional_argument + (string) @string.regexp)) + (#eq? @_ref "regex") + (#eq? @_ident "compile") + (#offset! @string.regexp 0 1 0 -1)) diff --git a/runtime/queries/wing/injections.scm b/runtime/queries/wing/injections.scm new file mode 100644 index 000000000..bd3fdaec5 --- /dev/null +++ b/runtime/queries/wing/injections.scm @@ -0,0 +1,15 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +(call + (reference + (nested_identifier + object: (reference) @_ref + property: (member_identifier) @_ident)) + (argument_list + (positional_argument + (string) @injection.content)) + (#eq? @_ref "regex") + (#eq? @_ident "compile") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "regex")) diff --git a/runtime/queries/wing/locals.scm b/runtime/queries/wing/locals.scm new file mode 100644 index 000000000..9a860c5f2 --- /dev/null +++ b/runtime/queries/wing/locals.scm @@ -0,0 +1,6 @@ +(block) @local.scope + +(variable_definition_statement + name: (identifier) @local.definition) + +; TODO: Missing "@local.reference" usage tuned for each relevant identifier location diff --git a/runtime/queries/wit/folds.scm b/runtime/queries/wit/folds.scm new file mode 100644 index 000000000..7f84ddd2e --- /dev/null +++ b/runtime/queries/wit/folds.scm @@ -0,0 +1,12 @@ +[ + (world_items) + (world_body) + (interface_items) + (interface_body) +] @fold + +(world_items + [ + (use_item) + (import_item) + ])+ @fold diff --git a/runtime/queries/wit/highlights.scm b/runtime/queries/wit/highlights.scm new file mode 100644 index 000000000..1f4b01cce --- /dev/null +++ b/runtime/queries/wit/highlights.scm @@ -0,0 +1,166 @@ +(comment) @comment @spell + +(ty + (id)) @type + +(package_decl + (id) @module) + +(valid_semver) @string.special + +(world_item + name: (id) @module) + +(interface_item + name: (id) @module) + +(import_item + name: (id) @module + (extern_type + (interface_body))) + +(import_item + name: (id) @function + (extern_type + (func_type))) + +(export_item + name: (id) @module + (extern_type + (interface_body))) + +(export_item + name: (id) @function + (extern_type + (func_type))) + +(type_item + alias: (id) @type.definition) + +(func_item + name: (id) @function.method) + +(handle + (id) @type) + +(named_type + name: (id) @variable.parameter) + +(record_item + name: (id) @type) + +(record_field + name: (id) @variable.member) + +(flags_items + name: (id) @type) + +(flags_body + (id) @variable.member) + +(variant_items + name: (id) @type) + +(variant_case + name: (id) @constant) + +(enum_items + name: (id) @type) + +(enum_case + name: (id) @constant) + +(resource_item + name: (id) @type) + +(resource_method + (id) @function.method) + +(resource_method + "constructor" @constructor) + +(toplevel_use_item + "use" @keyword.import) + +(toplevel_use_item + alias: (id) @module) + +(use_item + "use" @keyword.import) + +(use_path + (id) @module) + +(use_names_item + (id) @module) + +"func" @keyword.function + +[ + "type" + "interface" + "world" + "package" + "resource" + "record" + "enum" + "flags" + "variant" +] @keyword.type + +"static" @keyword.modifier + +[ + "include" + "import" + "export" + "as" +] @keyword.import + +[ + "u8" + "u16" + "u32" + "u64" + "s8" + "s16" + "s32" + "s64" + "f32" + "f64" + "float32" ; deprecated + "float64" ; deprecated + "char" + "bool" + "string" + "tuple" + "list" + "option" + "result" + "borrow" +] @type.builtin + +[ + "@" + "_" +] @punctuation.special + +[ + "/" + ";" + ":" + "," + "." + "->" +] @punctuation.delimiter + +[ + "{" + "}" + "(" + ")" + ">" + "<" +] @punctuation.bracket + +"=" @operator diff --git a/runtime/queries/wit/injections.scm b/runtime/queries/wit/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/wit/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/xcompose/highlights.scm b/runtime/queries/xcompose/highlights.scm new file mode 100644 index 000000000..2afab42f9 --- /dev/null +++ b/runtime/queries/xcompose/highlights.scm @@ -0,0 +1,38 @@ +(keysym) @constant + +((keysym) @constant.builtin + (#eq? @constant.builtin "Multi_key")) + +(text) @string + +"include" @keyword.import + +[ + (octal) + (hex) +] @number + +[ + (modifier) + "None" +] @keyword.modifier + +[ + "%L" + "%H" + "%S" +] @string.special + +[ + "!" + "~" +] @operator + +[ + ":" + "<" + ">" + "\"" +] @punctuation.delimiter + +(comment) @comment @spell diff --git a/runtime/queries/xcompose/injections.scm b/runtime/queries/xcompose/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/xcompose/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/xcompose/locals.scm b/runtime/queries/xcompose/locals.scm new file mode 100644 index 000000000..9b6f359bf --- /dev/null +++ b/runtime/queries/xcompose/locals.scm @@ -0,0 +1,5 @@ +(result + (keysym) @local.definition) + +(event + (keysym) @local.reference) diff --git a/runtime/queries/xml/folds.scm b/runtime/queries/xml/folds.scm new file mode 100644 index 000000000..494e8c00a --- /dev/null +++ b/runtime/queries/xml/folds.scm @@ -0,0 +1,5 @@ +[ + (element) + (doctypedecl) + (Comment) +] @fold diff --git a/runtime/queries/xml/highlights.scm b/runtime/queries/xml/highlights.scm new file mode 100644 index 000000000..85e6e9bb4 --- /dev/null +++ b/runtime/queries/xml/highlights.scm @@ -0,0 +1,199 @@ +; XML declaration +(XMLDecl + "xml" @keyword.directive) + +(XMLDecl + [ + "version" + "encoding" + "standalone" + ] @tag.attribute) + +(XMLDecl + (EncName) @string.special) + +(XMLDecl + (VersionNum) @number) + +(XMLDecl + [ + "yes" + "no" + ] @boolean) + +; Processing instructions +(PI) @keyword.directive + +; Element declaration +(elementdecl + "ELEMENT" @keyword.directive.define + (Name) @tag) + +(contentspec + (_ + (Name) @tag.attribute)) + +"#PCDATA" @type.builtin + +[ + "EMPTY" + "ANY" +] @keyword.modifier + +[ + "*" + "?" + "+" +] @character.special + +; Entity declaration +(GEDecl + "ENTITY" @keyword.directive.define + (Name) @constant) + +(GEDecl + (EntityValue) @string) + +(NDataDecl + "NDATA" @keyword + (Name) @label) + +; Parsed entity declaration +(PEDecl + "ENTITY" @keyword.directive.define + "%" @operator + (Name) @function.macro) + +(PEDecl + (EntityValue) @string) + +; Notation declaration +(NotationDecl + "NOTATION" @keyword.directive + (Name) @label) + +; Attlist declaration +(AttlistDecl + "ATTLIST" @keyword.directive.define + (Name) @tag) + +(AttDef + (Name) @tag.attribute) + +(AttDef + (Enumeration + (Nmtoken) @string)) + +[ + (StringType) + (TokenizedType) +] @type.builtin + +(NotationType + "NOTATION" @type.builtin) + +[ + "#REQUIRED" + "#IMPLIED" + "#FIXED" +] @attribute + +; Entities +(EntityRef) @constant + +((EntityRef) @constant.builtin + (#any-of? @constant.builtin "&" "<" ">" """ "'")) + +(CharRef) @character + +(PEReference) @function.macro + +; External references +[ + "PUBLIC" + "SYSTEM" +] @keyword + +(PubidLiteral) @string.special + +(SystemLiteral + (URI) @string.special.url) + +; Processing instructions +(XmlModelPI + "xml-model" @keyword.directive) + +(StyleSheetPI + "xml-stylesheet" @keyword.directive) + +(PseudoAtt + (Name) @tag.attribute) + +(PseudoAtt + (PseudoAttValue) @string) + +; Doctype declaration +(doctypedecl + "DOCTYPE" @keyword.directive.define) + +(doctypedecl + (Name) @type.definition) + +; Tags +(STag + (Name) @tag) + +(ETag + (Name) @tag) + +(EmptyElemTag + (Name) @tag) + +; Attributes +(Attribute + (Name) @tag.attribute) + +(Attribute + (AttValue) @string) + +; Delimiters & punctuation +[ + "<?" + "?>" + "<" + ">" + "</" + "/>" + "<!" + "]]>" +] @tag.delimiter + +[ + "(" + ")" + "[" + "]" +] @punctuation.bracket + +[ + "\"" + "'" +] @punctuation.delimiter + +[ + "," + "|" + "=" +] @operator + +; Text +(CharData) @none @spell + +((CDSect + (CDStart) @module + (CData) @markup.raw + "]]>" @module) + (#set! priority 105)) + +; Misc +(Comment) @comment @spell diff --git a/runtime/queries/xml/indents.scm b/runtime/queries/xml/indents.scm new file mode 100644 index 000000000..803c6e8a1 --- /dev/null +++ b/runtime/queries/xml/indents.scm @@ -0,0 +1,16 @@ +(element) @indent.begin + +[ + (Attribute) + (AttlistDecl) + (contentspec) +] @indent.align + +(ETag) @indent.branch + +(doctypedecl) @indent.ignore + +[ + (Comment) + (ERROR) +] @indent.auto diff --git a/runtime/queries/xml/injections.scm b/runtime/queries/xml/injections.scm new file mode 100644 index 000000000..02e99f02d --- /dev/null +++ b/runtime/queries/xml/injections.scm @@ -0,0 +1,32 @@ +((Comment) @injection.content + (#set! injection.language "comment")) + +; SVG style +((element + (STag + (Name) @_name) + (content) @injection.content) + (#eq? @_name "style") + (#set! injection.combined) + (#set! injection.include-children) + (#set! injection.language "css")) + +; SVG script +((element + (STag + (Name) @_name) + (content) @injection.content) + (#eq? @_name "script") + (#set! injection.combined) + (#set! injection.include-children) + (#set! injection.language "javascript")) + +; phpMyAdmin dump +((element + (STag + (Name) @_name) + (content) @injection.content) + (#eq? @_name "pma:table") + (#set! injection.combined) + (#set! injection.include-children) + (#set! injection.language "sql")) diff --git a/runtime/queries/xml/locals.scm b/runtime/queries/xml/locals.scm new file mode 100644 index 000000000..2806b530c --- /dev/null +++ b/runtime/queries/xml/locals.scm @@ -0,0 +1,35 @@ +; tags +(elementdecl + (Name) @local.definition.type) + +(elementdecl + (contentspec + (children + (Name) @local.reference))) + +(AttlistDecl + . + (Name) @local.reference) + +(STag + (Name) @local.reference) + +(ETag + (Name) @local.reference) + +(EmptyElemTag + (Name) @local.reference) + +; attributes +(AttDef + (Name) @local.definition.field) + +(Attribute + (Name) @local.reference) + +; entities +(GEDecl + (Name) @local.definition.macro) + +(EntityRef + (Name) @local.reference) diff --git a/runtime/queries/xresources/folds.scm b/runtime/queries/xresources/folds.scm new file mode 100644 index 000000000..9cc7d5cec --- /dev/null +++ b/runtime/queries/xresources/folds.scm @@ -0,0 +1,10 @@ +[ + (elif_directive) + (elifdef_directive) + (else_directive) + (if_directive) + (ifdef_directive) + (preprocessor_comment) + (comment)+ + (include_directive)+ +] @fold diff --git a/runtime/queries/xresources/highlights.scm b/runtime/queries/xresources/highlights.scm new file mode 100644 index 000000000..4bf394788 --- /dev/null +++ b/runtime/queries/xresources/highlights.scm @@ -0,0 +1,75 @@ +[ + (comment) + (preprocessor_comment) +] @comment @spell + +"#include" @keyword.import + +[ + "#define" + "#undef" +] @keyword.directive.define + +[ + "#if" + "#ifdef" + "#ifndef" + "#elif" + "#elifdef" + "#elifndef" + "#else" + "#endif" + (directive) +] @keyword.directive + +(identifier) @variable + +(define_directive + name: (identifier) @constant.macro) + +(define_function_directive + name: (identifier) @function.macro) + +(parameters + (identifier) @variable.parameter) + +"..." @variable.parameter.builtin + +(undef_directive + name: (identifier) @constant.macro) + +(ifdef_directive + condition: (identifier) @constant.macro) + +(elifdef_directive + condition: (identifier) @constant.macro) + +(expansion) @markup.raw + +(component) @variable.member + +(components + (component) @property .) + +[ + (string) + (resource_value) +] @string + +(escape_sequence) @string.escape + +[ + "*" + (any_component) +] @character.special + +[ + "." + "," + ":" +] @punctuation.delimiter + +[ + "(" + ")" +] @punctuation.bracket diff --git a/runtime/queries/xresources/injections.scm b/runtime/queries/xresources/injections.scm new file mode 100644 index 000000000..1f12a2148 --- /dev/null +++ b/runtime/queries/xresources/injections.scm @@ -0,0 +1,5 @@ +([ + (comment) + (preprocessor_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/xresources/locals.scm b/runtime/queries/xresources/locals.scm new file mode 100644 index 000000000..a7f932418 --- /dev/null +++ b/runtime/queries/xresources/locals.scm @@ -0,0 +1,12 @@ +(define_directive + name: (identifier) @local.definition.macro) + +(define_function_directive + name: (identifier) @local.definition.macro) + +(parameters + (identifier) @local.definition.parameter) + +(identifier) @local.reference + +(resources) @local.scope diff --git a/runtime/queries/yaml/folds.scm b/runtime/queries/yaml/folds.scm new file mode 100644 index 000000000..c426afb87 --- /dev/null +++ b/runtime/queries/yaml/folds.scm @@ -0,0 +1,4 @@ +[ + (block_mapping_pair) + (block_sequence_item) +] @fold diff --git a/runtime/queries/yaml/highlights.scm b/runtime/queries/yaml/highlights.scm new file mode 100644 index 000000000..9aed59ce4 --- /dev/null +++ b/runtime/queries/yaml/highlights.scm @@ -0,0 +1,99 @@ +(boolean_scalar) @boolean + +(null_scalar) @constant.builtin + +(double_quote_scalar) @string + +(single_quote_scalar) @string + +((block_scalar) @string + (#set! priority 99)) + +(string_scalar) @string + +(escape_sequence) @string.escape + +(integer_scalar) @number + +(float_scalar) @number + +(comment) @comment @spell + +[ + (anchor_name) + (alias_name) +] @label + +(tag) @type + +[ + (yaml_directive) + (tag_directive) + (reserved_directive) +] @keyword.directive + +(block_mapping_pair + key: (flow_node + [ + (double_quote_scalar) + (single_quote_scalar) + ] @property)) + +(block_mapping_pair + key: (flow_node + (plain_scalar + (string_scalar) @property))) + +(flow_mapping + (_ + key: (flow_node + [ + (double_quote_scalar) + (single_quote_scalar) + ] @property))) + +(flow_mapping + (_ + key: (flow_node + (plain_scalar + (string_scalar) @property)))) + +[ + "," + "-" + ":" + ">" + "?" + "|" +] @punctuation.delimiter + +[ + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "*" + "&" + "---" + "..." +] @punctuation.special + +; help deal with for yaml's norway problem https://www.bram.us/2022/01/11/yaml-the-norway-problem/ +; only using `true` and `false`, since Treesitter parser targets YAML spec 1.2 https://github.com/nvim-treesitter/nvim-treesitter/pull/7512#issuecomment-2565397302 +(block_mapping_pair + value: (block_node + (block_sequence + (block_sequence_item + (flow_node + (plain_scalar + (string_scalar) @boolean + (#any-of? @boolean "TRUE" "FALSE" "True" "False"))))))) + +(block_mapping_pair + value: (flow_node + (plain_scalar + (string_scalar) @boolean + (#any-of? @boolean "TRUE" "FALSE" "True" "False")))) diff --git a/runtime/queries/yaml/indents.scm b/runtime/queries/yaml/indents.scm new file mode 100644 index 000000000..f7146d316 --- /dev/null +++ b/runtime/queries/yaml/indents.scm @@ -0,0 +1,7 @@ +[ + (block_mapping_pair + value: (block_node)) + (block_sequence_item) +] @indent.begin + +(ERROR) @indent.auto diff --git a/runtime/queries/yaml/injections.scm b/runtime/queries/yaml/injections.scm new file mode 100644 index 000000000..143af1924 --- /dev/null +++ b/runtime/queries/yaml/injections.scm @@ -0,0 +1,81 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; Github actions ("run") / Gitlab CI ("scripts") +; Taskfile scripts ("cmds", "cmd", "sh") +(block_mapping_pair + key: (flow_node) @_run + (#any-of? @_run "run" "script" "before_script" "after_script" "cmds" "cmd" "sh") + value: (flow_node + (plain_scalar + (string_scalar) @injection.content) + (#set! injection.language "bash"))) + +(block_mapping_pair + key: (flow_node) @_run + (#any-of? @_run "run" "script" "before_script" "after_script" "cmds" "cmd" "sh") + value: (block_node + (block_scalar) @injection.content + (#set! injection.language "bash") + (#offset! @injection.content 0 1 0 0))) + +(block_mapping_pair + key: (flow_node) @_run + (#any-of? @_run "run" "script" "before_script" "after_script" "cmds" "sh") + value: (block_node + (block_sequence + (block_sequence_item + (flow_node + (plain_scalar + (string_scalar) @injection.content)) + (#set! injection.language "bash"))))) + +(block_mapping_pair + key: (flow_node) @_run + (#any-of? @_run "script" "before_script" "after_script" "cmds" "sh") + value: (block_node + (block_sequence + (block_sequence_item + (block_node + (block_scalar) @injection.content + (#set! injection.language "bash") + (#offset! @injection.content 0 1 0 0)))))) + +; Prometheus Alertmanager ("expr") +(block_mapping_pair + key: (flow_node) @_expr + (#eq? @_expr "expr") + value: (flow_node + (plain_scalar + (string_scalar) @injection.content) + (#set! injection.language "promql"))) + +(block_mapping_pair + key: (flow_node) @_expr + (#eq? @_expr "expr") + value: (block_node + (block_scalar) @injection.content + (#set! injection.language "promql") + (#offset! @injection.content 0 1 0 0))) + +(block_mapping_pair + key: (flow_node) @_expr + (#eq? @_expr "expr") + value: (block_node + (block_sequence + (block_sequence_item + (flow_node + (plain_scalar + (string_scalar) @injection.content)) + (#set! injection.language "promql"))))) + +(block_mapping_pair + key: (flow_node) @_expr + (#eq? @_expr "expr") + value: (block_node + (block_sequence + (block_sequence_item + (block_node + (block_scalar) @injection.content + (#set! injection.language "promql") + (#offset! @injection.content 0 1 0 0)))))) diff --git a/runtime/queries/yaml/locals.scm b/runtime/queries/yaml/locals.scm new file mode 100644 index 000000000..f7c79e082 --- /dev/null +++ b/runtime/queries/yaml/locals.scm @@ -0,0 +1,9 @@ +[ + (stream) + (document) + (block_node) +] @local.scope + +(anchor_name) @local.definition + +(alias_name) @local.reference diff --git a/runtime/queries/yang/folds.scm b/runtime/queries/yang/folds.scm new file mode 100644 index 000000000..fd7d23999 --- /dev/null +++ b/runtime/queries/yang/folds.scm @@ -0,0 +1 @@ +(block) @fold diff --git a/runtime/queries/yang/highlights.scm b/runtime/queries/yang/highlights.scm new file mode 100644 index 000000000..1fb588af1 --- /dev/null +++ b/runtime/queries/yang/highlights.scm @@ -0,0 +1,79 @@ +(comment) @comment @spell + +; Module / submodule +[ + "module" + "submodule" +] @keyword + +; Keywords +(statement_keyword) @keyword + +(statement_keyword + "import") @keyword.import + +(extension_keyword) @function + +; Arguments +(built_in_type) @type.builtin + +(number) @number + +(boolean) @boolean + +(date) @number + +(range + (_ + ".." @punctuation.special)) + +(range + (_ + "|" @punctuation.special)) + +(quoted_range + "\"" @string.special) + +(quoted_range + "'" @string.special) + +(yang_version) @constant.builtin + +(identifier) @variable + +(node_identifier) @variable + +(string) @string + +(string + (escape_sequence) @string.escape) + +(unquoted_string) @string + +(keypath) @string.special.path + +; Always highlight the value of an enum statement as a constant +(enum_value) @constant + +; Highlight xpath and pattern strings differently from plain strings +(statement + (statement_keyword + "must") + (argument + (string) @string.special)) + +(statement + (statement_keyword + "pattern") + (argument + (string) @string.regexp)) + +; Punctuation +(plus_symbol) @operator + +[ + "{" + "}" +] @punctuation.bracket + +";" @punctuation.delimiter diff --git a/runtime/queries/yang/indents.scm b/runtime/queries/yang/indents.scm new file mode 100644 index 000000000..cc4b3caee --- /dev/null +++ b/runtime/queries/yang/indents.scm @@ -0,0 +1,20 @@ +(module) @indent.begin + +(submodule) @indent.begin + +(statement) @indent.begin + +(extension_statement) @indent.begin + +(statement + ";" @indent.end) + +(extension_statement + ";" @indent.end) + +(block + "}" @indent.end @indent.branch) + +((string) @indent.align + (#set! indent.open_delimiter "\"") + (#set! indent.close_delimiter "\"")) diff --git a/runtime/queries/yang/injections.scm b/runtime/queries/yang/injections.scm new file mode 100644 index 000000000..4219eb30a --- /dev/null +++ b/runtime/queries/yang/injections.scm @@ -0,0 +1,10 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((statement + (statement_keyword + "pattern") + (argument + (string) @injection.content)) + (#set! injection.language "regex") + (#offset! @injection.content 0 1 0 -1)) diff --git a/runtime/queries/yuck/folds.scm b/runtime/queries/yuck/folds.scm new file mode 100644 index 000000000..bad5a07c9 --- /dev/null +++ b/runtime/queries/yuck/folds.scm @@ -0,0 +1,9 @@ +[ + (ast_block) + (list) + (array) + (expr) + (json_array) + (json_object) + (parenthesized_expression) +] @fold diff --git a/runtime/queries/yuck/highlights.scm b/runtime/queries/yuck/highlights.scm new file mode 100644 index 000000000..7b9a9d203 --- /dev/null +++ b/runtime/queries/yuck/highlights.scm @@ -0,0 +1,154 @@ +; Tags +; TODO apply to every symbol in list? I think it should probably only be applied to the first child of the list +(list + (symbol) @tag) + +; Includes +(list + . + (symbol) @keyword.import + (#eq? @keyword.import "include")) + +; Keywords +(list + . + (symbol) @keyword + (#any-of? @keyword + "defwindow" "defwidget" "defvar" "defpoll" "deflisten" "geometry" "children" "struts")) + +; Loop +(loop_widget + . + "for" @keyword.repeat + . + (symbol) @variable + . + "in" @keyword.operator) + +(loop_widget + . + "for" @keyword.repeat + . + (symbol) @variable + . + "in" @keyword.operator + . + (symbol) @variable) + +; Builtin widgets +(list + . + (symbol) @tag.builtin + (#any-of? @tag.builtin + "box" "button" "calendar" "centerbox" "checkbox" "circular-progress" "color-button" + "color-chooser" "combo-box-text" "eventbox" "expander" "graph" "image" "input" "label" "literal" + "overlay" "progress" "revealer" "scale" "scroll" "transform")) + +; Variables +(ident) @variable + +(array + (symbol) @variable) + +((ident) @variable.builtin + (#any-of? @variable.builtin + "EWW_TEMPS" "EWW_RAM" "EWW_DISK" "EWW_BATTERY" "EWW_CPU" "EWW_NET" "EWW_TIME" "EWW_CONFIG_DIR" + "EWW_CMD" "EWW_EXECUTABLE")) + +; Properties +(keyword) @property + +(json_access + (_) + "[" + (simplexpr + (ident) @property)) + +(json_safe_access + (_) + "?." + "[" + (simplexpr + (ident) @property)) + +(json_dot_access + (index) @property) + +(json_safe_dot_access + (index) @property) + +(json_object + (simplexpr + (ident) @property)) + +; Functions +(function_call + name: (ident) @function.call) + +; Operators +[ + "+" + "-" + "*" + "/" + "%" + "||" + "&&" + "==" + "!=" + "=~" + ">" + "<" + ">=" + "<=" + "!" + "?." + "?:" +] @operator + +; Punctuation +[ + ":" + "." + "," +] @punctuation.delimiter + +[ + "{" + "}" + "[" + "]" + "(" + ")" +] @punctuation.bracket + +; Ternary expression +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +; Literals +(number) @number + +(float) @number.float + +(boolean) @boolean + +; Strings +[ + (string_fragment) + "\"" + "'" + "`" +] @string + +(string_interpolation + "${" @punctuation.special + "}" @punctuation.special) + +(escape_sequence) @string.escape + +; Comments +(comment) @comment @spell diff --git a/runtime/queries/yuck/indents.scm b/runtime/queries/yuck/indents.scm new file mode 100644 index 000000000..515795021 --- /dev/null +++ b/runtime/queries/yuck/indents.scm @@ -0,0 +1,30 @@ +[ + (ast_block) + (array) + (expr) + (json_array) + (json_object) + (parenthesized_expression) +] @indent.begin + +; TODO: can't get this to work, goal is to indent at the property ":" prefix +; ((list (identifier) (property)) @indent.align +; (#set! indent.open_delimiter "(") +; (#set! indent.close_delimiter ")")) +[ + ")" + "}" + "]" +] @indent.end @indent.branch + +; I do not know what/when this should be added. +; Commenting this out for now +; [ +; "(" +; "{" +; "[" +; ] @indent.branch +[ + (ERROR) + (comment) +] @indent.auto diff --git a/runtime/queries/yuck/injections.scm b/runtime/queries/yuck/injections.scm new file mode 100644 index 000000000..298a8d070 --- /dev/null +++ b/runtime/queries/yuck/injections.scm @@ -0,0 +1,26 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((function_call + name: (ident) @_name + . + (simplexpr) + . + (simplexpr + (string + (string_fragment) @injection.content)+)) + (#any-of? @_name "replace" "search" "matches" "captures") + (#set! injection.language "regex") + (#set! injection.combined)) + +((function_call + name: (ident) @_name + . + (simplexpr) + . + (simplexpr + (string + (string_fragment) @injection.content)+)) + (#eq? @_name "jq") + (#set! injection.language "jq") + (#set! injection.combined)) diff --git a/runtime/queries/yuck/locals.scm b/runtime/queries/yuck/locals.scm new file mode 100644 index 000000000..9f40b2082 --- /dev/null +++ b/runtime/queries/yuck/locals.scm @@ -0,0 +1,21 @@ +[ + (ast_block) + (list) + (array) + (expr) + (json_array) + (json_object) + (parenthesized_expression) +] @local.scope + +(symbol) @local.reference + +(keyword) @local.definition.field + +(json_object + (simplexpr + (ident) @local.definition.field)) + +(ast_block + (symbol) + (ident) @local.definition.type) diff --git a/runtime/queries/zathurarc/highlights.scm b/runtime/queries/zathurarc/highlights.scm new file mode 100644 index 000000000..04daa190a --- /dev/null +++ b/runtime/queries/zathurarc/highlights.scm @@ -0,0 +1,36 @@ +; General +(path) @string.special.path + +(option) @variable.builtin + +(command) @keyword + +(include_directive + (command) @keyword.import) + +(mode_name) @type.builtin + +(key) @constant + +(function) @function.call + +(argument) @variable.parameter + +; Comments +(comment) @comment @spell + +; Literals +(int) @number + +(float) @number.float + +(string) @string + +(bool) @boolean + +[ + "<" + ">" + "[" + "]" +] @punctuation.bracket diff --git a/runtime/queries/zathurarc/injections.scm b/runtime/queries/zathurarc/injections.scm new file mode 100644 index 000000000..8e45396b7 --- /dev/null +++ b/runtime/queries/zathurarc/injections.scm @@ -0,0 +1,9 @@ +(set_directive + (option) @_option + (string) @injection.content + (#eq? @_option "synctex-editor-command") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "bash")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/zig/folds.scm b/runtime/queries/zig/folds.scm new file mode 100644 index 000000000..6be5c62ba --- /dev/null +++ b/runtime/queries/zig/folds.scm @@ -0,0 +1,23 @@ +[ + (block) + (switch_expression) + (initializer_list) + (asm_expression) + (multiline_string) + (if_statement) + (while_statement) + (for_statement) + (if_expression) + (else_clause) + (for_expression) + (while_expression) + (if_type_expression) + (function_signature) + (parameters) + (call_expression) + (struct_declaration) + (opaque_declaration) + (enum_declaration) + (union_declaration) + (error_set_declaration) +] @fold diff --git a/runtime/queries/zig/highlights.scm b/runtime/queries/zig/highlights.scm new file mode 100644 index 000000000..1f9006781 --- /dev/null +++ b/runtime/queries/zig/highlights.scm @@ -0,0 +1,283 @@ +; Variables +(identifier) @variable + +; Parameters +(parameter + name: (identifier) @variable.parameter) + +(payload + (identifier) @variable.parameter) + +; Types +(parameter + type: (identifier) @type) + +((identifier) @type + (#lua-match? @type "^[A-Z_][a-zA-Z0-9_]*")) + +(variable_declaration + (identifier) @type + "=" + [ + (struct_declaration) + (enum_declaration) + (union_declaration) + (opaque_declaration) + ]) + +[ + (builtin_type) + "anyframe" +] @type.builtin + +; Constants +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]+$")) + +[ + "null" + "unreachable" + "undefined" +] @constant.builtin + +(field_expression + . + member: (identifier) @constant) + +(enum_declaration + (container_field + type: (identifier) @constant)) + +; Labels +(block_label + (identifier) @label) + +(break_label + (identifier) @label) + +; Fields +(field_initializer + . + (identifier) @variable.member) + +(field_expression + (_) + member: (identifier) @variable.member) + +(container_field + name: (identifier) @variable.member) + +(initializer_list + (assignment_expression + left: (field_expression + . + member: (identifier) @variable.member))) + +; Functions +(builtin_identifier) @function.builtin + +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (field_expression + member: (identifier) @function.call)) + +(function_declaration + name: (identifier) @function) + +; Modules +(variable_declaration + (identifier) @module + (builtin_function + (builtin_identifier) @keyword.import + (#any-of? @keyword.import "@import" "@cImport"))) + +; Builtins +[ + "c" + "..." +] @variable.builtin + +((identifier) @variable.builtin + (#eq? @variable.builtin "_")) + +(calling_convention + (identifier) @variable.builtin) + +; Keywords +[ + "asm" + "defer" + "errdefer" + "test" + "error" + "const" + "var" +] @keyword + +[ + "struct" + "union" + "enum" + "opaque" +] @keyword.type + +[ + "async" + "await" + "suspend" + "nosuspend" + "resume" +] @keyword.coroutine + +"fn" @keyword.function + +[ + "and" + "or" + "orelse" +] @keyword.operator + +"return" @keyword.return + +[ + "if" + "else" + "switch" +] @keyword.conditional + +[ + "for" + "while" + "break" + "continue" +] @keyword.repeat + +[ + "usingnamespace" + "export" +] @keyword.import + +[ + "try" + "catch" +] @keyword.exception + +[ + "volatile" + "allowzero" + "noalias" + "addrspace" + "align" + "callconv" + "linksection" + "pub" + "inline" + "noinline" + "extern" + "comptime" + "packed" + "threadlocal" +] @keyword.modifier + +; Operator +[ + "=" + "*=" + "*%=" + "*|=" + "/=" + "%=" + "+=" + "+%=" + "+|=" + "-=" + "-%=" + "-|=" + "<<=" + "<<|=" + ">>=" + "&=" + "^=" + "|=" + "!" + "~" + "-" + "-%" + "&" + "==" + "!=" + ">" + ">=" + "<=" + "<" + "&" + "^" + "|" + "<<" + ">>" + "<<|" + "+" + "++" + "+%" + "-%" + "+|" + "-|" + "*" + "/" + "%" + "**" + "*%" + "*|" + "||" + ".*" + ".?" + "?" + ".." +] @operator + +; Literals +(character) @character + +([ + (string) + (multiline_string) +] @string + (#set! "priority" 95)) + +(integer) @number + +(float) @number.float + +(boolean) @boolean + +(escape_sequence) @string.escape + +; Punctuation +[ + "[" + "]" + "(" + ")" + "{" + "}" +] @punctuation.bracket + +[ + ";" + "." + "," + ":" + "=>" + "->" +] @punctuation.delimiter + +(payload + "|" @punctuation.bracket) + +; Comments +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^//!")) diff --git a/runtime/queries/zig/indents.scm b/runtime/queries/zig/indents.scm new file mode 100644 index 000000000..11ff9ca16 --- /dev/null +++ b/runtime/queries/zig/indents.scm @@ -0,0 +1,28 @@ +[ + (block) + (struct_declaration) + (enum_declaration) + (union_declaration) + (switch_expression) + (if_expression) + (while_expression) + (for_expression) + (initializer_list) +] @indent.begin + +(block + "}" @indent.end) + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @indent.branch + +[ + (comment) + (multiline_string) +] @indent.ignore diff --git a/runtime/queries/zig/injections.scm b/runtime/queries/zig/injections.scm new file mode 100644 index 000000000..48a1b44c9 --- /dev/null +++ b/runtime/queries/zig/injections.scm @@ -0,0 +1,10 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; TODO: add when asm is added +; (asm_output_item (string) @injection.content +; (#set! injection.language "asm")) +; (asm_input_item (string) @injection.content +; (#set! injection.language "asm")) +; (asm_clobbers (string) @injection.content +; (#set! injection.language "asm")) diff --git a/runtime/queries/zig/locals.scm b/runtime/queries/zig/locals.scm new file mode 100644 index 000000000..b9e63441d --- /dev/null +++ b/runtime/queries/zig/locals.scm @@ -0,0 +1,96 @@ +; Definitions +(function_declaration + name: (identifier) @local.definition.function) + +(parameter + name: (identifier) @local.definition.parameter) + +(variable_declaration + (identifier) @local.definition.var) + +(variable_declaration + (identifier) @local.definition.type + (enum_declaration)) + +(container_field + type: (identifier) @local.definition.field) + +(enum_declaration + (function_declaration + name: (identifier) @local.definition.method)) + +(variable_declaration + (identifier) @local.definition.type + (struct_declaration)) + +(struct_declaration + (function_declaration + name: (identifier) @local.definition.method)) + +(container_field + name: (identifier) @local.definition.field) + +(variable_declaration + (identifier) @local.definition.type + (union_declaration)) + +(union_declaration + (function_declaration + name: (identifier) @local.definition.method)) + +(payload + (identifier) @local.definition.var) + +(block_label + (identifier) @local.definition) + +; References +(identifier) @local.reference + +(parameter + type: (identifier) @local.reference + (#set! reference.kind "type")) + +(pointer_type + (identifier) @local.reference + (#set! reference.kind "type")) + +(nullable_type + (identifier) @local.reference + (#set! reference.kind "type")) + +(struct_initializer + (identifier) @local.reference + (#set! reference.kind "type")) + +(array_type + (_) + (identifier) @local.reference + (#set! reference.kind "type")) + +(slice_type + (identifier) @local.reference + (#set! reference.kind "type")) + +(field_expression + member: (identifier) @local.reference + (#set! reference.kind "field")) + +(call_expression + function: (field_expression + member: (identifier) @local.reference + (#set! reference.kind "function"))) + +(break_label + (identifier) @local.reference) + +[ + (for_statement) + (if_statement) + (while_statement) + (function_declaration) + (block) + (source_file) + (enum_declaration) + (struct_declaration) +] @local.scope diff --git a/runtime/queries/ziggy/highlights.scm b/runtime/queries/ziggy/highlights.scm new file mode 100644 index 000000000..27f6c9a48 --- /dev/null +++ b/runtime/queries/ziggy/highlights.scm @@ -0,0 +1,41 @@ +[ + (true) + (false) +] @constant.builtin + +(null) @constant.builtin + +[ + (integer) + (float) +] @number + +(struct_field + key: (_) @keyword) + +(struct + name: (_) @type) + +(tag) @function + +[ + (string) + (line_string)* +] @string + +(comment) @comment + +(escape_sequence) @string.escape + +"," @punctuation.delimiter + +[ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket + +(top_comment) @comment diff --git a/runtime/queries/ziggy/indents.scm b/runtime/queries/ziggy/indents.scm new file mode 100644 index 000000000..223bde81a --- /dev/null +++ b/runtime/queries/ziggy/indents.scm @@ -0,0 +1,10 @@ +[ + (struct) + (map) + (array) +] @indent.begin + +[ + "]" + "}" +] @indent.end diff --git a/runtime/queries/ziggy_schema/highlights.scm b/runtime/queries/ziggy_schema/highlights.scm new file mode 100644 index 000000000..4e1770127 --- /dev/null +++ b/runtime/queries/ziggy_schema/highlights.scm @@ -0,0 +1,38 @@ +(struct_field + key: (_) @keyword) + +(tag_name) @function + +[ + "unknown" + "any" + "struct" + "root" + "enum" + "map" +] @keyword + +(identifier) @type + +"?" @type + +[ + "bool" + "bytes" + "int" + "float" +] @constant.builtin + +(doc_comment) @comment.documentation + +[ + "," + "|" +] @punctuation.delimiter + +[ + "[" + "]" + "{" + "}" +] @punctuation.bracket diff --git a/runtime/queries/ziggy_schema/indents.scm b/runtime/queries/ziggy_schema/indents.scm new file mode 100644 index 000000000..6f7f7b87c --- /dev/null +++ b/runtime/queries/ziggy_schema/indents.scm @@ -0,0 +1,3 @@ +(struct) @indent.begin + +"}" @indent.end |
