diff --git a/CHANGELOG.md b/CHANGELOG.md index fac0814d9..fc9645b42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,9 @@ - Highlight tagged template literal functions as functions. https://github.com/rescript-lang/rescript-vscode/pull/920 - Complete for `type t` values when encountering a `type t` in relevant scenarios. https://github.com/rescript-lang/rescript-vscode/pull/924 - Highlight escaped sequences as a whole and not only the first character. https://github.com/rescript-lang/rescript-vscode/pull/929 -- Start highlighting escaped sequences in template literals. https://github.com/rescript-lang/rescript-vscode/pull/929 +- Highlight escaped sequences in template strings. https://github.com/rescript-lang/rescript-vscode/pull/929 +- Highlight trailing backslash for multi-line strings. https://github.com/rescript-lang/rescript-vscode/pull/929 +- Highlight comments, `int`, `float`, `bool`, and `char` values inside of embeded expressions in template strings. https://github.com/rescript-lang/rescript-vscode/pull/930 ## 1.38.0 diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index 5990a9476..cb8001fec 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -119,84 +119,87 @@ } ] }, + "expression": { + "patterns": [ + { "include": "#constant" }, + { "include": "#bracketAccess" }, + { "include": "#string" }, + { "include": "#number" }, + { "include": "#character" } + ] + }, "string-character-escape": { "name": "constant.character.escape", "match": "\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u{[0-9A-Fa-f]+}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)" }, - "string": { + "string-double-quoted": { + "name": "string.quoted.double", + "begin": "\"", + "end": "\"", + "beginCaptures": { + "1": { + "name": "punctuation.definition.string.begin" + } + }, + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end" + } + }, "patterns": [ { - "name": "string.quoted.double", - "begin": "\"", - "end": "\"", - "beginCaptures": { - "1": { - "name": "punctuation.definition.string.begin" - } - }, - "endCaptures": { - "1": { - "name": "punctuation.definition.string.end" - } - }, - "patterns": [ - { - "include": "#string-character-escape" - } - ] + "include": "#string-character-escape" + } + ] + }, + "template": { + "name": "string.template", + "begin": "([a-z_][0-9a-zA-Z_]*)?(`)", + "end": "(?<!\\\\)`", + "beginCaptures": { + "1": { + "name": "entity.name.function" }, - { - "name": "string.template", - "begin": "([a-z_][0-9a-zA-Z_]*)?(`)", - "end": "(?<!\\\\)`", - "beginCaptures": { - "1": { - "name": "entity.name.function" - }, - "2": { - "name": "punctuation.definition.string.template.begin" - } - }, - "endCaptures": { - "1": { - "name": "punctuation.definition.string.template.end" - } - }, - "patterns": [ - { - "include": "#string-character-escape" - }, - { - "name": "meta.template.expression", - "begin": "\\$\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.template-expression.begin" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.template-expression.end" - } - }, - "patterns": [ - { - "match": "[a-z_][0-9a-zA-Z_]*" - }, - { - "include": "#operator" - }, - { - "include": "#punctuations" - }, - { - "include": "#string" - } - ] - } - ] + "2": { + "name": "punctuation.definition.string.template.begin" } + }, + "endCaptures": { + "1": { + "name": "punctuation.definition.string.template.end" + } + }, + "patterns": [ + { "include": "#string-character-escape" }, + { "include": "#template-substitution-element" } + ] + }, + "template-substitution-element": { + "name": "meta.template.expression", + "begin": "\\$\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.template-expression.begin" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.template-expression.end" + } + }, + "patterns": [ + { "include": "#commentLine" }, + { "include": "#commentBlock" }, + { "include": "#operator" }, + { "include": "#punctuations" }, + { "include": "#expression" } + ] + }, + "string": { + "patterns": [ + { "include": "#string-double-quoted" }, + { "include": "#template" } ] }, "function": {