nixvim icon indicating copy to clipboard operation
nixvim copied to clipboard

[BUG] Enabling plugins.lsp.rust-analyzer and rustaceanvim spawns 2 LSPs

Open alisonjenkins opened this issue 1 year ago • 3 comments

Field Description
Plugin rustaceanvim
Nixpkgs unstable
Home Manager -

  • [x] I have read the FAQ and my bug is not listed there.

Description

If you have both lsp.rust-analyzer.enable set to true and are using rustaceanvim and work on a rust project 2 instances of rust-analyzer will spawn. Additionally the one used by rustaceanvim does not appear to honour the LSP config provided to the plugin.

I discovered this as I am trying to ignore the .direnv folder in my Rust projects as rust-analyzer gets stuck on scanning for roots on it indefinitely using this config.

To reproduce after setting up this config, edit a Rust project and do :LspInfo you will see 2 rust-analyzers. One which is just running rust-analyzer and another that is using the absolute path to an instance of rust-analyzer in the Nix store. The one using the absolute path is the lsp.servers one, the one using just rust-analyzer is the rustaceanvim instance.

I have not yet tested disabling rustaceanvim's instance of rust-analyzer to see if I can get the lsp.servers instance of rust-analyzer to take note of the config provided but the rustaceanvim one does not seem to honour the ignoreDirs option.

Minimal, Reproducible Example (MRE)

programs.nixvim = {
  plugins = {
    rustaceanvim = {
      enable = true;

      server.settings = {
        files = {
          excludeDirs = [ ".direnv" ];
        };
      };
    };

    lsp = {
      enable = true;

      servers = {
        rust-analyzer = {
          enable = true;
          installRustc = true;
          installCargo = true;
        };
      };
    };
  };
}

alisonjenkins avatar Mar 13 '24 09:03 alisonjenkins