diff --git a/extension.toml b/extension.toml index 9176247..c3a764e 100644 --- a/extension.toml +++ b/extension.toml @@ -12,4 +12,4 @@ language = "ReScript" [grammars.rescript] repository = "https://github.com/rescript-lang/tree-sitter-rescript" -commit = "64249e68649c77d3c880e335469b464674ad1cbf" +commit = "5b90cd4e4138b1231a67977303bda47eb608480a" diff --git a/languages/rescript/highlights.scm b/languages/rescript/highlights.scm index bc40da1..3bd8620 100644 --- a/languages/rescript/highlights.scm +++ b/languages/rescript/highlights.scm @@ -1,4 +1,7 @@ -(comment) @comment +[ + (line_comment) + (block_comment) +] @comment ; Identifiers ;------------ @@ -17,6 +20,14 @@ (list_pattern) ] @type +; Dict +(dict "dict" @type.builtin) +(dict_pattern "dict" @type.builtin) +(dict_entry (string) @property) +(dict_pattern_entry (string) @property) +(dict_pattern_entry (value_identifier) @variable.parameter) +(parameter (dict_pattern (dict_pattern_entry (value_identifier) @variable.parameter))) + ((type_identifier) @type.builtin (#any-of? @type.builtin "int" "char" "string" "float" "bool" "unit")) @@ -65,6 +76,8 @@ ] @string +(regex) @string.special + (character) @character (escape_sequence) @string.escape @@ -215,6 +228,9 @@ "**" "*." "/." + "<<" + ">>" + ">>>" "<=" "==" "===" @@ -222,8 +238,12 @@ "!=" "!==" ">=" + "&&&" "&&" + "|||" "||" + "^^^" + "~~~" "=" ":=" "->" @@ -235,8 +255,8 @@ ] @operator ; Explicitly enclose these operators with binary_expression -; to avoid confusion with JSX tag delimiters -(binary_expression ["<" ">" "/"] @operator) +; to avoid confusion with JSX tag delimiters and extension expressions. +(binary_expression ["<" ">" "/" "%"] @operator) [ "(" diff --git a/languages/rescript/injections.scm b/languages/rescript/injections.scm index dc8638e..ab74100 100644 --- a/languages/rescript/injections.scm +++ b/languages/rescript/injections.scm @@ -1,4 +1,11 @@ -((comment) @injection.content (#set! injection.language "comment")) +([ + (line_comment) + (block_comment) +] @injection.content (#set! injection.language "comment")) + +; regex literal +(regex + (regex_pattern) @injection.content (#set! injection.language "regex")) ; %re (extension_expression diff --git a/languages/rescript/textobjects.scm b/languages/rescript/textobjects.scm index 99b05c4..b6fc85e 100644 --- a/languages/rescript/textobjects.scm +++ b/languages/rescript/textobjects.scm @@ -24,7 +24,10 @@ ; Comments ;--------- -(comment) @comment.around +[ + (line_comment) + (block_comment) +] @comment.around ; Parameters ;-----------