on master help sign in
Upgrade rescript tree sitter & highlights (#4356)
de60783Jared Ramirez
languages.toml+1−1
@@ -1140,7 +1140,7 @@ indent = { tab-width = 2, unit = " " }
1140
1140
1141[[grammar]]
1141[[grammar]]
1142name = "rescript"
1142name = "rescript"
1143−source = { git = "https://github.com/jaredramirez/tree-sitter-rescript", rev = "4cd7ba91696886fdaca086fb32b5fd8cc294a129" }
1143+source = { git = "https://github.com/jaredramirez/tree-sitter-rescript", rev = "65609807c628477f3b94052e7ef895885ac51c3c" }
1144
1144
1145[[language]]
1145[[language]]
1146name = "erlang"
1146name = "erlang"
runtime/queries/rescript/highlights.scm+63−21
@@ -10,20 +10,23 @@
10[
10[
11 (type_identifier)
11 (type_identifier)
12 (unit_type)
12 (unit_type)
13− "list"
14] @type
13] @type
15
14
15+(list ["list{" "}"] @type)
16+(list_pattern ["list{" "}"] @type)
17+
16[
18[
17 (variant_identifier)
19 (variant_identifier)
18 (polyvar_identifier)
20 (polyvar_identifier)
19−] @constant
21+] @constructor
20
22
23+(record_type_field (property_identifier) @type)
24+(object_type (field (property_identifier) @type))
25+(record_field (property_identifier) @variable.other.member)
26+(object (field (property_identifier) @variable.other.member))
21−(property_identifier) @variable.other.member
27+(member_expression (property_identifier) @variable.other.member)
22(module_identifier) @namespace
28(module_identifier) @namespace
23
29
24−(jsx_identifier) @tag
25−(jsx_attribute (property_identifier) @variable.parameter)
26−
27; Parameters
30; Parameters
28;----------------
31;----------------
29
32
@@ -42,8 +45,8 @@
42 "${" @punctuation.bracket
45 "${" @punctuation.bracket
43 "}" @punctuation.bracket) @embedded
46 "}" @punctuation.bracket) @embedded
44
47
45−(character) @constant.character
48+(character) @string.special
46−(escape_sequence) @constant.character.escape
49+(escape_sequence) @string.special
47
50
48; Other literals
51; Other literals
49;---------------
52;---------------
@@ -60,11 +63,13 @@
60; Functions
63; Functions
61;----------
64;----------
62
65
66+; parameter(s) in parens
63[
67[
64− (formal_parameters (value_identifier))
68+ (parameter (value_identifier))
65 (labeled_parameter (value_identifier))
69 (labeled_parameter (value_identifier))
66] @variable.parameter
70] @variable.parameter
67
71
72+; single parameter with no parens
68(function parameter: (value_identifier) @variable.parameter)
73(function parameter: (value_identifier) @variable.parameter)
69
74
70; Meta
75; Meta
@@ -74,7 +79,7 @@
74 "@"
79 "@"
75 "@@"
80 "@@"
76 (decorator_identifier)
81 (decorator_identifier)
77−] @label
82+] @keyword.directive
78
83
79(extension_identifier) @keyword
84(extension_identifier) @keyword
80("%") @keyword
85("%") @keyword
@@ -82,13 +87,13 @@
82; Misc
87; Misc
83;-----
88;-----
84
89
85−(subscript_expression index: (string) @variable.other.member)
90+; (subscript_expression index: (string) @attribute)
86(polyvar_type_pattern "#" @constant)
91(polyvar_type_pattern "#" @constant)
87
92
88[
93[
89 ("include")
94 ("include")
90 ("open")
95 ("open")
91−] @keyword
96+] @keyword.control.import
92
97
93[
98[
94 "as"
99 "as"
@@ -96,25 +101,43 @@
96 "external"
101 "external"
97 "let"
102 "let"
98 "module"
103 "module"
99− "mutable"
100 "private"
104 "private"
101 "rec"
105 "rec"
102 "type"
106 "type"
103 "and"
107 "and"
108+ "assert"
109+ "async"
110+ "await"
111+ "with"
112+ "unpack"
104−] @keyword
113+] @keyword.storage.type
114+
115+"mutable" @keyword.storage.modifier
105
116
106[
117[
107 "if"
118 "if"
108 "else"
119 "else"
109 "switch"
120 "switch"
121+ "when"
110−] @keyword
122+] @keyword.control.conditional
111
123
112[
124[
113 "exception"
125 "exception"
114 "try"
126 "try"
115 "catch"
127 "catch"
116− "raise"
128+] @keyword.control.exception
129+
130+(call_expression
131+ function: (value_identifier) @keyword.control.exception
132+ (#eq? @keyword.control.exception "raise"))
133+
134+[
135+ "for"
136+ "in"
137+ "to"
138+ "downto"
139+ "while"
117−] @keyword
140+] @keyword.control.conditional
118
141
119[
142[
120 "."
143 "."
@@ -129,17 +152,15 @@
129 "-"
152 "-"
130 "-."
153 "-."
131 "*"
154 "*"
155+ "**"
132 "*."
156 "*."
133− "/"
134 "/."
157 "/."
135− "<"
136 "<="
158 "<="
137 "=="
159 "=="
138 "==="
160 "==="
139 "!"
161 "!"
140 "!="
162 "!="
141 "!=="
163 "!=="
142− ">"
143 ">="
164 ">="
144 "&&"
165 "&&"
145 "||"
166 "||"
@@ -151,6 +172,10 @@
151 (uncurry)
172 (uncurry)
152] @operator
173] @operator
153
174
175+; Explicitly enclose these operators with binary_expression
176+; to avoid confusion with JSX tag delimiters
177+(binary_expression ["<" ">" "/"] @operator)
178+
154[
179[
155 "("
180 "("
156 ")"
181 ")"
@@ -172,7 +197,24 @@
172 "~"
197 "~"
173 "?"
198 "?"
174 "=>"
199 "=>"
200+ ".."
175 "..."
201 "..."
176−] @punctuation
202+] @punctuation.special
177
203
178(ternary_expression ["?" ":"] @operator)
204(ternary_expression ["?" ":"] @operator)
205+
206+; JSX
207+;----------
208+(jsx_identifier) @tag
209+(jsx_element
210+ open_tag: (jsx_opening_element ["<" ">"] @punctuation.special))
211+(jsx_element
212+ close_tag: (jsx_closing_element ["<" "/" ">"] @punctuation.special))
213+(jsx_self_closing_element ["/" ">" "<"] @punctuation.special)
214+(jsx_fragment [">" "<" "/"] @punctuation.special)
215+(jsx_attribute (property_identifier) @attribute)
216+
217+; Error
218+;----------
219+
220+(ERROR) @keyword.control.exception
runtime/queries/rescript/injections.scm+1−1
@@ -5,4 +5,4 @@
5 (#set! injection.language "javascript"))
5 (#set! injection.language "javascript"))
6
6
7((raw_gql) @injection.content
7((raw_gql) @injection.content
8− (#set! injection.language "graphql"))
8+ (#set! injection.language "graphql"))
runtime/queries/rescript/locals.scmnew file+7
@@ -0,0 +1,7 @@
1+(switch_expression) @local.scope
2+(if_expression) @local.scope
3+
4+; Definitions
5+;------------
6+(type_declaration) @local.defintion
7+(let_binding) @local.defintion
runtime/queries/rescript/textobjects.scm+97−1
@@ -3,14 +3,110 @@
3
3
4(module_declaration definition: ((_) @class.inside)) @class.around
4(module_declaration definition: ((_) @class.inside)) @class.around
5
5
6+; Blocks
7+;-------
8+
9+(block (_) @function.inside) @function.around
10+
6; Functions
11; Functions
7;----------
12;----------
8
13
9(function body: (_) @function.inside) @function.around
14(function body: (_) @function.inside) @function.around
10
15
16+; Calls
17+;------
18+
19+(call_expression arguments: ((_) @parameter.inside)) @parameter.around
20+
11; Comments
21; Comments
12;---------
22;---------
13
23
14(comment) @comment.inside
24(comment) @comment.inside
15−
16(comment)+ @comment.around
25(comment)+ @comment.around
26+
27+; Parameters
28+;-----------
29+
30+(function parameter: (_) @parameter.inside @parameter.around)
31+
32+(formal_parameters
33+ ","
34+ . (_) @parameter.inside
35+ @parameter.around)
36+(formal_parameters
37+ . (_) @parameter.inside
38+ . ","?
39+ @parameter.around)
40+
41+(arguments
42+ "," @_arguments_start
43+ . (_) @parameter.inside
44+ @parameter.around)
45+(arguments
46+ . (_) @parameter.inside
47+ . ","?
48+ @parameter.around)
49+
50+(function_type_parameters
51+ ","
52+ . (_) @parameter.inside
53+ @parameter.around)
54+(function_type_parameters
55+ . (_) @parameter.inside
56+ . ","?
57+ @parameter.around)
58+
59+(functor_parameters
60+ ","
61+ . (_) @parameter.inside
62+ @parameter.around)
63+(functor_parameters
64+ . (_) @parameter.inside
65+ . ","?
66+ @parameter.around)
67+
68+(type_parameters
69+ ","
70+ . (_) @parameter.inside
71+ @parameter.around)
72+(type_parameters
73+ . (_) @parameter.inside
74+ . ","?
75+ @parameter.around)
76+
77+(type_arguments
78+ ","
79+ . (_) @parameter.inside
80+ @parameter.around)
81+(type_arguments
82+ . (_) @parameter.inside
83+ . ","?
84+ @parameter.around)
85+
86+(decorator_arguments
87+ ","
88+ . (_) @parameter.inside
89+ @parameter.around)
90+(decorator_arguments
91+ . (_) @parameter.inside
92+ . ","?
93+ @parameter.around)
94+
95+(variant_parameters
96+ ","
97+ . (_) @parameter.inside
98+ @parameter.around)
99+(variant_parameters
100+ . (_) @parameter.inside
101+ . ","?
102+ @parameter.around)
103+
104+(polyvar_parameters
105+ ","
106+ . (_) @parameter.inside
107+ @parameter.around)
108+(polyvar_parameters
109+ . (_) @parameter.inside
110+ . ","?
111+ @parameter.around)
112+