nix-community / nixpkgs-fmt

Nix code formatter for nixpkgs [maintainer=@zimbatm]
https://nix-community.github.io/nixpkgs-fmt/
Apache License 2.0
581 stars 34 forks source link

Misaligned lists of attribute sets #282

Open tazjin opened 2 years ago

tazjin commented 2 years ago

Input

let it = [{
  k = "1";
} {
  k = "2";
} {
  k = "3";
}]

Output

let it = [{
  k = "1";
}
  {
    k = "2";
  }
  {
    k = "3";
  }]

Desired output

let it = [
  {
    k = "1";
  }
  {
    k = "2";
  }
  {
    k = "3";
  }
]

The correct output will be produced if a \n is inserted between [{.

meain commented 9 months ago

Possibly related: If I try to format the following code which is a function returning a list, the formatting is a bit off.

Expected:

{ utils, ... }:
utils.create_list {
  key = "mango";
} ++ utils.create_list {
  key = "banana";
} ++ utils.create_list {
  key = "apple";
}

Formatted:

{ utils, ... }:
utils.create_list
  {
    key = "mango";
  } ++ utils.create_list {
  key = "banana";
} ++ utils.create_list {
  key = "apple";
}