Skip to content

Commit 25e39a9

Browse files
authored
Textmate: improvement on record entries and closure (#169)
* remove let-env keyword * add "export const" keyword * improve record entry parsing * improve operators * improve parsing for closure parameters
1 parent 6496c8f commit 25e39a9

File tree

1 file changed

+54
-27
lines changed

1 file changed

+54
-27
lines changed

syntaxes/nushell.tmLanguage.json

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
"name": "keyword.control.nushell"
193193
},
194194
"operators-symbols": {
195-
"match": "(?<= )(?:\\+|\\-|\\*|\\/|\\/\\/|\\*\\*|!=|[<>=]=?|[!=]~|&&|\\|\\||\\||\\+\\+=?)(?= |$)",
195+
"match": "(?<= )(?:(?:\\+|\\-|\\*|\\/)=?|\\/\\/|\\*\\*|!=|[<>=]=?|[!=]~|\\+\\+=?)(?= |$)",
196196
"name": "keyword.control.nushell"
197197
},
198198
"operators": {
@@ -265,7 +265,7 @@
265265
},
266266
{
267267
"begin": "\\??:\\s*",
268-
"end": "(?=(?:\\s+(?:-{0,2}|\\.{3})[\\w-]+)|(?:\\s*(?:,|\\]|@|=|#|$)))",
268+
"end": "(?=(?:\\s+(?:-{0,2}|\\.{3})[\\w-]+)|(?:\\s*(?:,|\\]|\\||@|=|#|$)))",
269269
"patterns": [
270270
{ "include": "#types" }
271271
]
@@ -278,7 +278,7 @@
278278
{
279279
"name": "default.value.nushell",
280280
"begin": "=\\s*",
281-
"end": "(?=(?:\\s+-{0,2}[\\w-]+)|(?:\\s*(?:,|\\]|#|$)))",
281+
"end": "(?=(?:\\s+-{0,2}[\\w-]+)|(?:\\s*(?:,|\\]|\\||#|$)))",
282282
"patterns": [{ "include": "#value" }]
283283
}
284284
]
@@ -504,20 +504,9 @@
504504
"patterns": [{ "include": "#expression" }]
505505
},
506506
"braced-expression": {
507-
"begin": "(\\{)(?:\\s*\\|([\\w, ]*)\\|)?",
507+
"begin": "\\{",
508508
"beginCaptures": {
509-
"1": {
510-
"name": "punctuation.section.block.begin.bracket.curly.nushell"
511-
},
512-
"2": {
513-
"patterns": [
514-
{ "include": "#function-parameter" },
515-
{
516-
"match": ",",
517-
"name": "punctuation.separator.nushell"
518-
}
519-
]
520-
}
509+
"0": { "name": "punctuation.section.block.begin.bracket.curly.nushell" }
521510
},
522511
"end": "\\}",
523512
"endCaptures": {
@@ -526,23 +515,57 @@
526515
"name": "meta.expression.braced.nushell",
527516
"patterns": [
528517
{
529-
"begin": "((?:(?:[^$\\(\\{\\[\"'#\\s][^\\(\\{\\[\"'#\\s]*)|\\$?(?:\"[^\"]+\"|'[^']+')))\\s*(:)\\s*",
530-
"beginCaptures": {
531-
"1": {
532-
"name": "variable.other.nushell",
533-
"patterns": [{ "include": "#paren-expression" }]
534-
},
535-
"2": { "patterns": [{ "include": "#operators" }] }
518+
"begin": "(?<=\\{)\\s*\\|",
519+
"end": "\\|",
520+
"name": "meta.closure.parameters.nushell",
521+
"patterns": [{ "include": "#function-parameter" }]
522+
},
523+
{
524+
"match": "(\\w+)\\s*(:)\\s*",
525+
"captures": {
526+
"1": { "name": "variable.other.nushell" },
527+
"2": { "name": "keyword.control.nushell" }
528+
}
529+
},
530+
{
531+
"match": "(\\$\"((?:[^\"\\\\]|\\\\.)*)\")\\s*(:)\\s*",
532+
"captures": {
533+
"1": { "name": "variable.other.nushell" },
534+
"2": { "name": "variable.other.nushell", "patterns": [{ "include": "#paren-expression" }] },
535+
"3": { "name": "keyword.control.nushell" }
536536
},
537-
"end": "(?=,|\\s|\\})",
538-
"name": "meta.record-entry.nushell",
539-
"patterns": [{ "include": "#value" }]
537+
"name": "meta.record-entry.nushell"
538+
},
539+
{
540+
"match": "(\"(?:[^\"\\\\]|\\\\.)*\")\\s*(:)\\s*",
541+
"captures": {
542+
"1": { "name": "variable.other.nushell" },
543+
"2": { "name": "keyword.control.nushell" }
544+
},
545+
"name": "meta.record-entry.nushell"
546+
},
547+
{
548+
"match": "(\\$'([^']*)')\\s*(:)\\s*",
549+
"captures": {
550+
"1": { "name": "variable.other.nushell" },
551+
"2": { "name": "variable.other.nushell", "patterns": [{ "include": "#paren-expression" }] },
552+
"3": { "name": "keyword.control.nushell" }
553+
},
554+
"name": "meta.record-entry.nushell"
555+
},
556+
{
557+
"match": "('[^']*')\\s*(:)\\s*",
558+
"captures": {
559+
"1": { "name": "variable.other.nushell" },
560+
"2": { "name": "keyword.control.nushell" }
561+
},
562+
"name": "meta.record-entry.nushell"
540563
},
541564
{ "include": "source.nushell" }
542565
]
543566
},
544567
"define-variable": {
545-
"match": "(let(?:-env)?|mut|const)\\s+(\\w+)\\s*(=)",
568+
"match": "(let|mut|(?:export\\s+)?const)\\s+(\\w+)\\s+(=)",
546569
"captures": {
547570
"1": { "name": "keyword.other.nushell" },
548571
"2": { "name": "variable.other.nushell" },
@@ -627,6 +650,10 @@
627650
{ "include": "#pre-command" },
628651
{ "include": "#for-loop" },
629652
{ "include": "#operators" },
653+
{
654+
"match": "\\|",
655+
"name": "keyword.control.nushell"
656+
},
630657
{ "include": "#control-keywords" },
631658
{ "include": "#constant-value" },
632659
{ "include": "#command" },

0 commit comments

Comments
 (0)