Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work well with git branches #18

Open
xxchan opened this issue Apr 6, 2023 · 7 comments
Open

Doesn't work well with git branches #18

xxchan opened this issue Apr 6, 2023 · 7 comments
Labels
hard Difficult issue usability This issue limits the usability of lsp mux

Comments

@xxchan
Copy link

xxchan commented Apr 6, 2023

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 🤔

@WhyNotHugo
Copy link
Contributor

WhyNotHugo commented Aug 24, 2023

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

@WhyNotHugo
Copy link
Contributor

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

@pr2502
Copy link
Owner

pr2502 commented Oct 25, 2023

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 pr2502 added enhancement New feature or request hard Difficult issue usability This issue limits the usability of lsp mux and removed enhancement New feature or request labels Oct 25, 2023
@WhyNotHugo
Copy link
Contributor

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
Copy link
Contributor

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

@xxchan
Copy link
Author

xxchan commented Oct 25, 2023

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

@pr2502
Copy link
Owner

pr2502 commented Oct 25, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hard Difficult issue usability This issue limits the usability of lsp mux
Projects
None yet
Development

No branches or pull requests

3 participants