diff --git a/syntaxes/nushell.tmLanguage.json b/syntaxes/nushell.tmLanguage.json index 178c33d..68fa52b 100644 --- a/syntaxes/nushell.tmLanguage.json +++ b/syntaxes/nushell.tmLanguage.json @@ -550,15 +550,19 @@ "patterns": [{ "include": "#function-parameter" }] }, { - "match": "(\\w+)\\s*(:)\\s*", - "captures": { - "1": { "name": "variable.other.nushell" }, + "comment": "Blocks and closures are also scanned by this rule, so the negative lookahead keeps a datetime like 2024-01-01T00:00:00Z from being split into key and value.", + "begin": "(?!\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2})([^\\s:,|;(){}\\[\"'$#][^\\s:,|;(){}\\[\"']*)\\s*(:)\\s*", + "beginCaptures": { + "1": { "name": "string.bare.nushell variable.other.nushell" }, "2": { "name": "keyword.control.nushell" } - } + }, + "end": "(?=[,}])|(?<=[^\\s:])(?=\\s)", + "name": "meta.record-entry.nushell", + "patterns": [{ "include": "#record-value" }] }, { - "match": "(\\$\"((?:[^\"\\\\]|\\\\.)*)\")\\s*(:)\\s*", - "captures": { + "begin": "(\\$\"((?:[^\"\\\\]|\\\\.)*)\")\\s*(:)\\s*", + "beginCaptures": { "1": { "name": "variable.other.nushell" }, "2": { "name": "variable.other.nushell", @@ -566,19 +570,23 @@ }, "3": { "name": "keyword.control.nushell" } }, - "name": "meta.record-entry.nushell" + "end": "(?=[,}])|(?<=[^\\s:])(?=\\s)", + "name": "meta.record-entry.nushell", + "patterns": [{ "include": "#record-value" }] }, { - "match": "(\"(?:[^\"\\\\]|\\\\.)*\")\\s*(:)\\s*", - "captures": { + "begin": "(\"(?:[^\"\\\\]|\\\\.)*\")\\s*(:)\\s*", + "beginCaptures": { "1": { "name": "string.quoted.double.nushell variable.other.nushell" }, "2": { "name": "keyword.control.nushell" } }, - "name": "meta.record-entry.nushell" + "end": "(?=[,}])|(?<=[^\\s:])(?=\\s)", + "name": "meta.record-entry.nushell", + "patterns": [{ "include": "#record-value" }] }, { - "match": "(\\$'([^']*)')\\s*(:)\\s*", - "captures": { + "begin": "(\\$'([^']*)')\\s*(:)\\s*", + "beginCaptures": { "1": { "name": "variable.other.nushell" }, "2": { "name": "variable.other.nushell", @@ -586,15 +594,19 @@ }, "3": { "name": "keyword.control.nushell" } }, - "name": "meta.record-entry.nushell" + "end": "(?=[,}])|(?<=[^\\s:])(?=\\s)", + "name": "meta.record-entry.nushell", + "patterns": [{ "include": "#record-value" }] }, { - "match": "('[^']*')\\s*(:)\\s*", - "captures": { + "begin": "('[^']*')\\s*(:)\\s*", + "beginCaptures": { "1": { "name": "string.quoted.single.nushell variable.other.nushell" }, "2": { "name": "keyword.control.nushell" } }, - "name": "meta.record-entry.nushell" + "end": "(?=[,}])|(?<=[^\\s:])(?=\\s)", + "name": "meta.record-entry.nushell", + "patterns": [{ "include": "#record-value" }] }, { "include": "#spread" }, { "include": "source.nushell" } @@ -718,6 +730,20 @@ { "include": "#string" }, { "include": "#comment" } ] + }, + "record-value": { + "patterns": [ + { "include": "#variables" }, + { "include": "#variable-fields" }, + { "include": "#constant-value" }, + { "include": "#table" }, + { "include": "#spread" }, + { "include": "#ranges" }, + { "include": "#paren-expression" }, + { "include": "#braced-expression" }, + { "include": "#string" }, + { "include": "#comment" } + ] } } }