Neovim-lsp reload on Cargo.toml change

For the folks who use nvim-lsp with rust-analyzer, how do you reload the LSP after a change in Cargo.toml (like adding a dependency)? This happens automatically in VSCode with rust-analyzer plugin. But the only way I have found to make it work in nvim by closing and re-opening it.
Any better solutions?

you are looking for the the command :LspRestart

1 Like

It should happen automatically in neovim as well, so the best course of action here is to figure out why this isn't happening. The two code paths which trigger reload:



1 Like

Well, I normally use cargo add - so that constitutes the second case. I wonder if I have mis-configured the LSP.
Btw, @matklad, is this a recent change (the first point)? Because I have been facing this problem for months now.

No, I don't think we've changed anything here in the past year or so.

Not sure why rust-analyzer doesn't catch the fs event, but rust-tools looks for changes in Cargo.toml and refreshed the workspace

So I would recommend either copying the autcmd and the related lua function from rust-tools or just use rust-tools

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.