Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for alejandra and nixpkgs-format #152

Open
TLATER opened this issue Mar 24, 2022 · 3 comments
Open

Support for alejandra and nixpkgs-format #152

TLATER opened this issue Mar 24, 2022 · 3 comments

Comments

@TLATER
Copy link

TLATER commented Mar 24, 2022

Hi, I've been meaning to switch to alejandra for formatting, and the only real blocker for me at this point is a convenient function in emacs to format my current buffer. nixpkgs-format also exists as a potential future replacement for nixfmt, though I've heard development interest in it has petered out a bit.

Either way, is there a chance these alternatives could be supported? I think their interfaces from an application point of view are similar enough that they are basically drop-in replacements for one another, so maybe a little configuration switch to choose one of them (that can be overridden with per-buffer or dir-locals when necessary) is simple enough?

I'm happy drafting that up myself, just want to test the waters before I spring it on here and see if it will be considered too much feature creep to do this for every nix formatter that may come into existence ;)

@fbergroth
Copy link

I'm using reformatter.el which is convenient: (reformatter-define nix-alejandra :program "alejandra") and then either (add-hook 'nix-mode-hook 'nix-alejandra-on-save-mode) or simply M-x nix-alejandra. Perhaps nix-format.el could use reformatter.

@TLATER
Copy link
Author

TLATER commented Mar 25, 2022

Hm, that does indeed cover everything I'd like to do. It's even already in my config through elm-mode, so I guess I might just switch to that for now. I'd be very in favor of switching to reformat.el as a backend, it's cool that there is a small standardization effort here, but that's a bit off-topic - separate issue?

I'd still like to see support for more that nix-fmt, though. nixpkgs-fmt and alejandra are big improvements over nix-fmt, so it would be nice to expose new users to them through this package. I don't think we'll see too many new ones created either.

On the other hand, I realize it'd feel a bit unclean to have multiple formatting functions lying around - especially because it'll be hard to remove formatters that don't see much maintenance in the future. It might also be confusingly hard to tell which to use. The maintenance burden would be low here, though, especially if it's backed by reformat.el.

We could also wait for the RFC that is choosing one of them as the default for nixpkgs to resolve, and switch to whichever wins?

@mkaito
Copy link

mkaito commented Oct 19, 2022

The "official" Alejandra integration suggests https://github.com/lassik/emacs-format-all-the-code, which also supports nixpkgs-format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants