ra-multiplex
ra-multiplex copied to clipboard
Doesn't work well with git branches
When I checkout to a different branch and open a file which is only included in that branch, there are errors:
This rust file does not belong to a loaded cargo project. It looks like it might belong to the workspace at path/to/crate/Cargo.toml, do you want to add it to the linked Projects?
Not sure whether the ra server is usually restarted in this case and whether this can be done by ra-multiplex 🤔
You can use :CargoReload
to work around this (it tells ~~cargo~~ rust-analyzer to reload).
Oh :CargoReload
sends a custom rust-analyzer
request called rust-analyzer/reloadWorkspace
. See reload_workspace
in https://github.com/neovim/nvim-lspconfig/blob/f7922e59aeb9bc3e31a660ea4e7405ffa3fc2c3a/lua/lspconfig/server_configurations/rust_analyzer.lua
I've looked into this a bit more and as far as I can tell this seems to be a missing feature on the editor side. LSP definies an event https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#workspace_didChangeWatchedFiles which is about the client telling the server when it detected a file change.
I've switched from neovim to vscode to helix now and I've noticed that this was a problem in both neovim and is now in helix, but everything just worked in vscode.
A possible workaround for us would be to lie to the server about the client's file watching capability even if the client says it doesn't support it and then do the file watching job for the client entirely (or do nothing if the client supports file watching).
I think that neovim only notifies when there is a change in files that are open.
A git checkout will affect files no open by neovim, so it won't notify anything.
@xxchan Does this actually work for you when using rust-analyzer
without ra-multiplex
?
Yes. Just tried again (in vscode) rust-analyzer works well by default.
Oh, does ra-multiplex break even vscode, that would be unfortunate. It might be (also) caused by server request we ignore in that case. We could also add an exception that server requests are sent unconditionally if there is only one client.