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

Add option to choose indention style #306

Open diktomat opened 1 year ago

diktomat commented 1 year ago

Indention style was already discussed in #131 with the conclusion of following the nixpkgs style of using two spaces, which obviously is the right choice for a project aiming to become the default. For personal preference and accessibility (as discussed there already) however, it would be great to be able to choose to use tabs (or more than two spaces) for personal files.

toastal commented 1 year ago

This resonates with me. I deeply-nested nix files at work and Flakes in general tend to be quite nest-y. I find these files grueling to read because 2 spaces doesn't give me enough visual contrast (same issue I've been having with a lot of languages recently). I tried to make an overlay that could wrap nixpkgs-fmt and pipe it to GNU unexpand as a workaround but upon multiple saves, the indentation of multiline strings kept increasing because how tabs are currently handled. (I tried prepending expend but then my script lost the flags; I could do some parse of the flags but now it's no longer a two-line wrapper)

zimbatm commented 1 year ago

I'm open to getting a PR for that.

Just know that tabs are not handled well in regard to multi-line strings; Nix includes them as part of the content of the string.