mrcjkb / rustaceanvim

🦀 Supercharge your Rust experience in Neovim! A heavily modified fork of rust-tools.nvim
GNU General Public License v2.0
1.62k stars 58 forks source link

Reload workspace when cargo.toml is changed from outside(e.g. `cargo add`) #423

Closed wakuflair closed 3 months ago

wakuflair commented 3 months ago

Feature description

Now when I add a crate via cargo add, I need to manually open the cargo.toml and :w to force reloading the workspace.

It is better to watch the cargo.toml and reload no matter how it changed.

mrcjkb commented 3 months ago

Hey 👋

This is out of scope for rustaceanvim and would need to be implemented in rust-analyzer. See also: https://github.com/rust-lang/rust-analyzer/issues/16683

wakuflair commented 3 months ago

I'm curious why VSCode can have it reloaded automatically.

mrcjkb commented 3 months ago

It does? Then I suppose it's a VSCode feature. I'll reopen (maybe it's possible to implement using libuv filesystem events). But I'll have to give it some thought.

wakuflair commented 3 months ago

It does?

Yes, I can show you:

https://github.com/mrcjkb/rustaceanvim/assets/3471718/2571a8a2-df42-4f6f-9670-f9e56baf5dac

Veykril commented 3 months ago

If the file watcher is registered as the client (which should be the default) it is the client's job to inform the server of any relevant file changes.

mrcjkb commented 3 months ago

If the file watcher is registered as the client (which should be the default) it is the client's job to inform the server of any relevant file changes.

This should probably be implemented via the didChangeWatchedFiles spec, which is implemented in Neovim core, but has been disabled on Linux for performance/reliability reasons.

As I said, this is likely out of scope for rustaceanvim, so I will have to put some thought into it.

Veykril commented 3 months ago

In that case you could probably hardcode the rust-analyzer.files.watcher config to be set to "server" when telling rust-analyzer about the configurations, that will make it use its own watcher. (though again the LSP does recommend the client watcher to be used)

mrcjkb commented 3 months ago

Perhaps it makes sense to check if the neovim has the client capability and hardcode the config if it doesn't. That way we don't risk running into problems if neovim enables the capability again.