digga
digga copied to clipboard
Format with alejandra
alejandra seems like the best choice out there and our codebase would look a lot cleaner with this.
This should probably be merged after #438, so we don't have to deal with the conflicts.
The first commit is me, the second commit is all alejandra.
nix 2.8 isn't in nixpkgs yet, but you can always do nix develop -c fmt
I haven't yet used https://github.com/numtide/treefmt, but it looks pretty useful as "One CLI to format the code tree". @blaggacao originally introduced its usage in the devshell changes reverted in #444. Looks like it could handle formatting for *.nix
files with alejandra
, in addition to other formatters per file type.
Considering formatting changes are usually pretty disruptive, it might be worth resurrecting the usage of treefmt
in this PR since the treefmt.toml
file there also added formatter configuration for *.sh
files with shfmt
, and we have a few of those in the repo. Plus, Prettier for all the rest.
https://github.com/divnix/digga/pull/444/files#diff-83489924125e52fef286509dc792070b570a0c656cd9b048445f87bebc57405a
Since treefmt was mentioned, we have a pretty useful solution at work that uses a devshell pre-commit hook to call treefmt on the entire repo before any commits are made. I don't think anybody would mind if we steal it: https://github.com/input-output-hk/devshell-capsules/blob/main/pre-commit.sh
I know we had something very similar here before, not sure if we still do
Definitely, I'll setup treefmt here.
We still have the pre-commit hook for devos, but it was never added to digga's devshell, I can do that here to. And we can switch to treefmt in the hook too. Right now it uses nixpkgs-fmt.
This can be closed since #491 was merged.