diff --git a/languages.toml b/languages.toml index 8c0f40482e355..b81ddb97aedb5 100644 --- a/languages.toml +++ b/languages.toml @@ -439,7 +439,7 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "nix" -source = { git = "https://github.com/cstrahan/tree-sitter-nix", rev = "50f38ceab667f9d482640edfee803d74f4edeba5" } +source = { git = "https://github.com/cstrahan/tree-sitter-nix", rev = "470b15a60520ff7b86f51732b8d8f1118c86041e" } [[language]] name = "ruby" diff --git a/runtime/queries/nix/highlights.scm b/runtime/queries/nix/highlights.scm index f6682065e7f69..0fee4df4899c0 100644 --- a/runtime/queries/nix/highlights.scm +++ b/runtime/queries/nix/highlights.scm @@ -1,19 +1,20 @@ (comment) @comment [ - "if" + "if" "then" "else" "let" "inherit" "in" "rec" - "with" + "with" "assert" + "or" ] @keyword ((identifier) @variable.builtin - (#match? @variable.builtin "^(__currentSystem|__currentTime|__nixPath|__nixVersion|__storeDir|builtins)$") + (#match? @variable.builtin "^(__currentSystem|__currentTime|__nixPath|__nixVersion|__storeDir|builtins|false|null|true)$") (#is-not? local)) ((identifier) @function.builtin @@ -21,33 +22,28 @@ (#is-not? local)) [ - (string) - (indented_string) + (string_expression) + (indented_string_expression) ] @string [ - (path) - (hpath) - (spath) + (path_expression) + (hpath_expression) + (spath_expression) ] @string.special.path -(uri) @string.special.uri +(uri_expression) @string.special.uri -; boolean -((identifier) @constant.builtin.boolean (#match? @constant.builtin.boolean "^(true|false)$")) @constant.builtin.boolean -; null -((identifier) @constant.builtin (#eq? @constant.builtin "null")) @constant.builtin - -(integer) @constant.numeric.integer -(float) @constant.numeric.float +(integer_expression) @constant.numeric.integer +(float_expression) @constant.numeric.float (interpolation "${" @punctuation.special "}" @punctuation.special) @embedded -(escape_sequence) @constant.character.escape +(escape_sequence) @escape -(function +(function_expression universal: (identifier) @variable.parameter ) @@ -55,27 +51,34 @@ name: (identifier) @variable.parameter "?"? @punctuation.delimiter) -(app +(select_expression + attrpath: (attrpath (identifier)) @variable.other.member) + +(apply_expression function: [ - (identifier) @function - (select + (variable_expression (identifier)) @function + (select_expression attrpath: (attrpath - attr: (attr_identifier) @function .))]) - + attr: (identifier) @function .))]) -(unary +(unary_expression operator: _ @operator) -(binary +(binary_expression operator: _ @operator) -(attr_identifier) @variable.other.member -(inherit attrs: (attrs_inherited (identifier) @variable.other.member) ) +(variable_expression (identifier) @variable) + +(binding + attrpath: (attrpath (identifier)) @variable.other.member) + +(identifier) @variable.other.member [ ";" "." "," + "=" ] @punctuation.delimiter [ diff --git a/runtime/queries/nix/indents.scm b/runtime/queries/nix/indents.scm index 0790ce2919ff1..8c1645f7b12f6 100644 --- a/runtime/queries/nix/indents.scm +++ b/runtime/queries/nix/indents.scm @@ -1,18 +1,25 @@ + [ - ; "function", - (bind) - (assert) - (with) + ; Bracket like (let) - (if) - (attrset) - (list) - (indented_string) + (rec_attrset) + (let_attrset) (parenthesized) + (list) + + ; Binding + (bind) + (inherit) + (inherit_from) + (formal) + + ; Binary operations + (binary) + (has_attr) + (select) + (app) ] @indent -[ - "}" - "]" -] @outdent +; Conditional +(if) @indent \ No newline at end of file