NixOS / nixfmt

The official (but not yet stable) formatter for Nix code
https://nixfmt.serokell.io
Mozilla Public License 2.0
815 stars 33 forks source link

Configurable indentation size #77

Open RealityAnomaly opened 3 years ago

RealityAnomaly commented 3 years ago

I prefer to indent my Nix expressions with four spaces rather than two as I find it more readable. It'd be nice to have this as a command-line option you can specify, with two as the default.

quantenzitrone commented 1 year ago

yes and a tabs option please preferably even respecting the settings in .editorconfig

infinisil commented 5 months ago

While it has been configurable for a while using -w, since #118, it's a soft limit, and not a hard one. We should also implement a way to configure the hard limit now.

quantenzitrone commented 5 months ago

-w is for line length not indentation

dasJ commented 5 months ago

Yep sorry, that was an oversight on my side :/

infinisil commented 5 months ago

Ah I see, makes sense!

I guess for that we should use editorconfig's indent_size

omkumar312 commented 1 month ago

I want to work on this issues please assign me this issue.

infinisil commented 1 month ago

@omkumar312 Thanks! If you need any help, feel free to also join the Nix Formatting Matrix room.

Note also that there's already an open draft PR for this: https://github.com/NixOS/nixfmt/pull/209

omkumar312 commented 1 month ago

Command-Line Option: Introduce a flag, such as --indent, that allows users to set their preferred indentation size. example of usage: 'nixfmt --indent 4'

Keep the default indentation at two spaces for compatibility but enable users to choose four spaces if they prefer. This change will provide greater flexibility and accommodate different coding styles, improving overall readability.