zed icon indicating copy to clipboard operation
zed copied to clipboard

Creating a language file that is not the primary project language behaviour

Open Moshyfawn opened this issue 1 year ago • 1 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

This was found as part of #9352.

When working in a project with a specific language, creating and opening an external language file doesn't produce any feedback. If you restart the editor, you'll get the error message that the workspace could not be initialised.

For example, creating a foo.rs file inside a TS / Vue project doesn't initialise the language server, nor does it show the initialisation error. Restarting the editor will give this error:

rust-analyzer-2024-03-11:
Failed to discover workspace.
Consider adding the 'Cargo.toml' of the workspace
to the
['linkedProjects']Chttps:// rust-analyzer.github.io
/manual.html#rust-analyzer.linkedProjects)
setting.
Failed to load workspaces.

Environment

Zed: v0.127.1 (Zed Preview) OS: macOS 14.4.0 Memory: 16 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

zed-ex-lang

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

[WARN] Language server rust-analyzer-2024-03-11 (id 3) status update: Failed to discover workspace.
Consider adding the `Cargo.toml` of the workspace to the [`linkedProjects`](https://rust-analyzer.github.io/manual.html#rust-analyzer.linkedProjects) setting.
[ERROR] Language server rust-analyzer-2024-03-11 (id 3) status update: Failed to discover workspace.
Consider adding the `Cargo.toml` of the workspace to the [`linkedProjects`](https://rust-analyzer.github.io/manual.html#rust-analyzer.linkedProjects) setting.

Failed to load workspaces.

Moshyfawn avatar Mar 14 '24 17:03 Moshyfawn

i found this in a large repository (WebKit) while doing some project-wide searches. if a .rs file appears in any of the searches, that is enough to start rust-analyzer, as well as many different javascript lsps. when i read through my logs, i saw a ton of eslint config not found errors, which is anoying to perform this work when i am just looking at search results.

paperclover avatar May 07 '24 02:05 paperclover

For rust-analyzer specifically, I have been able to work around this by putting this in ${PROJECT_ROOT}/.zed/settings.json:

{
  "lsp": {
    "rust-analyzer": {
      "initialization_options": {
        "linkedProjects": [
          "relative/path/to/Cargo.toml",
          "relative/path/to/another/Cargo.toml"
        ]
      }
    }
  }
}

The docs don't mention lsp as one of the allowed keys in this file, but it seems to work.

mullr avatar Jun 27 '24 14:06 mullr