Closed SaphiraKai closed 1 year ago
I've updated this issue several times, after discovering new information. After reading the log output I eventually managed to catch, I believe the error is caused by passing the current directory to the language server, instead of the path to the file. I will attempt to fix this error, and if I'm successful I'll make a PR.
Update on the attempted PR, it's now past 2am my time and I was completely unfamiliar with the codebase to start with, lol. I'll continue tomorrow, but so far I have confirmed that the issue occurs when send_payload_to_server()
is used to initialize the server with the current directory, instead of the path to the opened file. I have yet to find the exact call that's responsible though.
I've updated this issue several times, after discovering new information. After reading the log output I eventually managed to catch, I believe the error is caused by passing the current directory to the language server, instead of the path to the file. I will attempt to fix this error, and if I'm successful I'll make a PR.
It actually happens not just in rust-analyzer. I was thinking that roots
in languages.toml
recursively goes above the path of the file to search for the file that implies the root directory of the project e.g. Cargo.toml, Cargo.lock. I was thinking of opening an issue about this as well but I don't have a lot of time in my hands.
Parts of the code base that I think passes the current_directory should be in https://github.com/helix-editor/helix/blob/f10b6f6ee2bbf4d6d9356e27be25b25bdb85b9cd/helix-term/src/args.rs or more likely here https://github.com/helix-editor/helix/blob/6e2aaed5c2cbcedc9ee4e225510cae4f357888aa/helix-term/src/commands/lsp.rs#L149-L156 - just a guess since I am not familiar with helix too
Alright I never got around to working on it today unfortunately. I've discovered the the LSP features seem to be extremely picky and will break unless I open my projects a very specific way...
It also completely breaks if I try and use a helper script for reasons I can't begin to comprehend given that the situation should be exactly the same.. I'll get around to figuring it out eventually, I'm tired
Fixed in #3553
Summary
When opening a Rust source file with a file path either one level outside of the project directory or anywhere inside the directory, these features work perfectly. However, using a path more than one layer outside of the project directory, either on the commandline or in the editor, the 'goto definition' and 'show documentation' features and likely others do not work. Most simply do nothing, but 'goto definition' returns the error 'No definition found.'.
Reproduction Steps
Assume the following directory layout:
This works:
~/src/SaphiraKai$ hx libaether/src/lib.rs
I am fully able to use features such as
<space>k
. However, moving up a single directory layer breaks.This does not work:
~/src$ hx SaphiraKai/libaether/src/lib.rs
Attempting to use
<space>k
and other LSP features simply do nothing, or yield an error.I've also tried various other directory structure layouts, including this:
This works:
~/rd$ hx libaether/src/lib.rs
This does not work:
~$ hx rd/libaether/src/lib.rs
Helix log
I managed to get the output from opening a broken session, attempting to use
<space>k
, and then closing the session:~/.cache/helix/helix.log
``` 2022-07-05T01:24:31.912 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer] failed to find any projects in [AbsPathBuf(\"/home/saphira\")]\n" 2022-07-05T01:24:31.913 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to discover workspace\n" 2022-07-05T01:24:31.913 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to discover workspace" } 2022-07-05T01:24:37.087 helix_lsp::transport [ERROR] err: <- StreamClosed 2022-07-05T01:24:37.087 helix_lsp::transport [ERROR] err: <- StreamClosed ```Platform
Linux
Terminal Emulator
st-instantos (the instantOS fork of suckless terminal)
Helix Version
helix 22.05