diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 3314269ece..a8bf29ddf0 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -44,6 +44,9 @@ pub struct ServerConfig { /// Fine grained feature flags to disable specific features. pub feature_flags: FxHashMap, + /// Fine grained controls for additional `OUT_DIR` env variables + pub additional_out_dirs: FxHashMap, + pub rustfmt_args: Vec, /// Cargo feature configurations. @@ -64,6 +67,7 @@ impl Default for ServerConfig { cargo_watch_all_targets: true, with_sysroot: true, feature_flags: FxHashMap::default(), + additional_out_dirs: FxHashMap::default(), cargo_features: Default::default(), rustfmt_args: Vec::new(), } diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 221f464b65..6d123f629b 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -195,6 +195,7 @@ pub fn main_loop( Watch(!config.use_client_watching), options, feature_flags, + config.additional_out_dirs, ) }; diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs index 6f394055a2..ac4395617e 100644 --- a/crates/rust-analyzer/src/world.rs +++ b/crates/rust-analyzer/src/world.rs @@ -76,6 +76,7 @@ impl WorldState { watch: Watch, options: Options, feature_flags: FeatureFlags, + additional_out_dirs: FxHashMap, ) -> WorldState { let mut change = AnalysisChange::new(); diff --git a/editors/code/package.json b/editors/code/package.json index 7a4a93e303..b856729d31 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -224,6 +224,11 @@ "default": true, "description": "Whether to ask for permission before downloading any files from the Internet" }, + "rust-analyzer.additionalOutDirs": { + "type": "object", + "default": {}, + "markdownDescription": "Fine grained controls for OUT_DIR `env!(\"OUT_DIR\")` variable. e.g. `{\"foo\":\"/path/to/foo\"}`, " + }, "rust-analyzer.serverPath": { "type": [ "null", diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 540f7c9ea7..6ce3b9235c 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -37,6 +37,7 @@ export async function createClient(config: Config, serverPath: string): Promise< excludeGlobs: config.excludeGlobs, useClientWatching: config.useClientWatching, featureFlags: config.featureFlags, + additionalOutDirs: config.additionalOutDirs, withSysroot: config.withSysroot, cargoFeatures: config.cargoFeatures, rustfmtArgs: config.rustfmtArgs, diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index b72206d3cb..3ade7e900f 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -154,6 +154,7 @@ export class Config { get excludeGlobs() { return this.cfg.get("excludeGlobs") as string[]; } get useClientWatching() { return this.cfg.get("useClientWatching") as boolean; } get featureFlags() { return this.cfg.get("featureFlags") as Record; } + get additionalOutDirs() { return this.cfg.get("additionalOutDirs") as Record; } get rustfmtArgs() { return this.cfg.get("rustfmtArgs") as string[]; } get cargoWatchOptions(): CargoWatchOptions {