rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.35k stars 1.62k forks source link

Add Cargo file nesting pattern #13580

Closed alsoLut closed 2 years ago

alsoLut commented 2 years ago

In VS Code you can add:

"explorer.fileNesting.patterns": { "Cargo.toml": "Cargo.lock" },

In order to collapse .toml and .lock under one file (you can still expand it if you want).

I think this rule you be added by default by rust analyzer plugin.

lnicola commented 2 years ago

Sounds like a good idea! Do you want to file a PR?

alsoLut commented 2 years ago

Sadly, I don't have the time to set up the development env in order to make a PR. But from what I've seen on other extensions, this can be added like this:

In https://github.com/rust-lang/rust-analyzer/blob/master/editors/code/package.json you have to add:

{
   // ....
    "contributes": {
  // ....
        "configurationDefaults": {  // <-  add this object
            "explorer.fileNesting.patterns": {
                "Cargo.toml": "Cargo.lock"
            }
        }
    }
}

More info here: https://code.visualstudio.com/api/references/contribution-points#contributes.configurationDefaults

jplatte commented 2 years ago

I'm using Code (OSS version from arch repos) v1.73.0 and rust-analyzer v0.4.1284 (latest nightly from OpenVSX) and I'm not seeing this behavior. It should be there considering the PR was merged 6d ago, right?

edit: Ah, it looks like explorer.fileNesting.enabled has to be set to true first.