rust-analyzer/rust-analyzer.github.io

VS Code extension should not report error when workspace is not a Rust workspace

damianpowell opened this issue · 5 comments

Rust is not my main working environment, unfortunately. The rust-analyzer extension reports failed to find any projects in the workspace if the workspace is not a Rust workspace. This is slightly annoying and the associated red badge in the status bar is quite distracting.

Do you have any Rust files in your project? The extension should not activate if not, but IIRC there was a Code starting it when running a program.

Hi, Laurențiu. Thanks for responding so quickly.

There's none of the files listed below in my workspace:

  • *.rs
  • *.toml
  • .cargo/
  • rust-project.json

But I do have these:

  • Cargo.cs
  • cargo.js
  • cargo.scss
  • cargo.test.js

Could the [Cc]argo prefix be triggering the extension?

Strange, we have:

{
    "activationEvents": [
        "onLanguage:rust",
        "onCommand:rust-analyzer.analyzerStatus",
        "onCommand:rust-analyzer.memoryUsage",
        "onCommand:rust-analyzer.reloadWorkspace",
        "onCommand:rust-analyzer.startServer",
        "workspaceContains:*/Cargo.toml",
        "workspaceContains:*/rust-project.json"
    ]
}

Maybe you can copy files over into a new directory until it starts happening.

Are you sure it's not happening on F5 / Run / Debug?

I was going to try your suggestion of copying files into a new directory until the extension was triggered and found out that it is triggering immediately, even when opening an empty directory. I tried this a couple of different ways (see below) with the same results.

In all test cases I followed these steps:

  1. Close the current workspace or folder from the File menu.
  2. Close VS Code application.

Then either, Right-click the empty folder and select Open with Code, or,

  1. Launch Code form the Start menu.
  2. Open the empty directory from File | Open Folder... menu.