on master help sign in
Refactor queries for ecma based languages (#7207)
commit607b426e269b17f4ad32dca9c612c4a9f8541766 authorGammut <metaskopia@gmail.com> dateSun 9 Jul 2023, 11:35 (3 years ago) parent28452e1
38 files changed+492−305
languages.toml−3 runtime/queries/_javascript/highlights.scm+36 runtime/queries/_javascript/locals.scm+14 runtime/queries/_javascript/tags.scm+88 runtime/queries/_jsx/highlights.scm+55 runtime/queries/_jsx/indents.scm+7 runtime/queries/_typescript/highlights.scm+139 runtime/queries/_typescript/indents.scm+5 runtime/queries/_typescript/locals.scm+16 runtime/queries/_typescript/tags.scm+23 runtime/queries/_typescript/textobjects.scm+6 runtime/queries/ecma/README.md+14 runtime/queries/ecma/highlights.scm+8−1 runtime/queries/ecma/locals.scm+17−3 runtime/queries/javascript/highlights.scm+2−37 runtime/queries/javascript/indents.scm+3−1 runtime/queries/javascript/injections.scm+3−1 runtime/queries/javascript/locals.scm+3−1 runtime/queries/javascript/tags.scm+2−87 runtime/queries/javascript/textobjects.scm+3−1 runtime/queries/jsx/highlights.scm+2−36 runtime/queries/jsx/indents.scm+2−8 runtime/queries/jsx/injections.scm+3−1 runtime/queries/jsx/locals.scm+3−1 runtime/queries/jsx/tags.scm+3 runtime/queries/jsx/textobjects.scm+3−1 runtime/queries/tsx/highlights.scm+3−1 runtime/queries/tsx/indents.scm+3−1 runtime/queries/tsx/injections.scm+3−1 runtime/queries/tsx/locals.scm+3 runtime/queries/tsx/tags.scm+3 runtime/queries/tsx/textobjects.scm+3−1 runtime/queries/typescript/highlights.scm+2−81 runtime/queries/typescript/indents.scm+2−6 runtime/queries/typescript/injections.scm+3−1 runtime/queries/typescript/locals.scm+3−2 runtime/queries/typescript/tags.scm+2−22 runtime/queries/typescript/textobjects.scm+2−7
languages.toml−3
@@ -524,7 +524,6 @@ file-types = ["js", "mjs", "cjs"]
524524shebangs = ["node"]
525525roots = []
526526comment-token = "//"
527−# TODO: highlights-params
528527language-servers = [ "typescript-language-server" ]
529528indent = { tab-width = 2, unit = " " }
530529
@@ -564,7 +563,6 @@ file-types = ["ts", "mts", "cts"]
564563language-id = "typescript"
565564shebangs = []
566565roots = []
567−# TODO: highlights-params
568566language-servers = [ "typescript-language-server" ]
569567indent = { tab-width = 2, unit = " " }
570568
@@ -579,7 +577,6 @@ injection-regex = "(tsx)" # |typescript
579577language-id = "typescriptreact"
580578file-types = ["tsx"]
581579roots = []
582−# TODO: highlights-params
583580language-servers = [ "typescript-language-server" ]
584581indent = { tab-width = 2, unit = " " }
585582
runtime/queries/_javascript/highlights.scmnew file+36
@@ -0,0 +1,36 @@
1+; Function and method parameters
2+;-------------------------------
3+
4+; Javascript and Typescript Treesitter grammars deviate when defining the
5+; tree structure for parameters, so we need to address them in each specific
6+; language instead of ecma.
7+
8+; (p)
9+(formal_parameters
10+ (identifier) @variable.parameter)
11+
12+; (...p)
13+(formal_parameters
14+ (rest_pattern
15+ (identifier) @variable.parameter))
16+
17+; ({ p })
18+(formal_parameters
19+ (object_pattern
20+ (shorthand_property_identifier_pattern) @variable.parameter))
21+
22+; ({ a: p })
23+(formal_parameters
24+ (object_pattern
25+ (pair_pattern
26+ value: (identifier) @variable.parameter)))
27+
28+; ([ p ])
29+(formal_parameters
30+ (array_pattern
31+ (identifier) @variable.parameter))
32+
33+; (p = 1)
34+(formal_parameters
35+ (assignment_pattern
36+ left: (identifier) @variable.parameter))
runtime/queries/_javascript/locals.scmnew file+14
@@ -0,0 +1,14 @@
1+; Definitions
2+;------------
3+; Javascript and Typescript Treesitter grammars deviate when defining the
4+; tree structure for parameters, so we need to address them in each specific
5+; language instead of ecma.
6+
7+; (i)
8+(formal_parameters
9+ (identifier) @local.definition)
10+
11+; (i = 1)
12+(formal_parameters
13+ (assignment_pattern
14+ left: (identifier) @local.definition))
runtime/queries/_javascript/tags.scmnew file+88
@@ -0,0 +1,88 @@
1+(
2+ (comment)* @doc
3+ .
4+ (method_definition
5+ name: (property_identifier) @name) @definition.method
6+ (#not-eq? @name "constructor")
7+ (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
8+ (#select-adjacent! @doc @definition.method)
9+)
10+
11+(
12+ (comment)* @doc
13+ .
14+ [
15+ (class
16+ name: (_) @name)
17+ (class_declaration
18+ name: (_) @name)
19+ ] @definition.class
20+ (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
21+ (#select-adjacent! @doc @definition.class)
22+)
23+
24+(
25+ (comment)* @doc
26+ .
27+ [
28+ (function
29+ name: (identifier) @name)
30+ (function_declaration
31+ name: (identifier) @name)
32+ (generator_function
33+ name: (identifier) @name)
34+ (generator_function_declaration
35+ name: (identifier) @name)
36+ ] @definition.function
37+ (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
38+ (#select-adjacent! @doc @definition.function)
39+)
40+
41+(
42+ (comment)* @doc
43+ .
44+ (lexical_declaration
45+ (variable_declarator
46+ name: (identifier) @name
47+ value: [(arrow_function) (function)]) @definition.function)
48+ (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
49+ (#select-adjacent! @doc @definition.function)
50+)
51+
52+(
53+ (comment)* @doc
54+ .
55+ (variable_declaration
56+ (variable_declarator
57+ name: (identifier) @name
58+ value: [(arrow_function) (function)]) @definition.function)
59+ (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
60+ (#select-adjacent! @doc @definition.function)
61+)
62+
63+(assignment_expression
64+ left: [
65+ (identifier) @name
66+ (member_expression
67+ property: (property_identifier) @name)
68+ ]
69+ right: [(arrow_function) (function)]
70+) @definition.function
71+
72+(pair
73+ key: (property_identifier) @name
74+ value: [(arrow_function) (function)]) @definition.function
75+
76+(
77+ (call_expression
78+ function: (identifier) @name) @reference.call
79+ (#not-match? @name "^(require)$")
80+)
81+
82+(call_expression
83+ function: (member_expression
84+ property: (property_identifier) @name)
85+ arguments: (_) @reference.call)
86+
87+(new_expression
88+ constructor: (_) @name) @reference.class
runtime/queries/_jsx/highlights.scmnew file+55
@@ -0,0 +1,55 @@
1+; Opening elements
2+; ----------------
3+
4+(jsx_opening_element ((identifier) @constructor
5+ (#match? @constructor "^[A-Z]")))
6+
7+; Handle the dot operator effectively - <My.Component>
8+(jsx_opening_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
9+
10+(jsx_opening_element (identifier) @tag)
11+
12+; Closing elements
13+; ----------------
14+
15+(jsx_closing_element ((identifier) @constructor
16+ (#match? @constructor "^[A-Z]")))
17+
18+; Handle the dot operator effectively - </My.Component>
19+(jsx_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
20+
21+(jsx_closing_element (identifier) @tag)
22+
23+; Self-closing elements
24+; ---------------------
25+
26+(jsx_self_closing_element ((identifier) @constructor
27+ (#match? @constructor "^[A-Z]")))
28+
29+; Handle the dot operator effectively - <My.Component />
30+(jsx_self_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
31+
32+(jsx_self_closing_element (identifier) @tag)
33+
34+; Attributes
35+; ----------
36+
37+(jsx_attribute (property_identifier) @variable.other.member)
38+
39+; Punctuation
40+; -----------
41+
42+; Handle attribute delimiter
43+(jsx_attribute "=" @punctuation.delimiter)
44+
45+; <Component>
46+(jsx_opening_element ["<" ">"] @punctuation.bracket)
47+
48+; </Component>
49+(jsx_closing_element ["<" "/" ">"] @punctuation.bracket)
50+
51+; <Component />
52+(jsx_self_closing_element ["<" "/" ">"] @punctuation.bracket)
53+
54+; <> ... </>
55+(jsx_fragment ["<" "/" ">"] @punctuation.bracket)
runtime/queries/_jsx/indents.scmnew file+7
@@ -0,0 +1,7 @@
1+[
2+ (jsx_fragment)
3+ (jsx_element)
4+ (jsx_self_closing_element)
5+] @indent
6+
7+(parenthesized_expression) @indent
runtime/queries/_typescript/highlights.scmnew file+139
@@ -0,0 +1,139 @@
1+; Namespaces
2+; ----------
3+
4+(internal_module
5+ [((identifier) @namespace) ((nested_identifier (identifier) @namespace))])
6+
7+(ambient_declaration "global" @namespace)
8+
9+; Parameters
10+; ----------
11+; Javascript and Typescript Treesitter grammars deviate when defining the
12+; tree structure for parameters, so we need to address them in each specific
13+; language instead of ecma.
14+
15+; (p: t)
16+; (p: t = 1)
17+(required_parameter
18+ (identifier) @variable.parameter)
19+
20+; (...p: t)
21+(required_parameter
22+ (rest_pattern
23+ (identifier) @variable.parameter))
24+
25+; ({ p }: { p: t })
26+(required_parameter
27+ (object_pattern
28+ (shorthand_property_identifier_pattern) @variable.parameter))
29+
30+; ({ a: p }: { a: t })
31+(required_parameter
32+ (object_pattern
33+ (pair_pattern
34+ value: (identifier) @variable.parameter)))
35+
36+; ([ p ]: t[])
37+(required_parameter
38+ (array_pattern
39+ (identifier) @variable.parameter))
40+
41+; (p?: t)
42+; (p?: t = 1) // Invalid but still posible to hihglight.
43+(optional_parameter
44+ (identifier) @variable.parameter)
45+
46+; (...p?: t) // Invalid but still posible to hihglight.
47+(optional_parameter
48+ (rest_pattern
49+ (identifier) @variable.parameter))
50+
51+; ({ p }: { p?: t})
52+(optional_parameter
53+ (object_pattern
54+ (shorthand_property_identifier_pattern) @variable.parameter))
55+
56+; ({ a: p }: { a?: t })
57+(optional_parameter
58+ (object_pattern
59+ (pair_pattern
60+ value: (identifier) @variable.parameter)))
61+
62+; ([ p ]?: t[]) // Invalid but still posible to hihglight.
63+(optional_parameter
64+ (array_pattern
65+ (identifier) @variable.parameter))
66+
67+; Punctuation
68+; -----------
69+
70+[
71+ ":"
72+] @punctuation.delimiter
73+
74+(optional_parameter "?" @punctuation.special)
75+(property_signature "?" @punctuation.special)
76+
77+(conditional_type ["?" ":"] @operator)
78+
79+; Keywords
80+; --------
81+
82+[
83+ "abstract"
84+ "declare"
85+ "export"
86+ "infer"
87+ "implements"
88+ "keyof"
89+ "namespace"
90+ "override"
91+] @keyword
92+
93+[
94+ "type"
95+ "interface"
96+ "enum"
97+] @keyword.storage.type
98+
99+[
100+ "public"
101+ "private"
102+ "protected"
103+ "readonly"
104+] @keyword.storage.modifier
105+
106+; Types
107+; -----
108+
109+(type_identifier) @type
110+(predefined_type) @type.builtin
111+
112+; Type arguments and parameters
113+; -----------------------------
114+
115+(type_arguments
116+ [
117+ "<"
118+ ">"
119+ ] @punctuation.bracket)
120+
121+(type_parameters
122+ [
123+ "<"
124+ ">"
125+ ] @punctuation.bracket)
126+
127+; Literals
128+; --------
129+
130+[
131+ (template_literal_type)
132+] @string
133+
134+; Tokens
135+; ------
136+
137+(template_type
138+ "${" @punctuation.special
139+ "}" @punctuation.special) @embedded
runtime/queries/_typescript/indents.scmnew file+5
@@ -0,0 +1,5 @@
1+[
2+ (enum_declaration)
3+ (interface_declaration)
4+ (object_type)
5+] @indent
runtime/queries/_typescript/locals.scmnew file+16
@@ -0,0 +1,16 @@
1+; Definitions
2+;------------
3+
4+; Javascript and Typescript Treesitter grammars deviate when defining the
5+; tree structure for parameters, so we need to address them in each specific
6+; language instead of ecma.
7+
8+; (i: t)
9+; (i: t = 1)
10+(required_parameter
11+ (identifier) @local.definition)
12+
13+; (i?: t)
14+; (i?: t = 1) // Invalid but still posible to hihglight.
15+(optional_parameter
16+ (identifier) @local.definition)
runtime/queries/_typescript/tags.scmnew file+23
@@ -0,0 +1,23 @@
1+(function_signature
2+ name: (identifier) @name) @definition.function
3+
4+(method_signature
5+ name: (property_identifier) @name) @definition.method
6+
7+(abstract_method_signature
8+ name: (property_identifier) @name) @definition.method
9+
10+(abstract_class_declaration
11+ name: (type_identifier) @name) @definition.class
12+
13+(module
14+ name: (identifier) @name) @definition.module
15+
16+(interface_declaration
17+ name: (type_identifier) @name) @definition.interface
18+
19+(type_annotation
20+ (type_identifier) @name) @reference.type
21+
22+(new_expression
23+ constructor: (identifier) @name) @reference.class
runtime/queries/_typescript/textobjects.scmnew file+6
@@ -0,0 +1,6 @@
1+[
2+ (interface_declaration
3+ body:(_) @class.inside)
4+ (type_alias_declaration
5+ value: (_) @class.inside)
6+] @class.around
runtime/queries/ecma/README.mdnew file+14
@@ -0,0 +1,14 @@
1+# Inheritance model for ecma-based languages
2+
3+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.
4+
5+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.
6+
7+| Language | Inherits from |
8+| ---------- | ----------------------- |
9+| javascript | _javascript, ecma |
10+| jsx | _jsx, _javascript, ecma |
11+| typescript | _typescript, ecma |
12+| tsx | _jsx, _typescript, ecma |
13+
14+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.
runtime/queries/ecma/highlights.scm+8−1
@@ -46,8 +46,15 @@
4646(assignment_expression
4747 left: (identifier) @function
4848 right: [(function) (arrow_function)])
49−
5049
50+; Function and method parameters
51+;-------------------------------
52+
53+; Arrow function parameters in the form `p => ...` are supported by both
54+; javascript and typescript grammars without conflicts.
55+(arrow_function
56+ parameter: (identifier) @variable.parameter)
57+
5158; Function and method calls
5259;--------------------------
5360
runtime/queries/ecma/locals.scm+17−3
@@ -12,14 +12,28 @@
1212; Definitions
1313;------------
1414
15−(pattern/identifier) @local.definition
15+; ...i
16+(rest_pattern
17+ (identifier) @local.definition)
18+
19+; { i }
20+(object_pattern
21+ (shorthand_property_identifier_pattern) @local.definition)
1622
17−(pattern/rest_pattern
23+; { a: i }
24+(object_pattern
25+ (pair_pattern
26+ value: (identifier) @local.definition))
27+
28+; [ i ]
29+(array_pattern
1830 (identifier) @local.definition)
19−
31+
32+; i => ...
2033(arrow_function
2134 parameter: (identifier) @local.definition)
2235
36+; const/let/var i = ...
2337(variable_declarator
2438 name: (identifier) @local.definition)
2539
runtime/queries/javascript/highlights.scm+2−37
@@ -1,38 +1,3 @@
1−; Function and method parameters
2−;-------------------------------
1+; See runtime/queries/ecma/README.md for more info.
32
4−; (p) => ...
5−(formal_parameters
6− (identifier) @variable.parameter)
7−
8−; (...p) => ...
9−(formal_parameters
10− (rest_pattern
11− (identifier) @variable.parameter))
12−
13−; ({ p }) => ...
14−(formal_parameters
15− (object_pattern
16− (shorthand_property_identifier_pattern) @variable.parameter))
17−
18−; ({ a: p }) => ...
19−(formal_parameters
20− (object_pattern
21− (pair_pattern
22− value: (identifier) @variable.parameter)))
23−
24−; ([ p ]) => ...
25−(formal_parameters
26− (array_pattern
27− (identifier) @variable.parameter))
28−
29−; (p = 1) => ...
30−(formal_parameters
31− (assignment_pattern
32− left: (identifier) @variable.parameter))
33−
34−; p => ...
35−(arrow_function
36− parameter: (identifier) @variable.parameter)
37−
38−; inherits: ecma
3+; inherits: _javascript,ecma
runtime/queries/javascript/indents.scm+3−1
@@ -1 +1,3 @@
1−; inherits: ecma
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _javascript,ecma
runtime/queries/javascript/injections.scm+3−1
@@ -1 +1,3 @@
1−; inherits: ecma
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _javascript,ecma
runtime/queries/javascript/locals.scm+3−1
@@ -1 +1,3 @@
1−; inherits: ecma
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _javascript,ecma
runtime/queries/javascript/tags.scm+2−87
@@ -1,88 +1,3 @@
1−(
2− (comment)* @doc
3− .
4− (method_definition
5− name: (property_identifier) @name) @definition.method
6− (#not-eq? @name "constructor")
7− (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
8− (#select-adjacent! @doc @definition.method)
9−)
1+; See runtime/queries/ecma/README.md for more info.
102
11−(
12− (comment)* @doc
13− .
14− [
15− (class
16− name: (_) @name)
17− (class_declaration
18− name: (_) @name)
19− ] @definition.class
20− (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
21− (#select-adjacent! @doc @definition.class)
22−)
23−
24−(
25− (comment)* @doc
26− .
27− [
28− (function
29− name: (identifier) @name)
30− (function_declaration
31− name: (identifier) @name)
32− (generator_function
33− name: (identifier) @name)
34− (generator_function_declaration
35− name: (identifier) @name)
36− ] @definition.function
37− (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
38− (#select-adjacent! @doc @definition.function)
39−)
40−
41−(
42− (comment)* @doc
43− .
44− (lexical_declaration
45− (variable_declarator
46− name: (identifier) @name
47− value: [(arrow_function) (function)]) @definition.function)
48− (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
49− (#select-adjacent! @doc @definition.function)
50−)
51−
52−(
53− (comment)* @doc
54− .
55− (variable_declaration
56− (variable_declarator
57− name: (identifier) @name
58− value: [(arrow_function) (function)]) @definition.function)
59− (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
60− (#select-adjacent! @doc @definition.function)
61−)
62−
63−(assignment_expression
64− left: [
65− (identifier) @name
66− (member_expression
67− property: (property_identifier) @name)
68− ]
69− right: [(arrow_function) (function)]
70−) @definition.function
71−
72−(pair
73− key: (property_identifier) @name
74− value: [(arrow_function) (function)]) @definition.function
75−
76−(
77− (call_expression
78− function: (identifier) @name) @reference.call
79− (#not-match? @name "^(require)$")
80−)
81−
82−(call_expression
83− function: (member_expression
84− property: (property_identifier) @name)
85− arguments: (_) @reference.call)
86−
87−(new_expression
88− constructor: (_) @name) @reference.class
3+; inherits: _javascript,ecma
runtime/queries/javascript/textobjects.scm+3−1
@@ -1 +1,3 @@
1−; inherits: ecma
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _javascript,ecma
runtime/queries/jsx/highlights.scm+2−36
@@ -1,37 +1,3 @@
1−; Highlight component names differently
2−(jsx_opening_element ((identifier) @constructor
3− (#match? @constructor "^[A-Z]")))
1+; See runtime/queries/ecma/README.md for more info.
42
5−; Handle the dot operator effectively - <My.Component>
6−(jsx_opening_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
7−
8−; Highlight brackets differently
9−(jsx_opening_element ["<" ">"] @punctuation.bracket)
10−
11−(jsx_closing_element ((identifier) @constructor
12− (#match? @constructor "^[A-Z]")))
13−
14−; Handle the dot operator effectively - </My.Component>
15−(jsx_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
16−
17−; Highlight brackets differently
18−(jsx_closing_element ["<" "/" ">"] @punctuation.bracket)
19−
20−(jsx_self_closing_element ((identifier) @constructor
21− (#match? @constructor "^[A-Z]")))
22−
23−; Handle the dot operator effectively - <My.Component />
24−(jsx_self_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
25−
26−; Highlight brackets differently
27−(jsx_self_closing_element ["<" "/" ">"] @punctuation.bracket)
28−
29−; Handle attribute delimiter
30−(jsx_attribute "=" @punctuation.delimiter)
31−
32−(jsx_opening_element (identifier) @tag)
33−(jsx_closing_element (identifier) @tag)
34−(jsx_self_closing_element (identifier) @tag)
35−(jsx_attribute (property_identifier) @variable.other.member)
36−
37−; inherits: ecma
3+; inherits: _jsx,_javascript,ecma
runtime/queries/jsx/indents.scm+2−8
@@ -1,9 +1,3 @@
1−[
2− (jsx_fragment)
3− (jsx_element)
4− (jsx_self_closing_element)
5−] @indent
1+; See runtime/queries/ecma/README.md for more info.
62
7−(parenthesized_expression) @indent
8−
9−; inherits: ecma
3+; inherits: _jsx,_javascript,ecma
runtime/queries/jsx/injections.scm+3−1
@@ -1 +1,3 @@
1−; inherits: ecma
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _jsx,_javascript,ecma
runtime/queries/jsx/locals.scm+3−1
@@ -1 +1,3 @@
1−; inherits: ecma
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _jsx,_javascript,ecma
runtime/queries/jsx/tags.scmnew file+3
@@ -0,0 +1,3 @@
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _jsx,_javascript,ecma
runtime/queries/jsx/textobjects.scm+3−1
@@ -1 +1,3 @@
1−; inherits: ecma
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _jsx,_javascript,ecma
runtime/queries/tsx/highlights.scm+3−1
@@ -1 +1,3 @@
1−; inherits: jsx,typescript
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _jsx,_typescript,ecma
runtime/queries/tsx/indents.scm+3−1
@@ -1 +1,3 @@
1−; inherits: typescript,jsx
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _jsx,_typescript,ecma
runtime/queries/tsx/injections.scm+3−1
@@ -1 +1,3 @@
1−; inherits: typescript
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _jsx,_typescript,ecma
runtime/queries/tsx/locals.scmnew file+3
@@ -0,0 +1,3 @@
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _jsx,_typescript,ecma
runtime/queries/tsx/tags.scmnew file+3
@@ -0,0 +1,3 @@
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _jsx,_typescript,ecma
runtime/queries/tsx/textobjects.scm+3−1
@@ -1 +1,3 @@
1−; inherits: typescript,jsx
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _jsx,_typescript,ecma
runtime/queries/typescript/highlights.scm+2−81
@@ -1,82 +1,3 @@
1−; Namespaces
1+; See runtime/queries/ecma/README.md for more info.
22
3−(internal_module
4− [((identifier) @namespace) ((nested_identifier (identifier) @namespace))])
5−
6−(ambient_declaration "global" @namespace)
7−
8−; Variables
9−
10−(required_parameter (identifier) @variable.parameter)
11−(optional_parameter (identifier) @variable.parameter)
12−
13−; Punctuation
14−
15−[
16− ":"
17−] @punctuation.delimiter
18−
19−(optional_parameter "?" @punctuation.special)
20−(property_signature "?" @punctuation.special)
21−
22−(conditional_type ["?" ":"] @operator)
23−
24−; Keywords
25−
26−[
27− "abstract"
28− "declare"
29− "export"
30− "infer"
31− "implements"
32− "keyof"
33− "namespace"
34− "override"
35−] @keyword
36−
37−[
38− "type"
39− "interface"
40− "enum"
41−] @keyword.storage.type
42−
43−[
44− "public"
45− "private"
46− "protected"
47− "readonly"
48−] @keyword.storage.modifier
49−
50−; Types
51−
52−(type_identifier) @type
53−(predefined_type) @type.builtin
54−
55−(type_arguments
56− [
57− "<"
58− ">"
59− ] @punctuation.bracket)
60−
61−(type_parameters
62− [
63− "<"
64− ">"
65− ] @punctuation.bracket)
66−
67−((identifier) @type
68− (#match? @type "^[A-Z]"))
69−
70−; Literals
71−
72−[
73− (template_literal_type)
74−] @string
75−
76−; Tokens
77−
78−(template_type
79− "${" @punctuation.special
80− "}" @punctuation.special) @embedded
81−
82−; inherits: ecma
3+; inherits: _typescript,ecma
runtime/queries/typescript/indents.scm+2−6
@@ -1,7 +1,3 @@
1−; inherits: ecma
1+; See runtime/queries/ecma/README.md for more info.
22
3−[
4− (enum_declaration)
5− (interface_declaration)
6− (object_type)
7−] @indent
3+; inherits: _typescript,ecma
runtime/queries/typescript/injections.scm+3−1
@@ -1 +1,3 @@
1−; inherits: ecma
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _typescript,ecma
runtime/queries/typescript/locals.scm+3−2
@@ -1,2 +1,3 @@
1−(required_parameter (identifier) @local.definition)
2−(optional_parameter (identifier) @local.definition)
1+; See runtime/queries/ecma/README.md for more info.
2+
3+; inherits: _typescript,ecma
runtime/queries/typescript/tags.scm+2−22
@@ -1,23 +1,3 @@
1−(function_signature
2− name: (identifier) @name) @definition.function
1+; See runtime/queries/ecma/README.md for more info.
32
4−(method_signature
5− name: (property_identifier) @name) @definition.method
6−
7−(abstract_method_signature
8− name: (property_identifier) @name) @definition.method
9−
10−(abstract_class_declaration
11− name: (type_identifier) @name) @definition.class
12−
13−(module
14− name: (identifier) @name) @definition.module
15−
16−(interface_declaration
17− name: (type_identifier) @name) @definition.interface
18−
19−(type_annotation
20− (type_identifier) @name) @reference.type
21−
22−(new_expression
23− constructor: (identifier) @name) @reference.class
3+; inherits: _typescript,ecma
runtime/queries/typescript/textobjects.scm+2−7
@@ -1,8 +1,3 @@
1−; inherits: ecma
1+; See runtime/queries/ecma/README.md for more info.
22
3−[
4− (interface_declaration
5− body:(_) @class.inside)
6− (type_alias_declaration
7− value: (_) @class.inside)
8−] @class.around
3+; inherits: _typescript,ecma