dundalek / lazy-lsp.nvim

Neovim plugin to auto install LSP servers
MIT License
203 stars 17 forks source link

Rust LSP invalidates cargo cache, or fails #40

Closed AThilenius closed 6 months ago

AThilenius commented 6 months ago

Firstly, thank you so much for creating this! It's such an elegant solution to LSP installs on NixOS. I'm stuck between a rock and a hard place, and I'm hoping you can point me in the right direction.

Without having cargo installed if I launch nvim on main.rs it loads rust-analyser as I would expect, but shows LSP underlines on things like println! and is unable to provide symbol info with Shift+K. I don't see anything in :LspLog though. Same thing happens if I install cargo either in a flake or global with the standard nix packages. If I instead add https://github.com/oxalica/rust-overlay the LSP works as expected, happily returning Shift+K symbol info. But the LSP seems to invalidate the entire cargo build, so ever time I run cargo build it starts from scratch which takes a long time on big projects.

I'm stuck between having a functional LSP, and having super long builds for every single tiny change. I could never get Rust to work right with Mason, and think this is a better solution anyway.

Any ideas on where to look? I've stripped my nvim config down to just the recommend on your README.md, so I don't think it's another plugin causing issues. I'm on nvim 0.9 if that seems relevant.

dundalek commented 6 months ago

I went searching for clues in nixpkgs to see how rust-analyzer is packaged. I noticed there is even a test for lsp in neovim https://github.com/NixOS/nixpkgs/blob/6a2c2e1a98fd7edfffb2ef85d6af171647b27366/pkgs/development/tools/rust/rust-analyzer/test-neovim-lsp.nix#L3 which is very nice.

I noticed there is a rustc dep which we did not have. I pushed a commit https://github.com/dundalek/lazy-lsp.nvim/commit/17deb64279389056b6edd4b0619d8dc391798b6a to add it, could you update and give it a try? I wonder if it is as simple as that :smiley:

AThilenius commented 6 months ago

@dundalek you sir, are wonderful! That fixed all of the above issues, progressive builds and errors without the overlay. Thank you so much!

dundalek commented 6 months ago

Awesome, glad to hear that! Thank you for taking the time to open an issue and writing down an exemplary report.