-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Replace custom nixfmt
wrapping with reformatter
#176
Conversation
@matthewbauer Any opinions on this change? |
Sorry, looks good! Using an external package for this seems like a good change. |
Since NixOS#176 nix-mode is broken for me. Melpa only picks up the dependencies in the main nix-mode.el file, so this should fix it again.
Hi! So after discussion from Emacs ELPA, it sounds like we have an issue with using reformatter. The problem is reformatter is not included in ELPA, and since nix-mode is, including an outside hard dependency makes nix-mode not usable. So while we could require it as an optional dependency, it cannot be a hard dependency. It sounds like there is some interest in getting reformatter included in ELPA, but this could take some time and we can revisit this then. I've decided to revert it for the time being: c18a24e Thanks for the contribution though! I wish we could use reformatter since it simplifies things so much. |
There seems to be a fair amount of momentum behind apheleia as the formatter framework to replace both format-all and reformatter (authors of all 3 frameworks are discussing it). At least with doom emacs, adding a new formatter is a one-liner: (set-formatter! 'nixpkgs-fmt '("nixpkgs-fmt") :modes '(nix-mode)) So instead of committing to a particular framework, maybe this can be handled via documentation instead? Full disclosure - with doom the line above is supposed to work with |
@peterhoeg Could you provide a link to the discussion? |
@peterhoeg Thanks.
I have checked out the discussion at lassik/emacs-format-all-the-code#170, but apparently there is no consensus between the authors to switch to apheleia. People should be free to choose whatever formatter frontend. I am using reformatter, and I haven't found a problem with it so far, but there may be people who prefer to use something else.
I agree with this point. It is probably not a good idea to add an extra dependency just to save a few lines of configuration, as there are multiple options for running a formatter. FYI, some people in the Nix community are using treefmt-nix. With treefmt, there is no need to add a formatter configuration specific to the Nix language. |
eglot/lsp-mode can also ask the language server to run the formatter. nil supports this today. I don't think it's necessary for this package to handle formatting at all. |
I have checked out the discussion at lassik/emacs-format-all-the-code#170, but apparently there is no consensus between the authors to switch to apheleia.
I wasn’t advocating switching to apheleia either - in any case we would have the same problem as we do now with reformatter by virtue of it not being in gnu elpa. The way I read that thread is there is an agreement that having 3 frameworks for doing the same thing is a waste of effort and increased coordination at the very least would be helpful if not joining at least 2 of them (apheleia and format-all).
This was more of a “you may want to check this out while we are on the topic of formatting frameworks” point.
I agree with this point. It is probably not a good idea to add an extra dependency just to save a few lines of configuration, as there are multiple options for running a formatter.
Exactly. So it sounds we are very much aligned on this.
I think the situation would change in the situation where we get a formatting framework of some point into emacs proper.
FYI, some people in the Nix community are using treefmt-nix. With treefmt, there is no need to add a formatter configuration specific to the Nix language.
treefmt is indeed nifty, but caters to slightly different use cases. I don’t have a horse in the apheleia-race, so I’m not trying to push it, but in my experience its ability to make point stay put even when there is serious re-formatting going on, is just very good.
|
FWIW, |
Update: |
reformatter
here refers to https://github.com/purcell/emacs-reformatter.Note that as currently written this PR does remove existing user-facing commands. I would be glad to do any of the following:
For some related previous discussions, see