Skip to content

Commit 08f0c29

Browse files
committed
Auto merge of rust-lang#14906 - davidbarsky:davidbarsky/add-option-to-disable-explorer, r=Veykril
fix: add a toggle to disable the dependency explorer For common uses of non-Cargo build systems with rust-analyzer, the dependency view isn't particularly helpful because there isn't a Cargo.toml present for dependencies or the dependencies are part of the current workspace. Speaking from the perspective of a user of `rust-project.json`, I'd prefer to have this feature disabled until I can add a field to `Crate` that defines the location of a build file (e.g., a `BUCK`) file, which would allow for removing the "search for a Cargo.toml in parent directories of a crate root" behavior that exists in a few places (I've opened [an issue](rust-lang/cargo#12187) on Cargo to request this data from `cargo-metadata`).
2 parents 6bca9f2 + 7dfef85 commit 08f0c29

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

editors/code/package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,11 @@
465465
"default": true,
466466
"type": "boolean"
467467
},
468+
"rust-analyzer.showDependenciesExplorer": {
469+
"markdownDescription": "Whether to show the dependencies view.",
470+
"default": true,
471+
"type": "boolean"
472+
},
468473
"$generated-start": {},
469474
"rust-analyzer.assist.emitMustUse": {
470475
"markdownDescription": "Whether to insert #[must_use] when generating `as_` methods\nfor enum variants.",
@@ -2013,7 +2018,7 @@
20132018
{
20142019
"id": "rustDependencies",
20152020
"name": "Rust Dependencies",
2016-
"when": "inRustProject"
2021+
"when": "inRustProject && config.rust-analyzer.showDependenciesExplorer"
20172022
}
20182023
]
20192024
},

editors/code/src/config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,10 @@ export class Config {
284284
get useRustcErrorCode() {
285285
return this.get<boolean>("diagnostics.useRustcErrorCode");
286286
}
287+
288+
get showDependenciesExplorer() {
289+
return this.get<boolean>("showDependenciesExplorer");
290+
}
287291
}
288292

289293
// the optional `cb?` parameter is meant to be used to add additional

editors/code/src/ctx.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ export class Ctx {
263263
}
264264
await client.start();
265265
this.updateCommands();
266-
this.prepareTreeDependenciesView(client);
266+
267+
if (this.config.showDependenciesExplorer) {
268+
this.prepareTreeDependenciesView(client);
269+
}
267270
}
268271

269272
private prepareTreeDependenciesView(client: lc.LanguageClient) {

0 commit comments

Comments
 (0)