on master help sign in
feat(languages): rescript (#1616)
f5b95beJared Ramirez
.gitmodules+4
@@ -222,3 +222,7 @@
222 path = helix-syntax/languages/tree-sitter-twig
222 path = helix-syntax/languages/tree-sitter-twig
223 url = https://github.com/eirabben/tree-sitter-twig.git
223 url = https://github.com/eirabben/tree-sitter-twig.git
224 shallow = true
224 shallow = true
225+[submodule "helix-syntax/languages/tree-sitter-rescript"]
226+ path = helix-syntax/languages/tree-sitter-rescript
227+ url = https://github.com/jaredramirez/tree-sitter-rescript
228+ shallow = true
book/src/generated/lang-support.md+1
@@ -46,6 +46,7 @@
46| python | ✓ | ✓ | ✓ | `pylsp` |
46| python | ✓ | ✓ | ✓ | `pylsp` |
47| racket | | | | `racket` |
47| racket | | | | `racket` |
48| regex | ✓ | | | |
48| regex | ✓ | | | |
49+| rescript | ✓ | ✓ | | `rescript-language-server` |
49| ruby | ✓ | | ✓ | `solargraph` |
50| ruby | ✓ | | ✓ | `solargraph` |
50| rust | ✓ | ✓ | ✓ | `rust-analyzer` |
51| rust | ✓ | ✓ | ✓ | `rust-analyzer` |
51| scala | ✓ | | ✓ | `metals` |
52| scala | ✓ | | ✓ | `metals` |
helix-syntax/languages/tree-sitter-rescriptnew file+1

Submodule changed.

languages.toml+11
@@ -602,3 +602,14 @@ scope = "source.iex"
602injection-regex = "iex"
602injection-regex = "iex"
603file-types = ["iex"]
603file-types = ["iex"]
604roots = []
604roots = []
605+
606+[[language]]
607+name = "rescript"
608+scope = "source.rescript"
609+injection-regex = "rescript"
610+file-types = ["res"]
611+roots = ["bsconfig.json"]
612+auto-format = true
613+comment-token = "//"
614+language-server = { command = "rescript-language-server", args = ["--stdio"] }
615+indent = { tab-width = 2, unit = " " }
runtime/queries/rescript/highlights.scmnew file+179
@@ -0,0 +1,179 @@
1+(comment) @comment
2+
3+; Identifiers
4+;------------
5+
6+; Escaped identifiers like \"+."
7+((value_identifier) @function.macro
8+ (#match? @function.macro "^\\.*$"))
9+
10+[
11+ (type_identifier)
12+ (unit_type)
13+ "list"
14+] @type
15+
16+[
17+ (variant_identifier)
18+ (polyvar_identifier)
19+] @constant
20+
21+(property_identifier) @variable.other.member
22+(module_identifier) @namespace
23+
24+(jsx_identifier) @tag
25+(jsx_attribute (property_identifier) @variable.parameter)
26+
27+; Parameters
28+;----------------
29+
30+(list_pattern (value_identifier) @variable.parameter)
31+(spread_pattern (value_identifier) @variable.parameter)
32+
33+; String literals
34+;----------------
35+
36+[
37+ (string)
38+ (template_string)
39+] @string
40+
41+(template_substitution
42+ "${" @punctuation.bracket
43+ "}" @punctuation.bracket) @embedded
44+
45+(character) @constant.character
46+(escape_sequence) @constant.character.escape
47+
48+; Other literals
49+;---------------
50+
51+[
52+ (true)
53+ (false)
54+] @constant.builtin
55+
56+(number) @constant.numeric
57+(polyvar) @constant
58+(polyvar_string) @constant
59+
60+; Functions
61+;----------
62+
63+[
64+ (formal_parameters (value_identifier))
65+ (positional_parameter (value_identifier))
66+ (labeled_parameter (value_identifier))
67+] @variable.parameter
68+
69+(function parameter: (value_identifier) @variable.parameter)
70+
71+; Meta
72+;-----
73+
74+[
75+ "@"
76+ "@@"
77+ (decorator_identifier)
78+] @label
79+
80+(extension_identifier) @keyword
81+("%") @keyword
82+
83+; Misc
84+;-----
85+
86+(subscript_expression index: (string) @variable.other.member)
87+(polyvar_type_pattern "#" @constant)
88+
89+[
90+ ("include")
91+ ("open")
92+] @keyword
93+
94+[
95+ "as"
96+ "export"
97+ "external"
98+ "let"
99+ "module"
100+ "mutable"
101+ "private"
102+ "rec"
103+ "type"
104+ "and"
105+] @keyword
106+
107+[
108+ "if"
109+ "else"
110+ "switch"
111+] @keyword
112+
113+[
114+ "exception"
115+ "try"
116+ "catch"
117+ "raise"
118+] @keyword
119+
120+[
121+ "."
122+ ","
123+ "|"
124+] @punctuation.delimiter
125+
126+[
127+ "++"
128+ "+"
129+ "+."
130+ "-"
131+ "-."
132+ "*"
133+ "*."
134+ "/"
135+ "/."
136+ "<"
137+ "<="
138+ "=="
139+ "==="
140+ "!"
141+ "!="
142+ "!=="
143+ ">"
144+ ">="
145+ "&&"
146+ "||"
147+ "="
148+ ":="
149+ "->"
150+ "|>"
151+ ":>"
152+ (uncurry)
153+] @operator
154+
155+[
156+ "("
157+ ")"
158+ "{"
159+ "}"
160+ "["
161+ "]"
162+] @punctuation.bracket
163+
164+(polyvar_type
165+ [
166+ "["
167+ "[>"
168+ "[<"
169+ "]"
170+ ] @punctuation.bracket)
171+
172+[
173+ "~"
174+ "?"
175+ "=>"
176+ "..."
177+] @punctuation
178+
179+(ternary_expression ["?" ":"] @operator)
runtime/queries/rescript/injections.scmnew file+8
@@ -0,0 +1,8 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))
3+
4+((raw_js) @injection.content
5+ (#set! injection.language "javascript"))
6+
7+((raw_gql) @injection.content
8+ (#set! injection.language "graphql"))
runtime/queries/rescript/textobjects.scmnew file+9
@@ -0,0 +1,9 @@
1+; Classes (modules)
2+;------------------
3+
4+(module_declaration definition: ((_) @class.inside)) @class.around
5+
6+; Functions
7+;----------
8+
9+(function body: (_) @function.inside) @function.around