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

Respect Allman-style indentation #330

Open Andy3153 opened 2 months ago

Andy3153 commented 2 months ago

Is your feature request related to a problem? Please describe. I'd like to use this to automatically format my NixOS configuration, but I don't like that it breaks Allman-style indentation. I know most people, especially in the Nix space, just put their opening curly bracket on the line that requires it, but this is more readable, to me.

I understand why it happens, it's so that code like this

module1 =
  { module2.enable = true; };

looks good and is indented, but, because nixpkgs-fmt does not look for lone curly brackets on a line, it unintentionally turns code that looks like this

module1 =
{
  module2 =
  {
    enable = true;
  };
};

into this

module1 =
  {
    module2 =
      {
        enable = true;
      };
  };

Describe the solution you'd like I'd like to have it just let it be if it detects code styled like this.

Describe alternatives you've considered A workaround would be to at least have the option to tell nixpkgs-fmt to let it be like this (a command line argument, an option in some config file etc.)

Additional context Funnily enough, what this does right now is enforce GNU-style indentation