nix-community / rnix-lsp

WIP Language Server for Nix! [maintainer=@aaronjanse]
MIT License
708 stars 41 forks source link

rnix-lsp not keeping in sync with nixpkgs-fmt #100

Open lilyball opened 2 years ago

lilyball commented 2 years ago

Describe the bug

nixpkgs-fmt 1.3.0 was released 2 months ago, and nixpkgs-unstable updated almost immediately. However rnix-lsp appears to still be using nixpkgs-fmt 1.2.0.

nixpkgs-fmt 1.3.0 produces formatting differences from 1.2.0, and this means if I have rnix-lsp and nixpkgs-fmt both installed from recent nixpkgs-unstable, formatting from within my IDE disagrees with formatting from the command-line. This is very frustrating.

Steps to reproduce

With this code snippet:

{
  x = let x = {
    y = 1;
  }; in x;
}

Ask rnix-lsp to format it (e.g. with VSCode), and then ask nixpkgs-fmt 1.3.0 to format it. In this case, nixpkgs-fmt converts it to

{
  x =
    let
      x = {
        y = 1;
      };
    in
    x;
}

(I actually disagree with 1.3.0's formatting here but that's beside the point)

Expected behavior

rnix-lsp's formatting should match that of nixpkgs-fmt.

I realize that when nixpkgs-fmt updates, rnix-lsp might lag a little bit, but it should try to update as soon as is reasonable, so that way pulling rnix-lsp and nixpkgs-fmt from the same nixpkgs revision should result in identical formatting most of the time.

Additional context