Skip to content

LSP features don't work when rust source file is opened from more than one level outside of the project directory #2970

Closed
@SaphiraKai

Description

@SaphiraKai

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:

/
└─home/
  └─saphira/
    └─src/
      └─SaphiraKai/
        └─libaether/ # cargo created project dir
          └─src/
            └─lib.rs

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:

/
└─home/
  └─saphira/
    └─rd/ # ramdisk
      └─libaether/ # same directory copied
        └─src/
          └─lib.rs

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-helix-termArea: Helix term improvementsA-language-serverArea: Language server clientC-bugCategory: This is a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions