Skip to content

Pipe operator formatting support #230

Description

@VTimofeenko

Description

Nix 2.24 (release announcement post on discourse) added support for experimental pipes (RFC 0148).

I don't believe the exact formatting of code with pipe operator is specified in RFC 0148 or RFC 0166; this issue is about nixfmt not throwing an error when it encounters the pipe operator syntax.

Small example input

1 |> builtins.add 2

Expected output

1 |> builtins.add 2

Actual output

  |
1 | 1 |> builtins.add 2
  |   ^
unexpected '|'
expecting "or", '.', end of input, operator, or term

Steps to reproduce

❯ nix shell "github:NixOS/nixfmt" "github:NixOS/nix?ref=2.24.1"
❯ echo "1 |> builtins.add 2" | nix eval --extra-experimental-features pipe-operators --file -
3
❯ echo "1 |> builtins.add 2" | nixfmt 
<stdin>:1:3:
  |
1 | 1 |> builtins.add 2
  |   ^
unexpected '|'
expecting "or", '.', end of input, operator, or term

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions