unresolved import depending how you open the file
See original GitHub issuerust-analyzer: rust-analyzer fdd49b971 2021-11-17 dev rustc: rustc 1.58.0-nightly (c9c4b5d72 2021-11-17)
nvim and coc settings: https://gitlab.com/Ricky12Awesome/dotfiles/-/tree/main/.config/nvim project I’ve tested this on: https://github.com/Ricky12Awesome/sysusage
Related to: #898
When opening the project directory and you select the file you want to edit, it will give you this error
but, if you open the directory but select Cargo.toml
first, it doesn’t give you the error
this seems to be an issue when it starts rust-analyzer, since if you just open the directory and do CocInfo
, it isn’t started yet
but when you select a file (like Cargo.toml) then it gets started
so one way to fix this is if you open a directory that contains Cargo.toml
then it should start the RA server
could also just be an issue with my vim config and nerdtree
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (6 by maintainers)
Top GitHub Comments
The rust-analyzer needs a workspace root to work. If you do
vim path/to/project
, the workspace root is your cwd. After youcd path/to/project
, the workspace root will be resolved topath/to/project
.think I figured out the cause of this, if you change directory with in your vim config, it seems to not be reflected to coc and it’s workspaces, but if you change it manually (make sure anything that changes cd is commented out in vim config), it works fine
I switch from NERDTree to coc-explorer, but this should apply to both
this is how I’m launching explorer, with this, the explorer starts fine, but it’s whatever directory you execute the command in
if you comment that out and just do it manually, it works fine no problem but for don’t comment it out, and try and do this, it doesn’t work for some reason
EDIT:
Adding a delay does seem to fix, but there has to be some event that could trigger this, cuase just adding a delay is a hacky way of doing it