helix
set nixfmt as the default formatter for nix
#11001
Closed

set nixfmt as the default formatter for nix #11001

notnmeyer
notnmeyer363 days ago

sets the default formatter for nix to nixfmt and enables auto-formatting.

closes #10803

notnmeyer set nixfmt as the default formatter for nix
448ccbd5
poliorcetics
poliorcetics363 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

notnmeyer
notnmeyer363 days ago (edited 363 days ago)

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.

kirawi kirawi added A-language-support
poliorcetics
poliorcetics362 days ago

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 😅

notnmeyer
notnmeyer360 days ago (edited 360 days ago)

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:

  1. the style rfc has been adopted
  2. the formatter is packaged and available
the-mikedavis
the-mikedavis357 days ago

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.

notnmeyer
notnmeyer356 days ago (edited 356 days ago)

or now we could just recommend formatter.command = "nixfmt" in the documentation

works for me, thanks

notnmeyer notnmeyer closed this 356 days ago

Login to write a write a comment.

Login via GitHub

Reviewers
No reviews
Assignees
No one assigned
Labels
Milestone