rust-analyzer / rust-analyzer.github.io

https://rust-analyzer.github.io/
87 stars 51 forks source link

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

Closed damianpowell closed 1 year ago

damianpowell commented 1 year ago

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.

lnicola commented 1 year ago

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.

damianpowell commented 1 year ago

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

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

But I do have these:

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

lnicola commented 1 year ago

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?

damianpowell commented 1 year ago

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.
lnicola commented 1 year ago

Moved to https://github.com/rust-lang/rust-analyzer/issues/14898.