Support setting cargo features

This commit is contained in:
oxalica 2019-12-13 18:16:34 +08:00
parent 5eb5e80de9
commit af4eb26645
No known key found for this signature in database
GPG key ID: CED392DE0C483D00
8 changed files with 118 additions and 21 deletions

View file

@ -9,6 +9,7 @@
use rustc_hash::FxHashMap;
use ra_project_model::CargoFeatures;
use serde::{Deserialize, Deserializer};
/// Client provided initialization options
@ -37,6 +38,9 @@ pub struct ServerConfig {
/// Fine grained feature flags to disable specific features.
pub feature_flags: FxHashMap<String, bool>,
/// Cargo feature configurations.
pub cargo_features: CargoFeatures,
}
impl Default for ServerConfig {
@ -49,6 +53,7 @@ impl Default for ServerConfig {
max_inlay_hint_length: None,
with_sysroot: true,
feature_flags: FxHashMap::default(),
cargo_features: Default::default(),
}
}
}

View file

@ -67,6 +67,7 @@ pub fn main_loop(
let workspace = ra_project_model::ProjectWorkspace::discover_with_sysroot(
ws_root.as_path(),
config.with_sysroot,
&config.cargo_features,
);
match workspace {
Ok(workspace) => loaded_workspaces.push(workspace),