diff options
| -rw-r--r-- | lockfile.json | 2 | ||||
| -rw-r--r-- | queries/nix/folds.scm | 16 | ||||
| -rw-r--r-- | queries/nix/highlights.scm | 44 | ||||
| -rw-r--r-- | queries/nix/locals.scm | 10 |
4 files changed, 29 insertions, 43 deletions
diff --git a/lockfile.json b/lockfile.json index 0b78fdbb..47b9612c 100644 --- a/lockfile.json +++ b/lockfile.json @@ -198,7 +198,7 @@ "revision": "0a95cfdc0745b6ae82f60d3a339b37f19b7b9267" }, "nix": { - "revision": "6d6aaa50793b8265b6a8b6628577a0083d3b923d" + "revision": "6b71a810c0acd49b980c50fc79092561f7cee307" }, "norg": { "revision": "17d61df817c1e0a9cdef8d915d4e4c556b7cf68c" diff --git a/queries/nix/folds.scm b/queries/nix/folds.scm index 72050aa6..a89a5b24 100644 --- a/queries/nix/folds.scm +++ b/queries/nix/folds.scm @@ -1,11 +1,11 @@ ; Nix doesn't really have blocks, so just guess what people might want folds for [ - (if) - (with) - (let) - (function) - (attrset) - (rec_attrset) - (list) - (indented_string) + (if_expression) + (with_expression) + (let_expression) + (function_expression) + (attrset_expression) + (rec_attrset_expression) + (list_expression) + (indented_string_expression) ] @fold diff --git a/queries/nix/highlights.scm b/queries/nix/highlights.scm index 38b413fe..25f192b0 100644 --- a/queries/nix/highlights.scm +++ b/queries/nix/highlights.scm @@ -22,10 +22,10 @@ (comment) @comment ; strings -[ (string) (indented_string) ] @string +[ (string_expression) (indented_string_expression) ] @string ; paths and URLs -[ (path) (spath) (uri) ] @string.special +[ (path_expression) (spath_expression) (uri_expression) ] @string.special ; escape sequences (escape_sequence) @string.escape @@ -55,16 +55,18 @@ (ellipses) @punctuation.special ; `:` in `x: y`, used to separate function argument from body (see above) -(function ":" @punctuation.special) +(function_expression ":" @punctuation.special) ; basic identifiers -(identifier) @variable +(variable_expression) @variable ; builtin functions ((identifier) @_i (#match? @_i "^(builtins|baseNameOf|dirOf|fetchTarball|map|removeAttrs|toString)$")) @variable.builtin ; display entire builtins path as builtin (ex. `builtins.filter` is highlighted as one long builtin) -(select ((identifier) @_i (#eq? @_i "builtins")) (attrpath (attr_identifier) @variable.builtin)) @variable.builtin +(select_expression + expression: ((variable_expression) @_i (#eq? @_i "builtins")) + attrpath: (attrpath attr: (identifier) @variable.builtin)) @variable.builtin ; import ((identifier) @_i (#eq? @_i "import")) @include @@ -82,39 +84,23 @@ (interpolation "${" @punctuation.special (_) "}" @punctuation.special) @none ; fields (the `.` in `a.b = c;` isn't included) -(attrset (bind . (attrpath (attr_identifier) @field))) -(rec_attrset (bind . (attrpath (attr_identifier) @field))) +(attrset_expression (binding_set (binding . (attrpath (identifier) @field)))) +(rec_attrset_expression (binding_set (binding . (attrpath (identifier) @field)))) ; unary operators -(unary "-" @operator) -(unary "!" @operator) +(unary_expression operator: _ @operator) ; binary operators -(binary "?" @operator) -(binary "++" @operator) -(binary "*" @operator) -(binary "/" @operator) -(binary "+" @operator) -(binary "-" @operator) -(binary "//" @operator) -(binary "<" @operator) -(binary "<=" @operator) -(binary ">" @operator) -(binary ">=" @operator) -(binary "==" @operator) -(binary "!=" @operator) -(binary "&&" @operator) -(binary "||" @operator) -(binary "->" @operator) +(binary_expression operator: _ @operator) ; integers, also highlight a unary - [ - (unary "-" (integer)) - (integer) + (unary_expression "-" (integer_expression)) + (integer_expression) ] @number ; floats, also highlight a unary - [ - (unary "-" (float)) - (float) + (unary_expression "-" (float_expression)) + (float_expression) ] @float diff --git a/queries/nix/locals.scm b/queries/nix/locals.scm index 1720a848..1fc06d8b 100644 --- a/queries/nix/locals.scm +++ b/queries/nix/locals.scm @@ -1,15 +1,15 @@ ; let bindings -(let (bind . (attrpath) @definition.var)) @scope +(let_expression (binding_set (binding . (attrpath) @definition.var))) @scope ; rec attrsets -(rec_attrset (bind . (attrpath) @definition.field)) @scope +(rec_attrset_expression (binding_set (binding . (attrpath) @definition.field))) @scope ; functions and parameters -(function . [ +(function_expression . [ (identifier) @definition.parameter (formals (formal . (identifier) @definition.parameter)) ]) @scope ((formals) "@" (identifier) @definition.parameter) ; I couldn't get this to work properly inside the (function) -; some identifiers can't be references, but @reference doesn't seem to have an inverse like @none -(identifier) @reference +(variable_expression (identifier) @reference) +(inherited_attrs attr: (identifier) @reference) |
