nix-community / nixpkgs-fmt

Nix code formatter for nixpkgs [maintainer=@zimbatm]
https://nix-community.github.io/nixpkgs-fmt/
Apache License 2.0
581 stars 34 forks source link

feat: add `reformat_edits` function #296

Closed mtoohey31 closed 2 years ago

mtoohey31 commented 2 years ago

This pull request exposes a function which returns the spacing edits and indentation edits required to reformat the given node. I'd like to do this so that rnix-lsp (which uses this crate), can respond to document formatting requests with multiple small edits instead of responding with one huge edit that replaces the entire document.

I am somewhat unsure of what type these edits should be returned as. Please see the description of the related rnix-lsp pull request (rnix-lsp#87) for a discussion of that.

Ma27 commented 2 years ago

The diff seems OK to me, but I'd leave the decision on whether or not to merge up to @zimbatm

zimbatm commented 2 years ago

once CI gets fixed, I think we're good to go

mtoohey31 commented 2 years ago

once CI gets fixed, I think we're good to go

Great, CI should be fixed after 4fb3042da40482086963c3149d2e1d5697ab33f6.