{ "name": "Nix", "scopeName": "source.nix", "fileTypes": [ "nix" ], "uuid": "0514fd5f-acb6-436d-b42c-7643e6d36c8f", "patterns": [ { "include": "#expression" } ], "repository": { "expression": { "patterns": [ { "include": "#parens-and-cont" }, { "include": "#list-and-cont" }, { "include": "#string" }, { "include": "#interpolation" }, { "include": "#with-assert" }, { "include": "#function-for-sure" }, { "include": "#attrset-for-sure" }, { "include": "#attrset-or-function" }, { "include": "#let" }, { "include": "#if" }, { "include": "#operator-unary" }, { "include": "#operator-binary" }, { "include": "#constants" }, { "include": "#bad-reserved" }, { "include": "#parameter-name-and-cont" }, { "include": "#others" } ] }, "expression-cont": { "begin": "(?=.?)", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#parens" }, { "include": "#list" }, { "include": "#string" }, { "include": "#interpolation" }, { "include": "#function-for-sure" }, { "include": "#attrset-for-sure" }, { "include": "#attrset-or-function" }, { "include": "#operator-binary" }, { "include": "#constants" }, { "include": "#bad-reserved" }, { "include": "#parameter-name" }, { "include": "#others" } ] }, "parens": { "begin": "\\(", "beginCaptures": { "0": { "name": "punctuation.definition.expression.nix" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.definition.expression.nix" } }, "patterns": [ { "include": "#expression" } ] }, "parens-and-cont": { "begin": "(?=\\()", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#parens" }, { "include": "#expression-cont" } ] }, "list": { "begin": "\\[", "beginCaptures": { "0": { "name": "punctuation.definition.list.nix" } }, "end": "\\]", "endCaptures": { "0": { "name": "punctuation.definition.list.nix" } }, "patterns": [ { "include": "#expression" } ] }, "list-and-cont": { "begin": "(?=\\[)", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#list" }, { "include": "#expression-cont" } ] }, "attrset-for-sure": { "patterns": [ { "begin": "(?=\\brec\\b)", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "begin": "\\brec\\b", "end": "(?=\\{)", "beginCaptures": { "0": { "name": "keyword.other.nix" } }, "patterns": [ { "include": "#others" } ] }, { "include": "#attrset-definition" }, { "include": "#others" } ] }, { "begin": "(?=\\{\\s*(\\}|[^,?]*(=|;)))", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#attrset-definition" }, { "include": "#others" } ] } ] }, "attrset-definition": { "begin": "(?=\\{)", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "begin": "(\\{)", "end": "(\\})", "beginCaptures": { "0": { "name": "punctuation.definition.attrset.nix" } }, "endCaptures": { "0": { "name": "punctuation.definition.attrset.nix" } }, "patterns": [ { "include": "#attrset-contents" } ] }, { "begin": "(?<=\\})", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#expression-cont" } ] } ] }, "attrset-definition-brace-opened": { "patterns": [ { "begin": "(?<=\\})", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#expression-cont" } ] }, { "begin": "(?=.?)", "end": "\\}", "endCaptures": { "0": { "name": "punctuation.definition.attrset.nix" } }, "patterns": [ { "include": "#attrset-contents" } ] } ] }, "attrset-contents": { "patterns": [ { "include": "#attribute-inherit" }, { "include": "#bad-reserved" }, { "include": "#attribute-bind" }, { "include": "#others" } ] }, "function-header-open-brace": { "begin": "\\{", "end": "(?=\\})", "beginCaptures": { "0": { "name": "punctuation.definition.entity.function.2.nix" } }, "patterns": [ { "include": "#function-contents" } ] }, "function-header-close-brace-no-arg": { "begin": "\\}", "end": "(?=\\:)", "beginCaptures": { "0": { "name": "punctuation.definition.entity.function.nix" } }, "patterns": [ { "include": "#others" } ] }, "function-header-terminal-arg": { "begin": "(?=@)", "end": "(?=\\:)", "patterns": [ { "begin": "\\@", "end": "(?=\\:)", "patterns": [ { "begin": "(\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*)", "end": "(?=\\:)", "name": "variable.parameter.function.3.nix" }, { "include": "#others" } ] }, { "include": "#others" } ] }, "function-header-close-brace-with-arg": { "begin": "\\}", "end": "(?=\\:)", "beginCaptures": { "0": { "name": "punctuation.definition.entity.function.nix" } }, "patterns": [ { "include": "#function-header-terminal-arg" }, { "include": "#others" } ] }, "function-header-until-colon-no-arg": { "begin": "(?=\\{)", "end": "(?=\\:)", "patterns": [ { "include": "#function-header-open-brace" }, { "include": "#function-header-close-brace-no-arg" } ] }, "function-header-until-colon-with-arg": { "begin": "(?=\\{)", "end": "(?=\\:)", "patterns": [ { "include": "#function-header-open-brace" }, { "include": "#function-header-close-brace-with-arg" } ] }, "function-body-from-colon": { "begin": "(\\:)", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "beginCaptures": { "0": { "name": "punctuation.definition.function.nix" } }, "patterns": [ { "include": "#expression" } ] }, "function-definition": { "begin": "(?=.?)", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#function-body-from-colon" }, { "begin": "(?=.?)", "end": "(?=\\:)", "patterns": [ { "begin": "(\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*)", "end": "(?=\\:)", "beginCaptures": { "0": { "name": "variable.parameter.function.4.nix" } }, "patterns": [ { "begin": "\\@", "end": "(?=\\:)", "patterns": [ { "include": "#function-header-until-colon-no-arg" }, { "include": "#others" } ] }, { "include": "#others" } ] }, { "begin": "(?=\\{)", "end": "(?=\\:)", "patterns": [ { "include": "#function-header-until-colon-with-arg" } ] } ] }, { "include": "#others" } ] }, "function-definition-brace-opened": { "begin": "(?=.?)", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#function-body-from-colon" }, { "begin": "(?=.?)", "end": "(?=\\:)", "patterns": [ { "include": "#function-header-close-brace-with-arg" }, { "begin": "(?=.?)", "end": "(?=\\})", "patterns": [ { "include": "#function-contents" } ] } ] }, { "include": "#others" } ] }, "function-for-sure": { "patterns": [ { "begin": "(?=(\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*\\s*[:@]|\\{[^}\\\"']*\\}\\s*:|\\{[^#}\"'/=]*[,\\?]))", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#function-definition" } ] } ] }, "function-contents": { "patterns": [ { "include": "#bad-reserved" }, { "include": "#function-parameter" }, { "include": "#others" } ] }, "attrset-or-function": { "begin": "\\{", "beginCaptures": { "0": { "name": "punctuation.definition.attrset-or-function.nix" } }, "end": "(?=([\\])};]|\\b(else|then)\\b))", "patterns": [ { "begin": "(?=(\\s*\\}|\\\"|\\binherit\\b|\\$\\{|\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*(\\s*\\.|\\s*=[^=])))", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#attrset-definition-brace-opened" } ] }, { "begin": "(?=(\\.\\.\\.|\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*\\s*[,?]))", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#function-definition-brace-opened" } ] }, { "include": "#bad-reserved" }, { "begin": "\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*", "end": "(?=([\\])};]|\\b(else|then)\\b))", "beginCaptures": { "0": { "name": "variable.parameter.function.maybe.nix" } }, "patterns": [ { "begin": "(?=\\.)", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#attrset-definition-brace-opened" } ] }, { "begin": "\\s*(\\,)", "beginCaptures": { "1": { "name": "keyword.operator.nix" } }, "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#function-definition-brace-opened" } ] }, { "begin": "(?=\\=)", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#attribute-bind-from-equals" }, { "include": "#attrset-definition-brace-opened" } ] }, { "begin": "(?=\\?)", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#function-parameter-default" }, { "begin": "\\,", "beginCaptures": { "0": { "name": "keyword.operator.nix" } }, "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#function-definition-brace-opened" } ] } ] }, { "include": "#others" } ] }, { "include": "#others" } ] }, "with-assert": { "begin": "(?)", "beginCaptures": { "0": { "name": "string.unquoted.spath.nix" } }, "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#expression-cont" } ] }, { "begin": "([a-zA-Z][a-zA-Z0-9\\+\\-\\.]*\\:[a-zA-Z0-9\\%\\/\\?\\:\\@\\&\\=\\+\\$\\,\\-\\_\\.\\!\\~\\*\\']+)", "beginCaptures": { "0": { "name": "string.unquoted.url.nix" } }, "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#expression-cont" } ] } ] }, "parameter-name": { "match": "\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*", "captures": { "0": { "name": "variable.parameter.name.nix" } } }, "parameter-name-and-cont": { "begin": "\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "beginCaptures": { "0": { "name": "variable.parameter.name.nix" } }, "patterns": [ { "include": "#expression-cont" } ] }, "attribute-name-single": { "match": "\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*", "name": "entity.other.attribute-name.single.nix" }, "attribute-name": { "patterns": [ { "match": "\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*", "name": "entity.other.attribute-name.multipart.nix" }, { "match": "\\." }, { "include": "#string-quoted" }, { "include": "#interpolation" } ] }, "function-parameter-default": { "begin": "\\?", "beginCaptures": { "0": { "name": "keyword.operator.nix" } }, "end": "(?=[,}])", "patterns": [ { "include": "#expression" } ] }, "function-parameter": { "patterns": [ { "begin": "(\\.\\.\\.)", "end": "(,|(?=\\}))", "name": "keyword.operator.nix", "patterns": [ { "include": "#others" } ] }, { "begin": "\\b[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*", "beginCaptures": { "0": { "name": "variable.parameter.function.1.nix" } }, "end": "(,|(?=\\}))", "endCaptures": { "0": { "name": "keyword.operator.nix" } }, "patterns": [ { "include": "#whitespace" }, { "include": "#comment" }, { "include": "#function-parameter-default" }, { "include": "#expression" } ] }, { "include": "#others" } ] }, "attribute-inherit": { "begin": "\\binherit\\b", "beginCaptures": { "0": { "name": "keyword.other.inherit.nix" } }, "end": "\\;", "endCaptures": { "0": { "name": "punctuation.terminator.inherit.nix" } }, "patterns": [ { "begin": "\\(", "end": "(?=\\;)", "beginCaptures": { "0": { "name": "punctuation.section.function.arguments.nix" } }, "patterns": [ { "begin": "\\)", "end": "(?=\\;)", "beginCaptures": { "0": { "name": "punctuation.section.function.arguments.nix" } }, "patterns": [ { "include": "#bad-reserved" }, { "include": "#attribute-name-single" }, { "include": "#others" } ] }, { "include": "#expression" } ] }, { "begin": "(?=[a-zA-Z\\_])", "end": "(?=\\;)", "patterns": [ { "include": "#bad-reserved" }, { "include": "#attribute-name-single" }, { "include": "#others" } ] }, { "include": "#others" } ] }, "attribute-bind-from-equals": { "begin": "\\=", "beginCaptures": { "0": { "name": "keyword.operator.bind.nix" } }, "end": "\\;", "endCaptures": { "0": { "name": "punctuation.terminator.bind.nix" } }, "patterns": [ { "include": "#expression" } ] }, "attribute-bind": { "patterns": [ { "include": "#attribute-name" }, { "include": "#attribute-bind-from-equals" } ] }, "operator-unary": { "name": "keyword.operator.unary.nix", "match": "(!|-)" }, "operator-binary": { "name": "keyword.operator.nix", "match": "(\\bor\\b|\\.|\\|\\>|\\<\\||==|!=|!|\\<\\=|\\<|\\>\\=|\\>|&&|\\|\\||-\\>|//|\\?|\\+\\+|-|\\*|/(?=([^*]|$))|\\+)" }, "constants": { "patterns": [ { "begin": "\\b(builtins|true|false|null)\\b", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "beginCaptures": { "0": { "name": "constant.language.nix" } }, "patterns": [ { "include": "#expression-cont" } ] }, { "beginCaptures": { "0": { "name": "support.function.nix" } }, "begin": "\\b(scopedImport|import|isNull|abort|throw|baseNameOf|dirOf|removeAttrs|map|toString|derivationStrict|derivation)\\b", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#expression-cont" } ] }, { "beginCaptures": { "0": { "name": "constant.numeric.nix" } }, "begin": "\\b[0-9]+\\b", "end": "(?=([\\])};,]|\\b(else|then)\\b))", "patterns": [ { "include": "#expression-cont" } ] } ] }, "whitespace": { "match": "\\s+" }, "illegal": { "match": ".", "name": "invalid.illegal" }, "others": { "patterns": [ { "include": "#whitespace" }, { "include": "#comment" }, { "include": "#illegal" } ] }, "bad-reserved": { "match": "(?