I have a problem with rust-mode in my spacemacs (running on macOS).
Basically no interesting feature works, most prominently, jump to definition doesn't do anything.
If I do lsp-find-definition on function symbol it says "LSP :: Not found for: myfunction"
The same problem whether the function is defined in the same file or if it's a stdlib function.
I installed the rust layer here: Rust layer
I also installed rust-analyzer and it's placed here: /Users/jumar/.cargo/bin/rust-analyzer
There's a rust-analyzer process running:
ps aux | grep rust-analyzer
jumar 34174 0.0 0.0 33598788 612 ?? S 9:13AM 0:00.00 /Users/jumar/.rustup/toolchains/stable-x86_64-apple-darwin/libexec/rust-analyzer-proc-macro-srv
jumar 34147 0.0 0.6 34032384 212212 ?? Ss 9:13AM 0:09.41 /Users/jumar/.rustup/toolchains/stable-x86_64-apple-darwin/bin/rust-analyzer
This is started automatically after I start spacemacs (I'm not even sure how to re-/start it properly).
The odd thing is that it worked at the very beginning but it's not working anymore.
Any ideas how to troubleshoot and fix this problem?
The same is happening in Neovim
Try running lsp-describe-session
. It should list the running rust-analyzer sessions with their root folders. The root folder should be the directory containing the Cargo.toml for your project, or at most one directory up. If it's a higher-up directory, that's your problem.
Also, there should be a *rust-analyzer::stderr*
buffer. Take a look at that and see whether there are any error messages.
That seems to be a problem then.
I have a root (git) project directory rust-experiments.
Inside, I have rust-book/chapters - that's the directory with Cargo.toml.
However, rest-analyzer points to the project root (rust-experiments).
Now, I changed this via lsp-workspace-folders-remove and lsp-workspace-folders-add.
Here's the result of lsp-describe-session after the change:
[-] /Users/jumar/workspace/rust/rust-experiments/rust-book/chapters
`-[-] rust-analyzer:91847
|-[-] Buffers
| `-[+] references_and_borrowing.rs
`-[+] Capabilities
However, it still doesn't work.
The error buffer doesn't show any error at the moment.
Anything more I should check?
After calling flycheck-error-list I noticed this message in the minibuffer:
references_and_borrowing.rs 1 1 info unlinked-file file not included in crate hierarchy (lsp)
Then created a new cargo project and opened it in Emacs.
It looked better but still an error when I tried to invoke lsp-definition
.
the connected server does not support method textDocument/definition