Skip to content

Commit a5e799c

Browse files
authored
Merge pull request #4 from humaans/update-rescript-bits
Update rescript bits
2 parents 292268d + 9b85024 commit a5e799c

7 files changed

Lines changed: 233 additions & 59 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[package]
22
name = "zed_rescript"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2021"
55
publish = false
6-
license = "Apache-2.0"
6+
license = "MIT"
77

88
# [lints]
99
# workspace = true
@@ -13,4 +13,4 @@ path = "src/rescript.rs"
1313
crate-type = ["cdylib"]
1414

1515
[dependencies]
16-
zed_extension_api = "0.0.6"
16+
zed_extension_api = "0.1.0"

README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,3 @@ After opening a ReScript file, open Cmd + Shift + P nav and find
3333
And to see the language server logs, open Cmd + Shift + P nav and find
3434

3535
debug: open language server logs
36-
37-
## Known issues
38-
39-
This is the a very early cut of this extension and I have noticed:
40-
41-
- it's very slow to bring up autocomplete
42-
- the syntax partially loses highlighting as you're typing
43-
- the language server crashes quite easily and doesn't restart
44-
45-
We'll look to work through all these issues in the future releases!

extension.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
id = "rescript"
22
name = "ReScript"
33
description = "ReScript support."
4-
version = "0.1.0"
4+
version = "0.2.0"
55
schema_version = 1
66
authors = ["Karolis Narkevicius <hey@kn8.lt>"]
7-
repository = "https://github.com/zed-industries/zed"
7+
repository = "https://github.com/humaans/rescript-zed"
88

99
[language_servers.rescript-language-server]
1010
name = "rescript-language-server"
1111
language = "ReScript"
1212

1313
[grammars.rescript]
1414
repository = "https://github.com/rescript-lang/tree-sitter-rescript"
15-
commit = "49fc8378c3566f7a7dcb1b4a8e50ab3fd7cecc52"
15+
commit = "4606cd81c4c31d1d02390fee530858323410a74c"

languages/rescript/highlights.scm

Lines changed: 104 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,54 @@
77
((value_identifier) @constant.macro
88
(#match? @constant.macro "^\\.*$"))
99

10+
11+
((value_identifier) @variable)
12+
1013
[
1114
(type_identifier)
1215
(unit_type)
1316
(list)
1417
(list_pattern)
1518
] @type
1619

20+
((type_identifier) @type.builtin
21+
(#any-of? @type.builtin
22+
"int" "char" "string" "float" "bool" "unit"))
23+
1724
[
1825
(variant_identifier)
1926
(polyvar_identifier)
20-
] @constant
27+
] @constructor
2128

2229
(record_type_field (property_identifier) @property)
2330
(record_field (property_identifier) @property)
2431
(object (field (property_identifier) @property))
2532
(object_type (field (property_identifier) @property))
26-
(member_expression (property_identifier) @property)
27-
(module_identifier) @namespace
33+
(module_identifier) @module
34+
35+
(member_expression (property_identifier) @variable.member)
36+
37+
(value_identifier_path
38+
(module_identifier)
39+
(value_identifier) @variable)
40+
41+
42+
(record_pattern
43+
(value_identifier_path
44+
(value_identifier) @variable.member))
45+
46+
(record_pattern
47+
(value_identifier) @variable)
48+
49+
(labeled_argument
50+
label: (value_identifier) @variable.parameter)
51+
2852

2953
; Parameters
3054
;----------------
3155

32-
(list_pattern (value_identifier) @parameter)
33-
(spread_pattern (value_identifier) @parameter)
56+
(list_pattern (value_identifier) @variable.parameter)
57+
(spread_pattern (value_identifier) @variable.parameter)
3458

3559
; String literals
3660
;----------------
@@ -40,11 +64,8 @@
4064
(template_string)
4165
] @string
4266

43-
(template_substitution
44-
"${" @punctuation.bracket
45-
"}" @punctuation.bracket) @embedded
4667

47-
(character) @string.special
68+
(character) @character
4869
(escape_sequence) @string.escape
4970

5071
; Other literals
@@ -53,68 +74,102 @@
5374
[
5475
(true)
5576
(false)
56-
] @constant.builtin
77+
] @boolean
5778

5879
(number) @number
59-
(polyvar) @constant
60-
(polyvar_string) @constant
80+
(polyvar) @constructor
81+
(polyvar_string) @constructor
6182

6283
; Functions
6384
;----------
6485

6586
; parameter(s) in parens
66-
[
67-
(parameter (value_identifier))
68-
(labeled_parameter (value_identifier))
69-
] @parameter
87+
88+
(parameter (value_identifier) @variable.parameter)
89+
(labeled_parameter (value_identifier) @variable.parameter)
7090

