Closed notnmeyer closed 5 days ago
Is it stable yet ? I agree that using what is going to be the official formatter is nice but it's still in < 1.0 so I'm afraid they'll do breaking changes yet and we'll get issues with people complaining helix is changing all the formatting because of two different versions of nixfmt on two machines
could they... use nix to avoid that? joking aside, if this a concern a practical solution would just be disable auto-format
as a default. i think the scenario where different tooling versions "fight" over the correct formatting style can apply to a lot of tools and different configuration settings. personally, i don't think its that big of deal.
could they... use nix to avoid that
I must admit I laughed 😁
And really my comment was a question for you. I settled on "nixpkgs-fmt" a long time ago for nix formatting because I didn't want to depend on something that, at the time, was still only a project and not actual working code, but if the situation has changed and stabilized, adding out of the box support in helix is certainly something I'll agree with.
I have not followed evolutions though, so I genuinely don't know 😅
the current RFC style is packaged in nixfmt-rfc-style
(which still installs a nixfmt
binary) and i believe the intention is to eventually just have the nixfmt
package be the source of truth. i cant comment on how "stable" the formatter is, but ive been using it myself and it works fine.
the main points here:
Yeah let's keep auto-format off for now by default. We should only enable auto-format for languages where formatting is ubiquitous like Rust - otherwise it can unexpectedly reformat older code. Eventually if formatting becomes very popular for Nix we can enable it but where the RFC was accepted recently I think it's too soon.
Super ideally though we wouldn't need to set up a formatter
binary for this. Ideally the language servers would depend-on/use nixfmt. External formatters are fairly wasteful since we need to spawn them and send the whole document through them and figure out the diff ourself per-save while with language servers we have incremental document sync and text edits to describe the changes. Maybe for now we could just recommend formatter.command = "nixfmt"
in the documentation since I assume language servers will follow the RFC in the (near?) future.
or now we could just recommend formatter.command = "nixfmt" in the documentation
works for me, thanks
sets the default formatter for nix to
nixfmt
and enables auto-formatting.closes https://github.com/helix-editor/helix/issues/10803