ra-multiplex icon indicating copy to clipboard operation
ra-multiplex copied to clipboard

Doesn't work well with git branches

Open xxchan opened this issue 1 year ago • 7 comments

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 🤔

xxchan avatar Apr 06 '23 19:04 xxchan

You can use :CargoReload to work around this (it tells ~~cargo~~ rust-analyzer to reload).

WhyNotHugo avatar Aug 24 '23 10:08 WhyNotHugo

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

WhyNotHugo avatar Aug 24 '23 10:08 WhyNotHugo

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).

pr2502 avatar Oct 25 '23 01:10 pr2502

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.

WhyNotHugo avatar Oct 25 '23 07:10 WhyNotHugo

@xxchan Does this actually work for you when using rust-analyzer without ra-multiplex?

WhyNotHugo avatar Oct 25 '23 07:10 WhyNotHugo

Yes. Just tried again (in vscode) rust-analyzer works well by default.

xxchan avatar Oct 25 '23 08:10 xxchan

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.

pr2502 avatar Oct 25 '23 09:10 pr2502