7191
; single parameter with no parens
72-
(function parameter: (value_identifier) @parameter)
92+
(function parameter: (value_identifier) @variable.parameter)
7393

7494
; first-level descructuring (required for nvim-tree-sitter as it only matches direct
7595
; children and the above patterns do not match destructuring patterns in NeoVim)
76-
(parameter (tuple_pattern (tuple_item_pattern (value_identifier) @parameter)))
77-
(parameter (array_pattern (value_identifier) @parameter))
78-
(parameter (record_pattern (value_identifier) @parameter))
96+
(parameter (tuple_pattern (tuple_item_pattern (value_identifier) @variable.parameter)))
97+
(parameter (array_pattern (value_identifier) @variable.parameter))
98+
(parameter (record_pattern (value_identifier) @variable.parameter))
99+
100+
; function identifier in let binding
101+
(let_binding
102+
pattern: (value_identifier) @function
103+
body: (function))
104+
105+
; function calls
106+
107+
(call_expression
108+
function: (value_identifier_path
109+
_
110+
(value_identifier) @function.call))
111+
112+
(call_expression
113+
function: (value_identifier) @function.call)
114+
115+
; highlight the right-hand side of a pipe operator as a function call
116+
(pipe_expression
117+
_
118+
[(value_identifier_path
119+
_
120+
(value_identifier) @function.call)
121+
(value_identifier) @function.call])
122+
79123

80124
; Meta
81125
;-----
82126

83-
(decorator_identifier) @annotation
127+
(decorator_identifier) @attribute
84128

85129
(extension_identifier) @keyword
86130
("%") @keyword
87131

88132
; Misc
89133
;-----
90134

91-
(subscript_expression index: (string) @property)
92-
(polyvar_type_pattern "#" @constant)
135+
(polyvar_type_pattern "#" @constructor)
136+
137+
[
138+
"include"
139+
"open"
140+
] @keyword.import
141+
142+
143+
[
144+
"private"
145+
"mutable"
146+
"rec"
147+
] @keyword.modifier
93148

94149
[
95-
("include")
96-
("open")
97-
] @include
150+
"type"
151+
] @keyword.type
98152

99153
[
154+
"and"
155+
"with"
100156
"as"
157+
] @keyword.operator
158+
159+
[
101160
"export"
102161
"external"
103162
"let"
104163
"module"
105-
"mutable"
106-
"private"
107-
"rec"
108-
"type"
109-
"and"
110164
"assert"
111165
"await"
112-
"with"
113166
"lazy"
114167
"constraint"
115168
] @keyword
116169

117-
((function "async" @keyword))
170+
(("await") @keyword.coroutine)
171+
172+
((function "async" @keyword.coroutine))
118173

119174
(module_unpack "unpack" @keyword)
120175

@@ -123,30 +178,31 @@
123178
"else"
124179
"switch"
125180
"when"
126-
] @conditional
181+
] @keyword.conditional
127182

128183
[
129184
"exception"
130185
"try"
131186
"catch"
132-
] @exception
187+
] @keyword.exception
133188

134189
(call_expression
135-
function: (value_identifier) @exception
136-
(#eq? @exception "raise"))
190+
function: (value_identifier) @keyword.exception
191+
(#eq? @keyword.exception "raise"))
137192

138193
[
139194
"for"
140195
"in"
141196
"to"
142197
"downto"
143198
"while"
144-
] @repeat
199+
] @keyword.repeat
145200

146201
[
147202
"."
148203
","
149204
"|"
205+
":"
150206
] @punctuation.delimiter
151207

152208
[
@@ -174,6 +230,7 @@
174230
"|>"
175231
":>"
176232
"+="
233+
"=>"
177234
(uncurry)
178235
] @operator
179236

@@ -188,8 +245,16 @@
188245
"}"
189246
"["
190247
"]"
248+
"<"
249+
">"
191250
] @punctuation.bracket
192251

252+
(unit ["(" ")"] @constant.builtin)
253+
254+
(template_substitution
255+
"${" @punctuation.special
256+
"}" @punctuation.special) @none
257+
193258
(polyvar_type
194259
[
195260
"["
@@ -201,12 +266,11 @@
201266
[
202267
"~"
203268
"?"
204-
"=>"
205269
".."
206270
"..."
207271
] @punctuation.special
208272

209-
(ternary_expression ["?" ":"] @operator)
273+
(ternary_expression ["?" ":"] @keyword.conditional.ternary)
210274

211275
; JSX
212276
;----------

languages/rescript/locals.scm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(switch_expression) @scope
2+
3+
; Definitions
4+
;------------
5+
(type_declaration) @definition.type
6+
(let_binding) @definition.var
7+
(module_declaration) @definition.namespace

0 commit comments

Comments
 (0)