diff --git a/runtime/queries/nix/highlights.scm b/runtime/queries/nix/highlights.scm index be9310bb..7a1a7cf4 100644 --- a/runtime/queries/nix/highlights.scm +++ b/runtime/queries/nix/highlights.scm @@ -88,6 +88,24 @@ attrpath: (attrpath attr: (identifier) @function .))]) +; Pipe operators evaluate the side pointed to by the operator as a function: +; `value |> lib.foo` and `lib.foo <| value`. +(binary_expression + operator: "|>" + right: [ + (variable_expression (identifier) @function) + (select_expression + attrpath: (attrpath + attr: (identifier) @function .))]) + +(binary_expression + left: [ + (variable_expression (identifier) @function) + (select_expression + attrpath: (attrpath + attr: (identifier) @function .))] + operator: "<|") + (binding attrpath: (attrpath attr: (identifier) @function) diff --git a/tests/query/highlights/nix/calls.nix b/tests/query/highlights/nix/calls.nix index 242d28d8..acb65388 100644 --- a/tests/query/highlights/nix/calls.nix +++ b/tests/query/highlights/nix/calls.nix @@ -1,7 +1,11 @@ { x = map double items; -// ^ @function.builtin +# ^ @function.builtin y = builtins.length items; -// ^ @constant.builtin -// ^ @function.builtin +# ^ @constant.builtin +# ^ @function.builtin + z = value |> lib.foo; +# ^ @function + w = lib.foo <| value; +# ^ @function }