diff --git a/syntaxes/nushell.tmLanguage.json b/syntaxes/nushell.tmLanguage.json index cc3b62b..83557ef 100644 --- a/syntaxes/nushell.tmLanguage.json +++ b/syntaxes/nushell.tmLanguage.json @@ -221,26 +221,64 @@ { "include": "#comment" } ] }, + "types": { + "patterns": [ + { + "begin": "\\b(list)\\s*<", + "beginCaptures": { + "1": { "name": "entity.name.type.nushell" } + }, + "end": ">", + "patterns": [ + { "include": "#types" } + ] + }, + { + "begin": "\\b(record)\\s*<", + "beginCaptures": { + "1": { "name": "entity.name.type.nushell" } + }, + "end": ">", + "patterns": [ + { + "match": "([\\w\\-]+|\"[\\w\\- ]+\"|'[^']+')\\s*:\\s*", + "captures": { + "1": { "name": "variable.parameter.nushell" } + } + }, + { "include": "#types" } + ] + }, + { + "match": "\\b(\\w+)\\b", + "name": "entity.name.type.nushell" + } + ] + }, "function-parameter-default-value": { "begin": "=\\s*", - "captures": { - "1": { "name": "variable.parameter.nushell" }, - "2": { "name": "variable.parameter.nushell" }, - "3": { "name": "keyword.operator.nushell" }, - "4": { "name": "entity.name.type.nushell" } - }, "end": "(?=\\])|,|$", "patterns": [{ "include": "#value" }] }, "function-parameter-declare": { - "match": "(-{0,2}[\\w-]+|\\.{3})(?:\\((-[\\w?])\\))?(?:\\s*(\\??:)\\s*(\\w+)(?:@((?:\"[^\"]+\")|(?:'[^']+')))?)?", - "captures": { - "1": { "name": "variable.parameter.nushell" }, - "2": { "name": "variable.parameter.nushell" }, - "3": { "name": "keyword.operator.nushell" }, - "4": { "name": "entity.name.type.nushell" }, - "5": { "name": "string.quoted.nushell" } - } + "patterns": [ + { + "match": "(-{0,2}[\\w-]+|\\.{3})(?:\\((-[\\w?])\\))?", + "name": "variable.parameter.nushell" + }, + { + "begin": "\\??:\\s*", + "end": "\\s*(?=,|@|#|$)", + "patterns": [ + { "include": "#types" } + ] + }, + { + "begin": "@(?=\"|')", + "end": "(?<=\"|')", + "patterns": [ {"include": "#string"} ] + } + ] }, "function-parameter": { "patterns": [ @@ -264,12 +302,13 @@ "name": "meta.function.parameters.nushell" }, "inout": { - "match": "(\\w+|\\w+<\\w+>)\\s*->\\s*(\\w+|\\w+<\\w+>)\\s*(,)?\\s*", - "captures": { - "1": { "name": "entity.name.type.nushell" }, - "2": { "name": "entity.name.type.nushell" }, - "3": { "name": "punctuation.separator.nushell" } - } + "patterns": [ + { "include": "#types" }, + { + "match": "->", + "name": "keyword.operator.nushell" + } + ] }, "function-inout": { "begin": "(?<=]\\s*)(:)\\s+(\\[)",