coc-rust-analyzer icon indicating copy to clipboard operation
coc-rust-analyzer copied to clipboard

Rust analyzer does not activate for new tabs and windows opened in neovim

Open PxCommoner opened this issue 3 years ago • 5 comments

What's the output of :CocInfo

versions

vim version: NVIM v0.8.2 node version: v14.18.3 coc.nvim version: 0.0.82-b11a93ba 2022-12-25 15:19:13 +0800 coc.nvim directory: C:\Users\frede\AppData\Local\nvim-data\plugged\coc.nvim term: undefined platform: win32

Log of coc.nvim

2023-01-11T17:17:56.965 INFO (pid:18156) [plugin] - coc.nvim initialized with node: v14.18.3 after 121 2023-01-11T17:18:05.412 INFO (pid:18156) [attach] - receive notification: showInfo []

What's the output of :CocCommand rust-analyzer.serverVersion

[coc.nvim] rust-analyzer 0.3.1348-standalone (643bc02de 2023-01-01)

What's your coc-rust-analyzer version? You can get it from :CocList extensions coc-rust-analyzer 0.71.1 ~\AppData\Local\coc\extensions\node_modules\coc-rust-analyzer

ISSUE

When opening new, additional rust files in windows and tabs in neovim after the very first Rust file, the Rust analyzer does not activate for the subsequent files. The only workaround I have found so far is to execute :CocCommand rust-analyzer.reload to get the later files to have Rust code analysis.

For example: If I open an .rs file in neovim, it will have Rust analysis. If I open one or more .rs files in new windows or tabs within the same neovim instance, they will not have Rust code analysis unless I run :CocCommand rust-analyzer.reload

I do not see any possible configuration settings in the README.md that can address this issue and would like to know if there are any other methods besides having to run :CocCommand rust-analyzer.reload for each new tab or window that I open.

A new configuration setting that addresses this would be greatly appreciated.

PxCommoner avatar Jan 12 '23 00:01 PxCommoner

My tests:

Cargo.lock
Cargo.toml
src/
src/main.rs
  1. nvim src/main.ts, rust-analyzer launches and works as expected
  2. tabnew to a new tab
  3. some rust code, for example error code println!("{}", xyz);, :w src/lib.rs to new file
  4. rust-analyzer reports diagnostic on xyz cannot find in lib.rs, without reloading

I've watchman installed, you can try https://github.com/neoclide/coc.nvim/wiki/Install-coc.nvim#install-watchman-for-file-watching

fannheyward avatar Jan 12 '23 04:01 fannheyward

I have followed the installation instructions for watchman and have added it to my PATH. It does not appear to work and the documentation for Windows based systems is rather lacking.

Is this issue upstream in regards to the rust-analyzer or is it with the implementation of it in this plugin? It appears that I am the first one with the desire for rust-analyzer to work with multiple tabs and windows as I have not found any similar issues online elsewhere.

PxCommoner avatar Jan 14 '23 00:01 PxCommoner

I would also like to add that :CocRestart also appears to have the same results as well, although I currently only have coc-rust-analyzer installed.

PxCommoner avatar Jan 21 '23 18:01 PxCommoner

Still can't reproduce this on macOS, have no idea about this. It's properly issue of rust-analyzer. Can you reproduce this with VSCode + rust-analyzer?

fannheyward avatar Feb 01 '23 06:02 fannheyward

Still can't reproduce this on macOS, have no idea about this. It's properly issue of rust-analyzer. Can you reproduce this with VSCode + rust-analyzer?

I have been able to replicate the issue using a default VSCode installation and rust-analyzer installation acquired from here: https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer. Any rust files opened after the very first one will no longer have error detection or code suggestion / completion.

PxCommoner avatar Feb 01 '23 14:02 PxCommoner