diff --git a/grammars/rescript.tmLanguage.json b/grammars/rescript.tmLanguage.json index 542971556..e022865d2 100644 --- a/grammars/rescript.tmLanguage.json +++ b/grammars/rescript.tmLanguage.json @@ -1,6 +1,10 @@ { "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", "name": "ReScript", + "fileTypes": [ + "res", + "resi" + ], "scopeName": "source.rescript", "repository": { "RE_IDENT": { @@ -21,15 +25,6 @@ "name": "constant.language", "match": "\\b(true|false)\\b" }, - "commentLine": { - "match": "//.*", - "name": "comment.line" - }, - "commentBlock": { - "name": "comment.block", - "begin": "/\\*", - "end": "\\*/" - }, "punctuations": { "patterns": [ { @@ -299,32 +294,6 @@ } ] }, - "jsx": { - "patterns": [ - { - "match": "<>||/>" - }, - { - "match": "[:lower:]])", + "comment": "meta.separator", + "beginCaptures": { + "1": { + "name": "markup.inserted constant.language support.property-value entity.name.filename" + }, + "2": { + "name": "keyword.control.less" + } + }, + "patterns": [ + { + "include": "#value-expression-atomic-with-paths" + } + ] + }, + { + "match": "(\\b([[:lower:]][[:word:]]*)\\b[[:space:]]*+)", + "captures": { + "1": { + "comment": "meta.separator" + }, + "2": { + "name": "markup.inserted constant.language support.property-value entity.name.filename" + } + } + } + ] + }, + "jsx-body": { + "begin": "((>))", + "end": "(?=))|(?=])[[:space:]]*+", + "comment": "meta.separator", + "patterns": [ + { + "include": "#module-path-simple" + }, + { + "match": "\\b[[:lower:]][[:word:]]*\\b", + "name": "entity.name.tag.inline.any.html" + } + ] + }, + { + "include": "#jsx-attributes" + }, + { + "include": "#jsx-body" + }, + { + "include": "#comment" + } + ] + }, + "jsx-tail": { + "begin": "\\G(/>)|()", + "applyEndPatternLast": true, + "comment": "meta.separator", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.end.js" + }, + "2": { + "name": "punctuation.definition.tag.begin.js" + } + }, + "endCaptures": { + "1": { + "name": "punctuation.definition.tag.end.js" + } + }, + "patterns": [ + { + "include": "#module-path-simple" + }, + { + "match": "\\b[[:lower:]][[:word:]]*\\b", + "name": "entity.name.tag.inline.any.html" + } + ] + }, + "module-path-simple": { + "patterns": [ + { + "include": "#module-name-simple" + }, + { + "include": "#comment" + }, + { + "comment": "NOTE: end early to avoid too much reparsing", + "begin": "([\\.])", + "end": "(?<=[[:word:]\\)])|(?=[^\\.[:upper:]/])", + "beginCaptures": { + "1": { + "name": "variable.other.class.js variable.interpolation keyword.operator keyword.control message.error" + } + }, + "patterns": [ + { + "begin": "(?<=[\\.])", + "end": "(?<=[[:word:]\\)])|(?=[^\\.[:upper:]/])", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#module-name-simple" + } + ] + } + ] + } + ] + }, + "module-name-simple": { + "match": "\\b[[:upper:]][[:word:]]*\\b", + "name": "support.class entity.name.class" + }, + "comment": { + "patterns": [ + { + "include": "#comment-line" + }, + { + "include": "#comment-block-doc" + }, + { + "include": "#comment-block" + } + ] + }, + "comment-line": { + "begin": "(^[ \\t]+)?(//)", + "end": "$", + "name": "comment.line.double-slash", + "beginCaptures": { + "1": { + "name": "punctuation.whitespace.leading" + }, + "2": { + "name": "punctuation.definition.comment" + } + } + }, + "comment-block": { + "begin": "/\\*", + "end": "\\*/", + "name": "comment.block", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.begin" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.comment.end" + } + } + }, + "comment-block-doc": { + "begin": "/\\*\\*(?!/)", + "end": "\\*/", + "name": "comment.block.documentation", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.begin" + } + }, + "endCaptures": { + "0": { + "name": "punctuation.definition.comment.end" + } + } + }, + "value-expression": { + "patterns": [ + { + "include": "#attribute" + }, + { + "include": "#comment" + }, + { + "include": "#extension-node" + }, + { + "include": "#jsx" + }, + { + "include": "#operator" + }, + { + "include": "#value-expression-builtin" + }, + { + "include": "#value-expression-if-then-else" + }, + { + "include": "#value-expression-atomic" + }, + { + "include": "#module-path-simple-prefix" + }, + { + "match": "[:?]", + "name": "variable.other.class.js variable.interpolation keyword.operator keyword.control message.error" + }, + { + "include": "#record-path" + } + ] + }, + "value-expression-atomic-with-paths": { + "patterns": [ + { + "include": "#value-expression-atomic" + }, + { + "include": "#module-path-simple-prefix" + }, + { + "include": "#record-path-suffix" + } + ] + }, + "value-expression-atomic": { + "patterns": [ + { + "include": "#value-expression-literal" + }, + { + "include": "#value-expression-literal-list-or-array" + }, + { + "include": "#value-expression-for" + }, + { + "include": "#value-expression-fun" + }, + { + "include": "#value-expression-block-or-record-or-object" + }, + { + "include": "#value-expression-label" + }, + { + "include": "#value-expression-parens" + }, + { + "include": "#value-expression-switch" + }, + { + "include": "#value-expression-try" + }, + { + "include": "#value-expression-while" + } + ] + }, + "module-path-simple-prefix": { + "begin": "(?=\\b[[:upper:]])", + "end": "([\\.])|(?=[;\\)}]|\\b(and|class|constraint|exception|external|include|inherit|let|method|module|nonrec|open|private|rec|type|val|with)\\b)", + "endCaptures": { + "1": { + "name": "variable.other.class.js variable.interpolation keyword.operator keyword.control message.error" + } + }, + "patterns": [ + { + "include": "#module-path-simple" + } + ] + }, + "value-expression-literal": { + "patterns": [ + { + "include": "#value-expression-literal-boolean" + }, + { + "include": "#value-expression-literal-character" + }, + { + "include": "#value-expression-constructor" + }, + { + "include": "#value-expression-constructor-polymorphic" + }, + { + "include": "#value-expression-lazy" + }, + { + "include": "#value-expression-literal-numeric" + }, + { + "include": "#value-expression-literal-string" + }, + { + "include": "#value-expression-literal-unit" + } + ] + }, + "value-expression-literal-boolean": { + "match": "\\b(false|true)\\b", + "name": "entity.other.attribute-name.css constant.language constant.numeric" + }, + "value-expression-literal-character": { + "match": "(')([[:space:]]|[[:graph:]]|\\\\[\\\\\"'ntbr]|\\\\[[:digit:]][[:digit:]][[:digit:]]|\\\\x[[:xdigit:]][[:xdigit:]]|\\\\o[0-3][0-7][0-7])(')", + "name": "constant.character" + }, + "value-expression-literal-list-or-array": { + "begin": "(\\[\\|?)(?![@%])", + "end": "(\\|?\\])", + "beginCaptures": { + "1": { + "name": "constant.language.list" + } + }, + "endCaptures": { + "1": { + "name": "constant.language.list" + } + }, + "patterns": [ + { + "include": "#value-expression-literal-list-or-array-separator" + }, + { + "include": "#value-expression" + }, + { + "include": "#value-expression-literal-list-or-array" + } + ] + }, + "value-expression-literal-list-or-array-separator": { + "match": "(,)|(\\.\\.\\.)", + "captures": { + "1": { + "name": "variable.other.class.js variable.interpolation keyword.operator keyword.control message.error" + }, + "2": { + "name": "keyword.control" + } + } + }, + "value-expression-literal-numeric": { + "patterns": [ + { + "match": "([-])?([[:digit:]][_[:digit:]]*)(?:(\\.)([_[:digit:]]*))?(?:([eE])([\\-\\+])?([[:digit:]][_[:digit:]]*))?(?![bBoOxX])", + "captures": { + "1": { + "name": "keyword.control.less" + }, + "2": { + "name": "constant.numeric" + }, + "3": { + "name": "variable.other.class.js variable.interpolation keyword.operator keyword.control message.error" + }, + "4": { + "name": "constant.numeric" + }, + "5": { + "name": "keyword.control.less" + }, + "6": { + "name": "keyword.control.less" + }, + "7": { + "name": "constant.numeric" + } + } + }, + { + "match": "([-])?(0[xX])([[:xdigit:]][_[:xdigit:]]*)(?:(\\.)([_[:xdigit:]]*))?(?:([pP])([\\-\\+])?([[:digit:]][_[:digit:]]*))?", + "captures": { + "1": { + "name": "keyword.control.less" + }, + "2": { + "name": "keyword.control.less" + }, + "3": { + "name": "constant.numeric" + }, + "4": { + "name": "variable.other.class.js variable.interpolation keyword.operator keyword.control message.error" + }, + "5": { + "name": "constant.numeric" + }, + "6": { + "name": "keyword.control.less" + }, + "7": { + "name": "keyword.control.less" + }, + "8": { + "name": "constant.numeric" + } + } + }, + { + "match": "([-])?(0[oO])([0-7][_0-7]*)", + "captures": { + "1": { + "name": "keyword.control.less" + }, + "2": { + "name": "keyword.control.less" + }, + "3": { + "name": "constant.numeric" + } + } + }, + { + "match": "([-])?(0[bB])([0-1][_0-1]*)", + "captures": { + "1": { + "name": "keyword.control.less" + }, + "2": { + "name": "keyword.control.less" + }, + "3": { + "name": "constant.numeric" + } + } + } + ] + }, + "value-expression-literal-string": { + "patterns": [ + { + "begin": "(?|~$\\\\]))", + "end": "(?==>|[;\\)}])", + "patterns": [ + { + "include": "#pattern-guard" + }, + { + "include": "#pattern" + } + ] + }, + "value-expression-switch-pattern-match-rule-rhs": { + "begin": "(=>)", + "end": "(?=}|\\|(?![#\\-:!?.@*/&%^+<=>|~$\\\\]))", + "beginCaptures": { + "1": { + "name": "keyword.control.less" + } + }, + "patterns": [ + { + "include": "#value-expression-block-item" + } + ] + }, + "value-expression-try": { + "begin": "\\b(try)\\b", + "end": "(?<=})|(?=[;\\)]|\\b(and|as|class|constraint|exception|external|include|inherit|let|method|nonrec|open|private|rec|type|val|with)\\b)", + "beginCaptures": { + "1": { + "name": "keyword.control.trycatch" + } + }, + "patterns": [ + { + "include": "#value-expression-try-head" + }, + { + "include": "#value-expression-switch-body" + } + ] + }, + "value-expression-try-head": { + "begin": "(?<=try)", + "end": "(?