fannheyward / coc-rust-analyzer

rust-analyzer extension for coc.nvim
MIT License
1.13k stars 40 forks source link

Rust Analyzer doesn't resolve modules #1111

Closed S4ndf1re closed 1 year ago

S4ndf1re commented 1 year ago

What's the output of :CocInfo

versions

vim version: NVIM v0.8.1 node version: v18.12.1 coc.nvim version: 0.0.82-b11a93ba 2022-12-25 15:19:13 +0800 coc.nvim directory: /home/jan/.local/share/nvim/site/pack/packer/start/coc.nvim term: xterm-256color platform: linux

Log of coc.nvim

2023-02-02T19:08:29.231 INFO (pid:11489) [plugin] - coc.nvim initialized with node: v18.12.1 after 308 2023-02-02T19:08:31.287 INFO (pid:11489) [services] - LanguageClient Rust Analyzer Language Server state change: stopped => starting 2023-02-02T19:08:31.292 INFO (pid:11489) [language-client-index] - Language server "rust-analyzer" started with 11504 2023-02-02T19:08:31.303 INFO (pid:11489) [services] - LanguageClient Rust Analyzer Language Server state change: starting => running 2023-02-02T19:08:31.336 INFO (pid:11489) [services] - service rust-analyzer started 2023-02-02T19:08:35.277 INFO (pid:11489) [attach] - receive notification: highlight []

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

What's your coc-rust-analyzer version? You can get it from :CocList extensions coc-rust-analyzer 0.72.0

I have the following rust project: grafik grafik

The src/routes folder contains a corresponding mod.rs file.

No matter in what folder i start neovim (either the root folder of the project, containing the cargo.toml, or the src folder directly) my modules are not found: grafik

If I run cargo check, everything compiles as expected. Vs Code can resolve the modules without problems.

I just installed coc-rust-analyzer. Did I mess up somehow?

Edit: everything else works as expected. I can resolve the rust standard without problems

Edit 2: it seems that the rust analyzer recognizes the parent folder as the project root. That is rather strange, because it isn't even a rust project. The only thing I can think of is, that it behaves that way because the parent dir is the git repo folder.

fannheyward commented 1 year ago

Properly an issue of workspace root resolving, set "workspace.bottomUpFiletypes": ["rust"] and try again.

S4ndf1re commented 1 year ago

I tried setting the option in the CocConfig file (i hope that this is correct). I tried setting it as both the version you proposed and "rust-analyzer.workspace.bottomUpFiletypes" : ["rust"]. Both version didn't change the situation.

I tested some more: The fact that the git repo is in the parent folder isn't the problem. Im not sure what ":CocList folders" actually shows, but it always shows a parent directory of the acutal work directory. It is not always the direct parent, but folder up the file hierarchy.

fannheyward commented 1 year ago

Looks like coc resolving the wrong rust project root. Can you make a sample project similar with your project struct to let me debug this?

S4ndf1re commented 1 year ago

I created a simple public test repo. test repo

Every other editor (helix, vs code) i tried didn't hat such issue. Weirdly enough, this problem occures in every rust project. But i havn't really messed with the coc config. In fact, the coc config is empty. I will try to investigate further on my side, maybe with a clean nvim instance.

S4ndf1re commented 1 year ago

Im closing the issue because its a general coc nvim problem. Seems like my configuration is messed up. Thank you for trying though.