Add additional_outdirs in config

This commit is contained in:
Edwin Cheng 2020-03-10 21:58:15 +08:00
parent 6b9d66bbee
commit c1db5d26a0
6 changed files with 13 additions and 0 deletions

View file

@ -44,6 +44,9 @@ pub struct ServerConfig {
/// Fine grained feature flags to disable specific features.
pub feature_flags: FxHashMap<String, bool>,
/// Fine grained controls for additional `OUT_DIR` env variables
pub additional_out_dirs: FxHashMap<String, String>,
pub rustfmt_args: Vec<String>,
/// 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(),
}

View file

@ -195,6 +195,7 @@ pub fn main_loop(
Watch(!config.use_client_watching),
options,
feature_flags,
config.additional_out_dirs,
)
};

View file

@ -76,6 +76,7 @@ impl WorldState {
watch: Watch,
options: Options,
feature_flags: FeatureFlags,
additional_out_dirs: FxHashMap<String, String>,
) -> WorldState {
let mut change = AnalysisChange::new();

View file

@ -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",

View file

@ -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,

View file

@ -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<string, boolean>; }
get additionalOutDirs() { return this.cfg.get("additionalOutDirs") as Record<string, string>; }
get rustfmtArgs() { return this.cfg.get("rustfmtArgs") as string[]; }
get cargoWatchOptions(): CargoWatchOptions {