{ "displayName": "nushell", "name": "nushell", "patterns": [ { "include": "#define-variable" }, { "include": "#define-alias" }, { "include": "#function" }, { "include": "#extern" }, { "include": "#module" }, { "include": "#use-module" }, { "include": "#expression" }, { "include": "#comment" } ], "repository": { "binary": { "begin": "\\b(0x)(\\[)", "beginCaptures": { "1": { "name": "constant.numeric.nushell" }, "2": { "name": "meta.brace.square.begin.nushell" } }, "end": "]", "endCaptures": { "0": { "name": "meta.brace.square.begin.nushell" } }, "name": "constant.binary.nushell", "patterns": [ { "match": "\\h{2}", "name": "constant.numeric.nushell" } ] }, "braced-expression": { "begin": "\\{", "beginCaptures": { "0": { "name": "punctuation.section.block.begin.bracket.curly.nushell" } }, "end": "}", "endCaptures": { "0": { "name": "punctuation.section.block.end.bracket.curly.nushell" } }, "name": "meta.expression.braced.nushell", "patterns": [ { "begin": "(?<=\\{)\\s*\\|", "end": "\\|", "name": "meta.closure.parameters.nushell", "patterns": [ { "include": "#function-parameter" } ] }, { "captures": { "1": { "name": "variable.other.nushell" }, "2": { "name": "keyword.control.nushell" } }, "match": "(\\w+)\\s*(:)\\s*" }, { "captures": { "1": { "name": "variable.other.nushell" }, "2": { "name": "variable.other.nushell", "patterns": [ { "include": "#paren-expression" } ] }, "3": { "name": "keyword.control.nushell" } }, "match": "(\\$\"((?:[^\"\\\\]|\\\\.)*)\")\\s*(:)\\s*", "name": "meta.record-entry.nushell" }, { "captures": { "1": { "name": "variable.other.nushell" }, "2": { "name": "keyword.control.nushell" } }, "match": "(\"(?:[^\"\\\\]|\\\\.)*\")\\s*(:)\\s*", "name": "meta.record-entry.nushell" }, { "captures": { "1": { "name": "variable.other.nushell" }, "2": { "name": "variable.other.nushell", "patterns": [ { "include": "#paren-expression" } ] }, "3": { "name": "keyword.control.nushell" } }, "match": "(\\$'([^']*)')\\s*(:)\\s*", "name": "meta.record-entry.nushell" }, { "captures": { "1": { "name": "variable.other.nushell" }, "2": { "name": "keyword.control.nushell" } }, "match": "('[^']*')\\s*(:)\\s*", "name": "meta.record-entry.nushell" }, { "include": "#spread" }, { "include": "source.nushell" } ] }, "command": { "begin": "(?", "name": "keyword.operator.nushell" }, { "include": "#function-multiple-inout" } ] }, "function-multiple-inout": { "begin": "(?<=]\\s*)(:)\\s+(\\[)", "beginCaptures": { "1": { "name": "punctuation.definition.in-out.nushell" }, "2": { "name": "meta.brace.square.begin.nushell" } }, "end": "]", "endCaptures": { "0": { "name": "meta.brace.square.end.nushell" } }, "patterns": [ { "include": "#types" }, { "captures": { "1": { "name": "punctuation.separator.nushell" } }, "match": "\\s*(,)\\s*" }, { "captures": { "1": { "name": "keyword.operator.nushell" } }, "match": "\\s+(->)\\s+" } ] }, "function-parameter": { "patterns": [ { "captures": { "1": { "name": "keyword.control.nushell" } }, "match": "(-{0,2}|\\.{3})[-\\w]+(?:\\((-[?\\w])\\))?", "name": "variable.parameter.nushell" }, { "begin": "\\??:\\s*", "end": "(?=\\s+(?:-{0,2}|\\.{3})[-\\w]+|\\s*(?:[]#,=@|]|$))", "patterns": [ { "include": "#types" } ] }, { "begin": "@(?=[\"'])", "end": "(?<=[\"'])", "patterns": [ { "include": "#string" } ] }, { "begin": "=\\s*", "end": "(?=\\s+-{0,2}[-\\w]+|\\s*(?:[]#,|]|$))", "name": "default.value.nushell", "patterns": [ { "include": "#value" } ] } ] }, "function-parameters": { "begin": "\\[", "beginCaptures": { "0": { "name": "meta.brace.square.begin.nushell" } }, "end": "]", "endCaptures": { "0": { "name": "meta.brace.square.end.nushell" } }, "name": "meta.function.parameters.nushell", "patterns": [ { "include": "#function-parameter" }, { "include": "#comment" } ] }, "internal-variables": { "match": "\\$(?:nu|env)\\b", "name": "variable.language.nushell" }, "keyword": { "match": "def(?:-env)?", "name": "keyword.other.nushell" }, "module": { "begin": "((?:export\\s+)?module)\\s+([-\\w]+)\\s*\\{", "beginCaptures": { "1": { "name": "entity.name.function.nushell" }, "2": { "name": "entity.name.namespace.nushell" } }, "end": "}", "endCaptures": { "0": { "name": "punctuation.definition.module.end.nushell" } }, "name": "meta.module.nushell", "patterns": [ { "include": "source.nushell" } ] }, "numbers": { "match": "(?]=?|[!=]~|\\+\\+=?)(?= |$)", "name": "keyword.control.nushell" }, "operators-word": { "match": "(?<=[ (])(?:mod|in|not-(?:in|like|has)|not|and|or|xor|bit-(?:or|and|xor|shl|shr)|starts-with|ends-with|like|has)(?=[ )]|$)", "name": "keyword.control.nushell" }, "parameters": { "captures": { "1": { "name": "keyword.control.nushell" } }, "match": "(?<=\\s)(-{1,2})[-\\w]+", "name": "variable.parameter.nushell" }, "paren-expression": { "begin": "\\(", "beginCaptures": { "0": { "name": "meta.brace.round.begin.nushell" } }, "end": "\\)", "endCaptures": { "0": { "name": "meta.brace.round.end.nushell" } }, "name": "meta.expression.parenthesis.nushell", "patterns": [ { "include": "#expression" } ] }, "pre-command": { "begin": "(\\w+)(=)", "beginCaptures": { "1": { "name": "variable.other.nushell" }, "2": { "patterns": [ { "include": "#operators" } ] } }, "end": "(?=\\s+)", "patterns": [ { "include": "#value" } ] }, "ranges": { "match": "\\.\\.", "name": "meta.list.nushell", "patterns": [ { "include": "#types" } ] }, { "begin": "\\b(record)\\s*<", "beginCaptures": { "1": { "name": "entity.name.type.nushell" } }, "end": ">", "name": "meta.record.nushell", "patterns": [ { "captures": { "1": { "name": "variable.parameter.nushell" } }, "match": "([-\\w]+|\"[- \\w]+\"|'[^']+')\\s*:\\s*" }, { "include": "#types" } ] }, { "match": "\\b(\\w+)\\b", "name": "entity.name.type.nushell" } ] }, "use-module": { "patterns": [ { "captures": { "1": { "name": "entity.name.function.nushell" }, "2": { "name": "entity.name.namespace.nushell" }, "3": { "name": "keyword.other.nushell" } }, "match": "^\\s*((?:export )?use)\\s+([-\\w]+|\"[- \\w]+\"|'[- \\w]+')(?:\\s+([-\\w]+|\"[- \\w]+\"|'[- \\w]+'|\\*))?\\s*;?$" }, { "begin": "^\\s*((?:export )?use)\\s+([-\\w]+|\"[- \\w]+\"|'[- \\w]+')\\s*\\[", "beginCaptures": { "1": { "name": "entity.name.function.nushell" }, "2": { "name": "entity.name.namespace.nushell" } }, "end": "(])\\s*;?\\s*$", "endCaptures": { "1": { "name": "meta.brace.square.end.nushell" } }, "patterns": [ { "captures": { "1": { "name": "keyword.other.nushell" } }, "match": "([-\\w]+|\"[- \\w]+\"|'[- \\w]+'|\\*),?" }, { "include": "#comment" } ] }, { "captures": { "2": { "name": "entity.name.function.nushell" }, "3": { "name": "string.bare.nushell", "patterns": [ { "captures": { "1": { "name": "entity.name.namespace.nushell" } }, "match": "([- \\w]+)(?:\\.nu)?(?=$|[\"'])" } ] }, "4": { "name": "keyword.other.nushell" } }, "match": "(?(?:[/\\\\]|~[/\\\\]|\\.\\.?[/\\\\])?(?:[^/\\\\]+[/\\\\])*[- \\w]+(?:\\.nu)?){0}^\\s*((?:export )?use)\\s+(\"\\g\"|'\\g'|(?![\"'])\\g)(?:\\s+([-\\w]+|\"[- \\w]+\"|'[^']+'|\\*))?\\s*;?$" }, { "begin": "(?(?:[/\\\\]|~[/\\\\]|\\.\\.?[/\\\\])?(?:[^/\\\\]+[/\\\\])*[- \\w]+(?:\\.nu)?){0}^\\s*((?:export )?use)\\s+(\"\\g\"|'\\g'|(?![\"'])\\g)\\s+\\[", "beginCaptures": { "2": { "name": "entity.name.function.nushell" }, "3": { "name": "string.bare.nushell", "patterns": [ { "captures": { "1": { "name": "entity.name.namespace.nushell" } }, "match": "([- \\w]+)(?:\\.nu)?(?=$|[\"'])" } ] } }, "end": "(])\\s*;?\\s*$", "endCaptures": { "1": { "name": "meta.brace.square.end.nushell" } }, "patterns": [ { "captures": { "0": { "name": "keyword.other.nushell" } }, "match": "([-\\w]+|\"[- \\w]+\"|'[- \\w]+'|\\*),?" }, { "include": "#comment" } ] }, { "captures": { "0": { "name": "entity.name.function.nushell" } }, "match": "^\\s*(?:export )?use\\b" } ] }, "value": { "patterns": [ { "include": "#variables" }, { "include": "#variable-fields" }, { "include": "#control-keywords" }, { "include": "#constant-value" }, { "include": "#table" }, { "include": "#operators" }, { "include": "#paren-expression" }, { "include": "#braced-expression" }, { "include": "#string" }, { "include": "#comment" } ] }, "variable-fields": { "match": "(?<=[])}])(?:\\.(?:[-\\w]+|\"[- \\w]+\"))+", "name": "variable.other.nushell" }, "variables": { "captures": { "1": { "patterns": [ { "include": "#internal-variables" }, { "match": "\\$.+", "name": "variable.other.nushell" } ] }, "2": { "name": "variable.other.nushell" } }, "match": "(\\$[0-9A-Z_a-z]+)((?:\\.(?:[-\\w]+|\"[- \\w]+\"))*)" } }, "scopeName": "source.nushell" }