nix-idea icon indicating copy to clipboard operation
nix-idea copied to clipboard

Formatter

Open JojOatXGME opened this issue 5 years ago • 3 comments

It would be nice to have a basic formatter which manages indentation.

EDIT: Some reference: https://nixos.org/manual/nixpkgs/stable/#sec-syntax

JojOatXGME avatar Dec 27 '20 18:12 JojOatXGME

In the meantime, hooking up nixfmt with a File Watcher works reasonably well: image

r-k-b avatar Dec 29 '20 07:12 r-k-b

Coming soon with the next release, there will be a new option in the settings which can be used to integrate nixpkgs-fmt and potentially other formatters. Thanks goes to @Cottand.

Screenshot of the settings menu for external formatter

I think it would still be nice to have a very basic built-in formatter, which can at least handle the indentation in lists, attribute sets and let expressions. I will therefore keep this ticket open.

JojOatXGME avatar Jun 08 '24 13:06 JojOatXGME

Can confirm this feature works, personally using nixfmt-rfc-style with the following command: nix --extra-experimental-features "nix-command flakes" run nixpkgs#nixfmt-rfc-style -- -w 240

TheArcaneBrony avatar Aug 01 '24 22:08 TheArcaneBrony