From 394488fe6fe8b965dc10e73a6840b894a7e93841 Mon Sep 17 00:00:00 2001 From: mst-mkt Date: Sun, 2 Aug 2026 19:25:15 +0900 Subject: [PATCH 1/5] fix: bound record values so they are not parsed as commands --- syntaxes/nushell.tmLanguage.json | 41 ++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/syntaxes/nushell.tmLanguage.json b/syntaxes/nushell.tmLanguage.json index 178c33d..c5b0063 100644 --- a/syntaxes/nushell.tmLanguage.json +++ b/syntaxes/nushell.tmLanguage.json @@ -550,15 +550,18 @@ "patterns": [{ "include": "#function-parameter" }] }, { - "match": "(\\w+)\\s*(:)\\s*", - "captures": { + "begin": "(\\w+)\\s*(:)\\s*", + "beginCaptures": { "1": { "name": "variable.other.nushell" }, "2": { "name": "keyword.control.nushell" } - } + }, + "end": "(?=[,}])|(?<=[^\\s:])(?=\\s)", + "name": "meta.record-entry.nushell", + "patterns": [{ "include": "#value" }] }, { - "match": "(\\$\"((?:[^\"\\\\]|\\\\.)*)\")\\s*(:)\\s*", - "captures": { + "begin": "(\\$\"((?:[^\"\\\\]|\\\\.)*)\")\\s*(:)\\s*", + "beginCaptures": { "1": { "name": "variable.other.nushell" }, "2": { "name": "variable.other.nushell", @@ -566,19 +569,23 @@ }, "3": { "name": "keyword.control.nushell" } }, - "name": "meta.record-entry.nushell" + "end": "(?=[,}])|(?<=[^\\s:])(?=\\s)", + "name": "meta.record-entry.nushell", + "patterns": [{ "include": "#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": "#value" }] }, { - "match": "(\\$'([^']*)')\\s*(:)\\s*", - "captures": { + "begin": "(\\$'([^']*)')\\s*(:)\\s*", + "beginCaptures": { "1": { "name": "variable.other.nushell" }, "2": { "name": "variable.other.nushell", @@ -586,15 +593,19 @@ }, "3": { "name": "keyword.control.nushell" } }, - "name": "meta.record-entry.nushell" + "end": "(?=[,}])|(?<=[^\\s:])(?=\\s)", + "name": "meta.record-entry.nushell", + "patterns": [{ "include": "#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": "#value" }] }, { "include": "#spread" }, { "include": "source.nushell" } From ed8ec9ace99f3812fab82807f4fca163bc326589 Mon Sep 17 00:00:00 2001 From: mst-mkt Date: Sun, 2 Aug 2026 19:29:31 +0900 Subject: [PATCH 2/5] fix: treat keywords and operators in record values as strings --- syntaxes/nushell.tmLanguage.json | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/syntaxes/nushell.tmLanguage.json b/syntaxes/nushell.tmLanguage.json index c5b0063..284891e 100644 --- a/syntaxes/nushell.tmLanguage.json +++ b/syntaxes/nushell.tmLanguage.json @@ -557,7 +557,7 @@ }, "end": "(?=[,}])|(?<=[^\\s:])(?=\\s)", "name": "meta.record-entry.nushell", - "patterns": [{ "include": "#value" }] + "patterns": [{ "include": "#record-value" }] }, { "begin": "(\\$\"((?:[^\"\\\\]|\\\\.)*)\")\\s*(:)\\s*", @@ -571,7 +571,7 @@ }, "end": "(?=[,}])|(?<=[^\\s:])(?=\\s)", "name": "meta.record-entry.nushell", - "patterns": [{ "include": "#value" }] + "patterns": [{ "include": "#record-value" }] }, { "begin": "(\"(?:[^\"\\\\]|\\\\.)*\")\\s*(:)\\s*", @@ -581,7 +581,7 @@ }, "end": "(?=[,}])|(?<=[^\\s:])(?=\\s)", "name": "meta.record-entry.nushell", - "patterns": [{ "include": "#value" }] + "patterns": [{ "include": "#record-value" }] }, { "begin": "(\\$'([^']*)')\\s*(:)\\s*", @@ -595,7 +595,7 @@ }, "end": "(?=[,}])|(?<=[^\\s:])(?=\\s)", "name": "meta.record-entry.nushell", - "patterns": [{ "include": "#value" }] + "patterns": [{ "include": "#record-value" }] }, { "begin": "('[^']*')\\s*(:)\\s*", @@ -605,7 +605,7 @@ }, "end": "(?=[,}])|(?<=[^\\s:])(?=\\s)", "name": "meta.record-entry.nushell", - "patterns": [{ "include": "#value" }] + "patterns": [{ "include": "#record-value" }] }, { "include": "#spread" }, { "include": "source.nushell" } @@ -729,6 +729,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" } + ] } } } From 84b0b1a4dd1dcdbc3840dd7dbfc973773c3e3b1f Mon Sep 17 00:00:00 2001 From: mst-mkt Date: Sun, 2 Aug 2026 19:32:26 +0900 Subject: [PATCH 3/5] fix: match bare record keys with any character nushell allows --- syntaxes/nushell.tmLanguage.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntaxes/nushell.tmLanguage.json b/syntaxes/nushell.tmLanguage.json index 284891e..6f5b9fd 100644 --- a/syntaxes/nushell.tmLanguage.json +++ b/syntaxes/nushell.tmLanguage.json @@ -550,9 +550,9 @@ "patterns": [{ "include": "#function-parameter" }] }, { - "begin": "(\\w+)\\s*(:)\\s*", + "begin": "(?!\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2})([^\\s:,|;(){}\\[\"'$#][^\\s:,|;(){}\\[\"']*)\\s*(:)\\s*", "beginCaptures": { - "1": { "name": "variable.other.nushell" }, + "1": { "name": "string.bare.nushell variable.other.nushell" }, "2": { "name": "keyword.control.nushell" } }, "end": "(?=[,}])|(?<=[^\\s:])(?=\\s)", From e113e319bdaa3dcd6afa341a6c21922818aa4932 Mon Sep 17 00:00:00 2001 From: mst-mkt Date: Wed, 12 Aug 2026 03:46:45 +0900 Subject: [PATCH 4/5] fix: add a comment explaining why the bare key rule excludes datetimes --- syntaxes/nushell.tmLanguage.json | 1 + 1 file changed, 1 insertion(+) diff --git a/syntaxes/nushell.tmLanguage.json b/syntaxes/nushell.tmLanguage.json index 6f5b9fd..b1bb88a 100644 --- a/syntaxes/nushell.tmLanguage.json +++ b/syntaxes/nushell.tmLanguage.json @@ -550,6 +550,7 @@ "patterns": [{ "include": "#function-parameter" }] }, { + "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})([^\\s:,|;(){}\\[\"'$#][^\\s:,|;(){}\\[\"']*)\\s*(:)\\s*", "beginCaptures": { "1": { "name": "string.bare.nushell variable.other.nushell" }, From c03003d3df545df8b333b292b019711ff7254bb1 Mon Sep 17 00:00:00 2001 From: mst-mkt Date: Wed, 12 Aug 2026 03:53:16 +0900 Subject: [PATCH 5/5] fix: require a full time part in the datetime lookahead for bare keys --- syntaxes/nushell.tmLanguage.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/nushell.tmLanguage.json b/syntaxes/nushell.tmLanguage.json index b1bb88a..68fa52b 100644 --- a/syntaxes/nushell.tmLanguage.json +++ b/syntaxes/nushell.tmLanguage.json @@ -551,7 +551,7 @@ }, { "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})([^\\s:,|;(){}\\[\"'$#][^\\s:,|;(){}\\[\"']*)\\s*(:)\\s*", + "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" }