diff --git a/languages.toml b/languages.toml index 261391579392..482a25110195 100644 --- a/languages.toml +++ b/languages.toml @@ -524,7 +524,6 @@ file-types = ["js", "mjs", "cjs"] shebangs = ["node"] roots = [] comment-token = "//" -# TODO: highlights-params language-servers = [ "typescript-language-server" ] indent = { tab-width = 2, unit = " " } @@ -564,7 +563,6 @@ file-types = ["ts", "mts", "cts"] language-id = "typescript" shebangs = [] roots = [] -# TODO: highlights-params language-servers = [ "typescript-language-server" ] indent = { tab-width = 2, unit = " " } @@ -579,7 +577,6 @@ injection-regex = "(tsx)" # |typescript language-id = "typescriptreact" file-types = ["tsx"] roots = [] -# TODO: highlights-params language-servers = [ "typescript-language-server" ] indent = { tab-width = 2, unit = " " } diff --git a/runtime/queries/_javascript/highlights.scm b/runtime/queries/_javascript/highlights.scm new file mode 100644 index 000000000000..8b0bbb94f371 --- /dev/null +++ b/runtime/queries/_javascript/highlights.scm @@ -0,0 +1,36 @@ +; Function and method parameters +;------------------------------- + +; Javascript and Typescript Treesitter grammars deviate when defining the +; tree structure for parameters, so we need to address them in each specific +; language instead of ecma. + +; (p) +(formal_parameters + (identifier) @variable.parameter) + +; (...p) +(formal_parameters + (rest_pattern + (identifier) @variable.parameter)) + +; ({ p }) +(formal_parameters + (object_pattern + (shorthand_property_identifier_pattern) @variable.parameter)) + +; ({ a: p }) +(formal_parameters + (object_pattern + (pair_pattern + value: (identifier) @variable.parameter))) + +; ([ p ]) +(formal_parameters + (array_pattern + (identifier) @variable.parameter)) + +; (p = 1) +(formal_parameters + (assignment_pattern + left: (identifier) @variable.parameter)) diff --git a/runtime/queries/_javascript/locals.scm b/runtime/queries/_javascript/locals.scm new file mode 100644 index 000000000000..943566167933 --- /dev/null +++ b/runtime/queries/_javascript/locals.scm @@ -0,0 +1,14 @@ +; Definitions +;------------ +; Javascript and Typescript Treesitter grammars deviate when defining the +; tree structure for parameters, so we need to address them in each specific +; language instead of ecma. + +; (i) +(formal_parameters + (identifier) @local.definition) + +; (i = 1) +(formal_parameters + (assignment_pattern + left: (identifier) @local.definition)) diff --git a/runtime/queries/_javascript/tags.scm b/runtime/queries/_javascript/tags.scm new file mode 100644 index 000000000000..a7bbd311a4ea --- /dev/null +++ b/runtime/queries/_javascript/tags.scm @@ -0,0 +1,88 @@ +( + (comment)* @doc + . + (method_definition + name: (property_identifier) @name) @definition.method + (#not-eq? @name "constructor") + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.method) +) + +( + (comment)* @doc + . + [ + (class + name: (_) @name) + (class_declaration + name: (_) @name) + ] @definition.class + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.class) +) + +( + (comment)* @doc + . + [ + (function + name: (identifier) @name) + (function_declaration + name: (identifier) @name) + (generator_function + name: (identifier) @name) + (generator_function_declaration + name: (identifier) @name) + ] @definition.function + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.function) +) + +( + (comment)* @doc + . + (lexical_declaration + (variable_declarator + name: (identifier) @name + value: [(arrow_function) (function)]) @definition.function) + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.function) +) + +( + (comment)* @doc + . + (variable_declaration + (variable_declarator + name: (identifier) @name + value: [(arrow_function) (function)]) @definition.function) + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.function) +) + +(assignment_expression + left: [ + (identifier) @name + (member_expression + property: (property_identifier) @name) + ] + right: [(arrow_function) (function)] +) @definition.function + +(pair + key: (property_identifier) @name + value: [(arrow_function) (function)]) @definition.function + +( + (call_expression + function: (identifier) @name) @reference.call + (#not-match? @name "^(require)$") +) + +(call_expression + function: (member_expression + property: (property_identifier) @name) + arguments: (_) @reference.call) + +(new_expression + constructor: (_) @name) @reference.class diff --git a/runtime/queries/_jsx/highlights.scm b/runtime/queries/_jsx/highlights.scm new file mode 100644 index 000000000000..00641cdedbfd --- /dev/null +++ b/runtime/queries/_jsx/highlights.scm @@ -0,0 +1,55 @@ +; Opening elements +; ---------------- + +(jsx_opening_element ((identifier) @constructor + (#match? @constructor "^[A-Z]"))) + +; Handle the dot operator effectively - +(jsx_opening_element ((nested_identifier (identifier) @tag (identifier) @constructor))) + +(jsx_opening_element (identifier) @tag) + +; Closing elements +; ---------------- + +(jsx_closing_element ((identifier) @constructor + (#match? @constructor "^[A-Z]"))) + +; Handle the dot operator effectively - +(jsx_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor))) + +(jsx_closing_element (identifier) @tag) + +; Self-closing elements +; --------------------- + +(jsx_self_closing_element ((identifier) @constructor + (#match? @constructor "^[A-Z]"))) + +; Handle the dot operator effectively - +(jsx_self_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor))) + +(jsx_self_closing_element (identifier) @tag) + +; Attributes +; ---------- + +(jsx_attribute (property_identifier) @variable.other.member) + +; Punctuation +; ----------- + +; Handle attribute delimiter +(jsx_attribute "=" @punctuation.delimiter) + +; +(jsx_opening_element ["<" ">"] @punctuation.bracket) + +; +(jsx_closing_element ["<" "/" ">"] @punctuation.bracket) + +; +(jsx_self_closing_element ["<" "/" ">"] @punctuation.bracket) + +; <> ... +(jsx_fragment ["<" "/" ">"] @punctuation.bracket) diff --git a/runtime/queries/_jsx/indents.scm b/runtime/queries/_jsx/indents.scm new file mode 100644 index 000000000000..4731856cf9d4 --- /dev/null +++ b/runtime/queries/_jsx/indents.scm @@ -0,0 +1,7 @@ +[ + (jsx_fragment) + (jsx_element) + (jsx_self_closing_element) +] @indent + +(parenthesized_expression) @indent diff --git a/runtime/queries/_typescript/highlights.scm b/runtime/queries/_typescript/highlights.scm new file mode 100644 index 000000000000..02f3aab77a91 --- /dev/null +++ b/runtime/queries/_typescript/highlights.scm @@ -0,0 +1,139 @@ +; Namespaces +; ---------- + +(internal_module + [((identifier) @namespace) ((nested_identifier (identifier) @namespace))]) + +(ambient_declaration "global" @namespace) + +; Parameters +; ---------- +; Javascript and Typescript Treesitter grammars deviate when defining the +; tree structure for parameters, so we need to address them in each specific +; language instead of ecma. + +; (p: t) +; (p: t = 1) +(required_parameter + (identifier) @variable.parameter) + +; (...p: t) +(required_parameter + (rest_pattern + (identifier) @variable.parameter)) + +; ({ p }: { p: t }) +(required_parameter + (object_pattern + (shorthand_property_identifier_pattern) @variable.parameter)) + +; ({ a: p }: { a: t }) +(required_parameter + (object_pattern + (pair_pattern + value: (identifier) @variable.parameter))) + +; ([ p ]: t[]) +(required_parameter + (array_pattern + (identifier) @variable.parameter)) + +; (p?: t) +; (p?: t = 1) // Invalid but still posible to hihglight. +(optional_parameter + (identifier) @variable.parameter) + +; (...p?: t) // Invalid but still posible to hihglight. +(optional_parameter + (rest_pattern + (identifier) @variable.parameter)) + +; ({ p }: { p?: t}) +(optional_parameter + (object_pattern + (shorthand_property_identifier_pattern) @variable.parameter)) + +; ({ a: p }: { a?: t }) +(optional_parameter + (object_pattern + (pair_pattern + value: (identifier) @variable.parameter))) + +; ([ p ]?: t[]) // Invalid but still posible to hihglight. +(optional_parameter + (array_pattern + (identifier) @variable.parameter)) + +; Punctuation +; ----------- + +[ + ":" +] @punctuation.delimiter + +(optional_parameter "?" @punctuation.special) +(property_signature "?" @punctuation.special) + +(conditional_type ["?" ":"] @operator) + +; Keywords +; -------- + +[ + "abstract" + "declare" + "export" + "infer" + "implements" + "keyof" + "namespace" + "override" +] @keyword + +[ + "type" + "interface" + "enum" +] @keyword.storage.type + +[ + "public" + "private" + "protected" + "readonly" +] @keyword.storage.modifier + +; Types +; ----- + +(type_identifier) @type +(predefined_type) @type.builtin + +; Type arguments and parameters +; ----------------------------- + +(type_arguments + [ + "<" + ">" + ] @punctuation.bracket) + +(type_parameters + [ + "<" + ">" + ] @punctuation.bracket) + +; Literals +; -------- + +[ + (template_literal_type) +] @string + +; Tokens +; ------ + +(template_type + "${" @punctuation.special + "}" @punctuation.special) @embedded diff --git a/runtime/queries/_typescript/indents.scm b/runtime/queries/_typescript/indents.scm new file mode 100644 index 000000000000..90dbc85bf86b --- /dev/null +++ b/runtime/queries/_typescript/indents.scm @@ -0,0 +1,5 @@ +[ + (enum_declaration) + (interface_declaration) + (object_type) +] @indent diff --git a/runtime/queries/_typescript/locals.scm b/runtime/queries/_typescript/locals.scm new file mode 100644 index 000000000000..fe13f21d3d65 --- /dev/null +++ b/runtime/queries/_typescript/locals.scm @@ -0,0 +1,16 @@ +; Definitions +;------------ + +; Javascript and Typescript Treesitter grammars deviate when defining the +; tree structure for parameters, so we need to address them in each specific +; language instead of ecma. + +; (i: t) +; (i: t = 1) +(required_parameter + (identifier) @local.definition) + +; (i?: t) +; (i?: t = 1) // Invalid but still posible to hihglight. +(optional_parameter + (identifier) @local.definition) diff --git a/runtime/queries/_typescript/tags.scm b/runtime/queries/_typescript/tags.scm new file mode 100644 index 000000000000..ccae934e7159 --- /dev/null +++ b/runtime/queries/_typescript/tags.scm @@ -0,0 +1,23 @@ +(function_signature + name: (identifier) @name) @definition.function + +(method_signature + name: (property_identifier) @name) @definition.method + +(abstract_method_signature + name: (property_identifier) @name) @definition.method + +(abstract_class_declaration + name: (type_identifier) @name) @definition.class + +(module + name: (identifier) @name) @definition.module + +(interface_declaration + name: (type_identifier) @name) @definition.interface + +(type_annotation + (type_identifier) @name) @reference.type + +(new_expression + constructor: (identifier) @name) @reference.class diff --git a/runtime/queries/_typescript/textobjects.scm b/runtime/queries/_typescript/textobjects.scm new file mode 100644 index 000000000000..c248aeade497 --- /dev/null +++ b/runtime/queries/_typescript/textobjects.scm @@ -0,0 +1,6 @@ +[ + (interface_declaration + body:(_) @class.inside) + (type_alias_declaration + value: (_) @class.inside) +] @class.around diff --git a/runtime/queries/ecma/README.md b/runtime/queries/ecma/README.md new file mode 100644 index 000000000000..b891f24bbc93 --- /dev/null +++ b/runtime/queries/ecma/README.md @@ -0,0 +1,14 @@ +# Inheritance model for ecma-based languages + +Ecma-based languages share many traits. Because of this we want to share as many queries as possible while avoiding nested inheritance that can make query behaviour unpredictable due to unexpected precedence. + +To achieve that, there are "public" and "private" versions for javascript, jsx, and typescript query files, that share the same name, but the "private" version name starts with an underscore (with the exception of ecma, that already exists as a sort of base "private" language). This allows the "private" versions to host the specific queries of the language excluding any `; inherits` statement, in order to make them safe to be inherited by the "public" version of the same language and other languages as well. The tsx language doesn't have a "private" version given that currently it doesn't need to be inherited by other languages. + +| Language | Inherits from | +| ---------- | ----------------------- | +| javascript | _javascript, ecma | +| jsx | _jsx, _javascript, ecma | +| typescript | _typescript, ecma | +| tsx | _jsx, _typescript, ecma | + +If you intend to add queries to any of the ecma-based languages above, make sure you add them to the correct private language they belong to, so that other languages down the line can benefit from them. diff --git a/runtime/queries/ecma/highlights.scm b/runtime/queries/ecma/highlights.scm index 7285ab9603ba..ddbe938fe2e5 100644 --- a/runtime/queries/ecma/highlights.scm +++ b/runtime/queries/ecma/highlights.scm @@ -46,8 +46,15 @@ (assignment_expression left: (identifier) @function right: [(function) (arrow_function)]) - +; Function and method parameters +;------------------------------- + +; Arrow function parameters in the form `p => ...` are supported by both +; javascript and typescript grammars without conflicts. +(arrow_function + parameter: (identifier) @variable.parameter) + ; Function and method calls ;-------------------------- diff --git a/runtime/queries/ecma/locals.scm b/runtime/queries/ecma/locals.scm index cc5f2e14f8fc..df8eb0d397e7 100644 --- a/runtime/queries/ecma/locals.scm +++ b/runtime/queries/ecma/locals.scm @@ -12,14 +12,28 @@ ; Definitions ;------------ -(pattern/identifier) @local.definition +; ...i +(rest_pattern + (identifier) @local.definition) + +; { i } +(object_pattern + (shorthand_property_identifier_pattern) @local.definition) -(pattern/rest_pattern +; { a: i } +(object_pattern + (pair_pattern + value: (identifier) @local.definition)) + +; [ i ] +(array_pattern (identifier) @local.definition) - + +; i => ... (arrow_function parameter: (identifier) @local.definition) +; const/let/var i = ... (variable_declarator name: (identifier) @local.definition) diff --git a/runtime/queries/javascript/highlights.scm b/runtime/queries/javascript/highlights.scm index 588434799072..2a40b3723383 100644 --- a/runtime/queries/javascript/highlights.scm +++ b/runtime/queries/javascript/highlights.scm @@ -1,38 +1,3 @@ -; Function and method parameters -;------------------------------- +; See runtime/queries/ecma/README.md for more info. -; (p) => ... -(formal_parameters - (identifier) @variable.parameter) - -; (...p) => ... -(formal_parameters - (rest_pattern - (identifier) @variable.parameter)) - -; ({ p }) => ... -(formal_parameters - (object_pattern - (shorthand_property_identifier_pattern) @variable.parameter)) - -; ({ a: p }) => ... -(formal_parameters - (object_pattern - (pair_pattern - value: (identifier) @variable.parameter))) - -; ([ p ]) => ... -(formal_parameters - (array_pattern - (identifier) @variable.parameter)) - -; (p = 1) => ... -(formal_parameters - (assignment_pattern - left: (identifier) @variable.parameter)) - -; p => ... -(arrow_function - parameter: (identifier) @variable.parameter) - -; inherits: ecma +; inherits: _javascript,ecma diff --git a/runtime/queries/javascript/indents.scm b/runtime/queries/javascript/indents.scm index 04328f099e98..2a40b3723383 100644 --- a/runtime/queries/javascript/indents.scm +++ b/runtime/queries/javascript/indents.scm @@ -1 +1,3 @@ -; inherits: ecma +; See runtime/queries/ecma/README.md for more info. + +; inherits: _javascript,ecma diff --git a/runtime/queries/javascript/injections.scm b/runtime/queries/javascript/injections.scm index 04328f099e98..2a40b3723383 100644 --- a/runtime/queries/javascript/injections.scm +++ b/runtime/queries/javascript/injections.scm @@ -1 +1,3 @@ -; inherits: ecma +; See runtime/queries/ecma/README.md for more info. + +; inherits: _javascript,ecma diff --git a/runtime/queries/javascript/locals.scm b/runtime/queries/javascript/locals.scm index 04328f099e98..2a40b3723383 100644 --- a/runtime/queries/javascript/locals.scm +++ b/runtime/queries/javascript/locals.scm @@ -1 +1,3 @@ -; inherits: ecma +; See runtime/queries/ecma/README.md for more info. + +; inherits: _javascript,ecma diff --git a/runtime/queries/javascript/tags.scm b/runtime/queries/javascript/tags.scm index a7bbd311a4ea..2a40b3723383 100644 --- a/runtime/queries/javascript/tags.scm +++ b/runtime/queries/javascript/tags.scm @@ -1,88 +1,3 @@ -( - (comment)* @doc - . - (method_definition - name: (property_identifier) @name) @definition.method - (#not-eq? @name "constructor") - (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") - (#select-adjacent! @doc @definition.method) -) +; See runtime/queries/ecma/README.md for more info. -( - (comment)* @doc - . - [ - (class - name: (_) @name) - (class_declaration - name: (_) @name) - ] @definition.class - (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") - (#select-adjacent! @doc @definition.class) -) - -( - (comment)* @doc - . - [ - (function - name: (identifier) @name) - (function_declaration - name: (identifier) @name) - (generator_function - name: (identifier) @name) - (generator_function_declaration - name: (identifier) @name) - ] @definition.function - (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") - (#select-adjacent! @doc @definition.function) -) - -( - (comment)* @doc - . - (lexical_declaration - (variable_declarator - name: (identifier) @name - value: [(arrow_function) (function)]) @definition.function) - (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") - (#select-adjacent! @doc @definition.function) -) - -( - (comment)* @doc - . - (variable_declaration - (variable_declarator - name: (identifier) @name - value: [(arrow_function) (function)]) @definition.function) - (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") - (#select-adjacent! @doc @definition.function) -) - -(assignment_expression - left: [ - (identifier) @name - (member_expression - property: (property_identifier) @name) - ] - right: [(arrow_function) (function)] -) @definition.function - -(pair - key: (property_identifier) @name - value: [(arrow_function) (function)]) @definition.function - -( - (call_expression - function: (identifier) @name) @reference.call - (#not-match? @name "^(require)$") -) - -(call_expression - function: (member_expression - property: (property_identifier) @name) - arguments: (_) @reference.call) - -(new_expression - constructor: (_) @name) @reference.class +; inherits: _javascript,ecma diff --git a/runtime/queries/javascript/textobjects.scm b/runtime/queries/javascript/textobjects.scm index 04328f099e98..2a40b3723383 100644 --- a/runtime/queries/javascript/textobjects.scm +++ b/runtime/queries/javascript/textobjects.scm @@ -1 +1,3 @@ -; inherits: ecma +; See runtime/queries/ecma/README.md for more info. + +; inherits: _javascript,ecma diff --git a/runtime/queries/jsx/highlights.scm b/runtime/queries/jsx/highlights.scm index a1eb2d0ed6e9..eb2b1b1a4595 100644 --- a/runtime/queries/jsx/highlights.scm +++ b/runtime/queries/jsx/highlights.scm @@ -1,37 +1,3 @@ -; Highlight component names differently -(jsx_opening_element ((identifier) @constructor - (#match? @constructor "^[A-Z]"))) +; See runtime/queries/ecma/README.md for more info. -; Handle the dot operator effectively - -(jsx_opening_element ((nested_identifier (identifier) @tag (identifier) @constructor))) - -; Highlight brackets differently -(jsx_opening_element ["<" ">"] @punctuation.bracket) - -(jsx_closing_element ((identifier) @constructor - (#match? @constructor "^[A-Z]"))) - -; Handle the dot operator effectively - -(jsx_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor))) - -; Highlight brackets differently -(jsx_closing_element ["<" "/" ">"] @punctuation.bracket) - -(jsx_self_closing_element ((identifier) @constructor - (#match? @constructor "^[A-Z]"))) - -; Handle the dot operator effectively - -(jsx_self_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor))) - -; Highlight brackets differently -(jsx_self_closing_element ["<" "/" ">"] @punctuation.bracket) - -; Handle attribute delimiter -(jsx_attribute "=" @punctuation.delimiter) - -(jsx_opening_element (identifier) @tag) -(jsx_closing_element (identifier) @tag) -(jsx_self_closing_element (identifier) @tag) -(jsx_attribute (property_identifier) @variable.other.member) - -; inherits: ecma +; inherits: _jsx,_javascript,ecma diff --git a/runtime/queries/jsx/indents.scm b/runtime/queries/jsx/indents.scm index 6cb82545efd4..eb2b1b1a4595 100644 --- a/runtime/queries/jsx/indents.scm +++ b/runtime/queries/jsx/indents.scm @@ -1,9 +1,3 @@ -[ - (jsx_fragment) - (jsx_element) - (jsx_self_closing_element) -] @indent +; See runtime/queries/ecma/README.md for more info. -(parenthesized_expression) @indent - -; inherits: ecma +; inherits: _jsx,_javascript,ecma diff --git a/runtime/queries/jsx/injections.scm b/runtime/queries/jsx/injections.scm index 04328f099e98..eb2b1b1a4595 100644 --- a/runtime/queries/jsx/injections.scm +++ b/runtime/queries/jsx/injections.scm @@ -1 +1,3 @@ -; inherits: ecma +; See runtime/queries/ecma/README.md for more info. + +; inherits: _jsx,_javascript,ecma diff --git a/runtime/queries/jsx/locals.scm b/runtime/queries/jsx/locals.scm index 04328f099e98..eb2b1b1a4595 100644 --- a/runtime/queries/jsx/locals.scm +++ b/runtime/queries/jsx/locals.scm @@ -1 +1,3 @@ -; inherits: ecma +; See runtime/queries/ecma/README.md for more info. + +; inherits: _jsx,_javascript,ecma diff --git a/runtime/queries/jsx/tags.scm b/runtime/queries/jsx/tags.scm new file mode 100644 index 000000000000..eb2b1b1a4595 --- /dev/null +++ b/runtime/queries/jsx/tags.scm @@ -0,0 +1,3 @@ +; See runtime/queries/ecma/README.md for more info. + +; inherits: _jsx,_javascript,ecma diff --git a/runtime/queries/jsx/textobjects.scm b/runtime/queries/jsx/textobjects.scm index 04328f099e98..eb2b1b1a4595 100644 --- a/runtime/queries/jsx/textobjects.scm +++ b/runtime/queries/jsx/textobjects.scm @@ -1 +1,3 @@ -; inherits: ecma +; See runtime/queries/ecma/README.md for more info. + +; inherits: _jsx,_javascript,ecma diff --git a/runtime/queries/tsx/highlights.scm b/runtime/queries/tsx/highlights.scm index 100c7cc7af58..721c56c74a22 100644 --- a/runtime/queries/tsx/highlights.scm +++ b/runtime/queries/tsx/highlights.scm @@ -1 +1,3 @@ -; inherits: jsx,typescript +; See runtime/queries/ecma/README.md for more info. + +; inherits: _jsx,_typescript,ecma diff --git a/runtime/queries/tsx/indents.scm b/runtime/queries/tsx/indents.scm index 07391231c635..721c56c74a22 100644 --- a/runtime/queries/tsx/indents.scm +++ b/runtime/queries/tsx/indents.scm @@ -1 +1,3 @@ -; inherits: typescript,jsx +; See runtime/queries/ecma/README.md for more info. + +; inherits: _jsx,_typescript,ecma diff --git a/runtime/queries/tsx/injections.scm b/runtime/queries/tsx/injections.scm index 1b61e36da3ca..721c56c74a22 100644 --- a/runtime/queries/tsx/injections.scm +++ b/runtime/queries/tsx/injections.scm @@ -1 +1,3 @@ -; inherits: typescript +; See runtime/queries/ecma/README.md for more info. + +; inherits: _jsx,_typescript,ecma diff --git a/runtime/queries/tsx/locals.scm b/runtime/queries/tsx/locals.scm new file mode 100644 index 000000000000..721c56c74a22 --- /dev/null +++ b/runtime/queries/tsx/locals.scm @@ -0,0 +1,3 @@ +; See runtime/queries/ecma/README.md for more info. + +; inherits: _jsx,_typescript,ecma diff --git a/runtime/queries/tsx/tags.scm b/runtime/queries/tsx/tags.scm new file mode 100644 index 000000000000..721c56c74a22 --- /dev/null +++ b/runtime/queries/tsx/tags.scm @@ -0,0 +1,3 @@ +; See runtime/queries/ecma/README.md for more info. + +; inherits: _jsx,_typescript,ecma diff --git a/runtime/queries/tsx/textobjects.scm b/runtime/queries/tsx/textobjects.scm index 07391231c635..721c56c74a22 100644 --- a/runtime/queries/tsx/textobjects.scm +++ b/runtime/queries/tsx/textobjects.scm @@ -1 +1,3 @@ -; inherits: typescript,jsx +; See runtime/queries/ecma/README.md for more info. + +; inherits: _jsx,_typescript,ecma diff --git a/runtime/queries/typescript/highlights.scm b/runtime/queries/typescript/highlights.scm index 3ab9c7466a54..5b8c8f244a3d 100644 --- a/runtime/queries/typescript/highlights.scm +++ b/runtime/queries/typescript/highlights.scm @@ -1,82 +1,3 @@ -; Namespaces +; See runtime/queries/ecma/README.md for more info. -(internal_module - [((identifier) @namespace) ((nested_identifier (identifier) @namespace))]) - -(ambient_declaration "global" @namespace) - -; Variables - -(required_parameter (identifier) @variable.parameter) -(optional_parameter (identifier) @variable.parameter) - -; Punctuation - -[ - ":" -] @punctuation.delimiter - -(optional_parameter "?" @punctuation.special) -(property_signature "?" @punctuation.special) - -(conditional_type ["?" ":"] @operator) - -; Keywords - -[ - "abstract" - "declare" - "export" - "infer" - "implements" - "keyof" - "namespace" - "override" -] @keyword - -[ - "type" - "interface" - "enum" -] @keyword.storage.type - -[ - "public" - "private" - "protected" - "readonly" -] @keyword.storage.modifier - -; Types - -(type_identifier) @type -(predefined_type) @type.builtin - -(type_arguments - [ - "<" - ">" - ] @punctuation.bracket) - -(type_parameters - [ - "<" - ">" - ] @punctuation.bracket) - -((identifier) @type - (#match? @type "^[A-Z]")) - -; Literals - -[ - (template_literal_type) -] @string - -; Tokens - -(template_type - "${" @punctuation.special - "}" @punctuation.special) @embedded - -; inherits: ecma +; inherits: _typescript,ecma diff --git a/runtime/queries/typescript/indents.scm b/runtime/queries/typescript/indents.scm index 34db2741d7dd..5b8c8f244a3d 100644 --- a/runtime/queries/typescript/indents.scm +++ b/runtime/queries/typescript/indents.scm @@ -1,7 +1,3 @@ -; inherits: ecma +; See runtime/queries/ecma/README.md for more info. -[ - (enum_declaration) - (interface_declaration) - (object_type) -] @indent +; inherits: _typescript,ecma diff --git a/runtime/queries/typescript/injections.scm b/runtime/queries/typescript/injections.scm index 04328f099e98..5b8c8f244a3d 100644 --- a/runtime/queries/typescript/injections.scm +++ b/runtime/queries/typescript/injections.scm @@ -1 +1,3 @@ -; inherits: ecma +; See runtime/queries/ecma/README.md for more info. + +; inherits: _typescript,ecma diff --git a/runtime/queries/typescript/locals.scm b/runtime/queries/typescript/locals.scm index aa6d6ffdbefb..5b8c8f244a3d 100644 --- a/runtime/queries/typescript/locals.scm +++ b/runtime/queries/typescript/locals.scm @@ -1,2 +1,3 @@ -(required_parameter (identifier) @local.definition) -(optional_parameter (identifier) @local.definition) +; See runtime/queries/ecma/README.md for more info. + +; inherits: _typescript,ecma diff --git a/runtime/queries/typescript/tags.scm b/runtime/queries/typescript/tags.scm index ccae934e7159..5b8c8f244a3d 100644 --- a/runtime/queries/typescript/tags.scm +++ b/runtime/queries/typescript/tags.scm @@ -1,23 +1,3 @@ -(function_signature - name: (identifier) @name) @definition.function +; See runtime/queries/ecma/README.md for more info. -(method_signature - name: (property_identifier) @name) @definition.method - -(abstract_method_signature - name: (property_identifier) @name) @definition.method - -(abstract_class_declaration - name: (type_identifier) @name) @definition.class - -(module - name: (identifier) @name) @definition.module - -(interface_declaration - name: (type_identifier) @name) @definition.interface - -(type_annotation - (type_identifier) @name) @reference.type - -(new_expression - constructor: (identifier) @name) @reference.class +; inherits: _typescript,ecma diff --git a/runtime/queries/typescript/textobjects.scm b/runtime/queries/typescript/textobjects.scm index 57be8b5f4ee8..5b8c8f244a3d 100644 --- a/runtime/queries/typescript/textobjects.scm +++ b/runtime/queries/typescript/textobjects.scm @@ -1,8 +1,3 @@ -; inherits: ecma +; See runtime/queries/ecma/README.md for more info. -[ - (interface_declaration - body:(_) @class.inside) - (type_alias_declaration - value: (_) @class.inside) -] @class.around +; inherits: _typescript,ecma