diff --git a/extension.toml b/extension.toml index 9176247..809e620 100644 --- a/extension.toml +++ b/extension.toml @@ -1,15 +1,15 @@ id = "rescript" name = "ReScript" description = "ReScript support." -version = "0.4.3" +version = "0.5.0" schema_version = 1 authors = ["Karolis Narkevicius "] -repository = "https://github.com/rescript-lang/rescript-zed" +repository = "https://github.com/sigurthor/rescript-zed" [language_servers.rescript-language-server] name = "rescript-language-server" language = "ReScript" [grammars.rescript] -repository = "https://github.com/rescript-lang/tree-sitter-rescript" -commit = "64249e68649c77d3c880e335469b464674ad1cbf" +repository = "https://github.com/sigurthor/tree-sitter-rescript" +commit = "f81040d23a3c2970e467432178043162acabdd34" diff --git a/languages/rescript/highlights.scm b/languages/rescript/highlights.scm index bc40da1..8802bb1 100644 --- a/languages/rescript/highlights.scm +++ b/languages/rescript/highlights.scm @@ -283,6 +283,14 @@ (jsx_fragment [">" "<" "/"] @tag.delimiter) (jsx_attribute (property_identifier) @tag.attribute) + +; Regex literals +;--------------- + +(regex "/" @punctuation.special) +(regex_pattern) @string.special.regex +(regex_flags) @operator + ; Error ;---------- diff --git a/languages/rescript/injections.scm b/languages/rescript/injections.scm index dc8638e..7823df0 100644 --- a/languages/rescript/injections.scm +++ b/languages/rescript/injections.scm @@ -26,3 +26,7 @@ (#eq? @_name "relay") (expression_statement (_ (_) @injection.content (#set! injection.language "graphql") ))) + +; Native regex literals (/pattern/flags) +(regex + (regex_pattern) @injection.content (#set! injection.language "regex")) diff --git a/languages/rescript/outline.scm b/languages/rescript/outline.scm new file mode 100644 index 0000000..857b5d2 --- /dev/null +++ b/languages/rescript/outline.scm @@ -0,0 +1,76 @@ +; Let declarations, e.g. `let foo = 42` +(let_declaration +["let" "export"] @context +(let_binding +pattern: (_) @name) @item) + +; Recursive let declarations, e.g. `let rec fib = n => ...` +(let_declaration +["let" "export"] @context +"rec" @context +(let_binding +pattern: (_) @name) @item) + +; Type declarations, e.g. `type t = int` +(type_declaration +"type" @context +(type_binding +name: (_) @name) @item) + +; Recursive type declarations, e.g. `type rec tree<'a> = ...` +(type_declaration +"type" @context +"rec" @context +(type_binding +name: (_) @name) @item) + +; Exported type declarations, e.g. `export type t = int` +(type_declaration +"export" @context +"type" @context +(type_binding +name: (_) @name) @item) + +; Module declarations, e.g. `module Foo = { ... }` +(module_declaration +"module" @context +(module_binding +name: (_) @name) @item) + +; Recursive module declarations +(module_declaration +"module" @context +"rec" @context +(module_binding +name: (_) @name) @item) + +; Module type declarations +(module_declaration +"module" @context +"type" @context +(module_binding +name: (_) @name) @item) + +; External declarations +(external_declaration +"external" @context +(value_identifier) @name) @item + +; Exception declarations +(exception_declaration +"exception" @context +(variant_identifier) @name) @item + +; Open statements +(open_statement +"open" @context +(_) @name) @item + +; Include statements +(include_statement +"include" @context +(_) @name) @item + +; Variant declarations inside type bodies +(variant_declaration +(variant_identifier) @name) @item