Skip to content

Long function applications should be wrapped per-arg #267

Open
@MattSturgeon

Description

@MattSturgeon

Description

nixfmt currently uses heuristics to find sensible places to insert line breaks, once a line becomes too long.

In the case of multi-arg function calls this can be counter productive, and result in less-readable code than if a more simplistic "one arg per line" approach is taken.

Small example input

{
  config_file_path = defaultNullOpts.mkNullable (with types; either str (listOf str)) [ ] "Custom config file path or list of custom config file paths.";
}

Expected output

{
  config_file_path =
    defaultNullOpts.mkNullable
      (with types; either str (listOf str))
      [ ]
      "Custom config file path or list of custom config file paths.";
}

Actual output

{
  config_file_path = defaultNullOpts.mkNullable (with types; either str (listOf str)) [
  ] "Custom config file path or list of custom config file paths.";
}

Note: there is also some strange line-breaking done within the empty list here. That is #268.

This was originally discussed here nix-community/nixvim#2209 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    styleStyle discussion

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions