From 1e012eb991da7344f2423ce1447917c3eb388e87 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 1 Apr 2020 17:22:56 +0200 Subject: Move all config to config --- crates/ra_project_model/src/cargo_workspace.rs | 1 + crates/rust-analyzer/src/config.rs | 10 ++++++++++ crates/rust-analyzer/src/main_loop.rs | 13 ++++++------- 3 files changed, 17 insertions(+), 7 deletions(-) (limited to 'crates') diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index f4fd6ad28..91735a726 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs @@ -43,6 +43,7 @@ impl ops::Index for CargoWorkspace { } } +// TODO: rename to CargoConfig, kill `rename_all`, kill serde dep? #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] #[serde(rename_all = "camelCase", default)] pub struct CargoFeatures { diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 94627d35d..8a8e42ed8 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -30,6 +30,11 @@ pub struct Config { pub check: Option, pub vscode_lldb: bool, pub proc_macro_srv: Option, + pub lru_capacity: Option, + pub use_client_watching: bool, + pub exclude_globs: Vec, + pub cargo: CargoFeatures, + pub with_sysroot: bool, } #[derive(Debug, Clone)] @@ -101,6 +106,11 @@ pub(crate) fn get_config( rustfmt: RustfmtConfig::Rustfmt { extra_args: config.rustfmt_args.clone() }, vscode_lldb: config.vscode_lldb, proc_macro_srv: None, // FIXME: get this from config + lru_capacity: config.lru_capacity, + use_client_watching: config.use_client_watching, + exclude_globs: config.exclude_globs.clone(), + cargo: config.cargo_features.clone(), + with_sysroot: config.with_sysroot, } } diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 8f89fb7ea..c973d43fa 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -71,7 +71,9 @@ pub fn main_loop( config: ServerConfig, connection: Connection, ) -> Result<()> { - log::info!("server_config: {:#?}", config); + let text_document_caps = client_caps.text_document.as_ref(); + let config = get_config(&config, text_document_caps); + log::info!("initial config: {:#?}", config); // Windows scheduler implements priority boosts: if thread waits for an // event (like a condvar), and event fires, priority of the thread is @@ -92,11 +94,8 @@ pub fn main_loop( SetThreadPriority(thread, thread_priority_above_normal); } - let text_document_caps = client_caps.text_document.as_ref(); let mut loop_state = LoopState::default(); let mut world_state = { - // TODO: refactor - let new_config = get_config(&config, text_document_caps); // FIXME: support dynamic workspace loading. let workspaces = { let mut loaded_workspaces = Vec::new(); @@ -104,7 +103,7 @@ pub fn main_loop( let workspace = ra_project_model::ProjectWorkspace::discover_with_sysroot( ws_root.as_path(), config.with_sysroot, - &config.cargo_features, + &config.cargo, ); match workspace { Ok(workspace) => loaded_workspaces.push(workspace), @@ -114,7 +113,7 @@ pub fn main_loop( if let Some(ra_project_model::CargoTomlNotFoundError { .. }) = e.downcast_ref() { - if !new_config.notifications.cargo_toml_not_found { + if !config.notifications.cargo_toml_not_found { continue; } } @@ -163,7 +162,7 @@ pub fn main_loop( config.lru_capacity, &globs, Watch(!config.use_client_watching), - new_config, + config, ) }; -- cgit v1.2.3