diff options
author | Aleksey Kladov <[email protected]> | 2020-04-01 16:22:56 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-04-01 16:22:56 +0100 |
commit | 1e012eb991da7344f2423ce1447917c3eb388e87 (patch) | |
tree | 5d94bfd18cfc0fef4185bd70e4e65d0e633c10c8 /crates | |
parent | 797cd34c7c996251816226dac369fece1587a416 (diff) |
Move all config to config
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_project_model/src/cargo_workspace.rs | 1 | ||||
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 10 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 13 |
3 files changed, 17 insertions, 7 deletions
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<Target> for CargoWorkspace { | |||
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
46 | // TODO: rename to CargoConfig, kill `rename_all`, kill serde dep? | ||
46 | #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] | 47 | #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] |
47 | #[serde(rename_all = "camelCase", default)] | 48 | #[serde(rename_all = "camelCase", default)] |
48 | pub struct CargoFeatures { | 49 | 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 { | |||
30 | pub check: Option<FlycheckConfig>, | 30 | pub check: Option<FlycheckConfig>, |
31 | pub vscode_lldb: bool, | 31 | pub vscode_lldb: bool, |
32 | pub proc_macro_srv: Option<String>, | 32 | pub proc_macro_srv: Option<String>, |
33 | pub lru_capacity: Option<usize>, | ||
34 | pub use_client_watching: bool, | ||
35 | pub exclude_globs: Vec<String>, | ||
36 | pub cargo: CargoFeatures, | ||
37 | pub with_sysroot: bool, | ||
33 | } | 38 | } |
34 | 39 | ||
35 | #[derive(Debug, Clone)] | 40 | #[derive(Debug, Clone)] |
@@ -101,6 +106,11 @@ pub(crate) fn get_config( | |||
101 | rustfmt: RustfmtConfig::Rustfmt { extra_args: config.rustfmt_args.clone() }, | 106 | rustfmt: RustfmtConfig::Rustfmt { extra_args: config.rustfmt_args.clone() }, |
102 | vscode_lldb: config.vscode_lldb, | 107 | vscode_lldb: config.vscode_lldb, |
103 | proc_macro_srv: None, // FIXME: get this from config | 108 | proc_macro_srv: None, // FIXME: get this from config |
109 | lru_capacity: config.lru_capacity, | ||
110 | use_client_watching: config.use_client_watching, | ||
111 | exclude_globs: config.exclude_globs.clone(), | ||
112 | cargo: config.cargo_features.clone(), | ||
113 | with_sysroot: config.with_sysroot, | ||
104 | } | 114 | } |
105 | } | 115 | } |
106 | 116 | ||
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( | |||
71 | config: ServerConfig, | 71 | config: ServerConfig, |
72 | connection: Connection, | 72 | connection: Connection, |
73 | ) -> Result<()> { | 73 | ) -> Result<()> { |
74 | log::info!("server_config: {:#?}", config); | 74 | let text_document_caps = client_caps.text_document.as_ref(); |
75 | let config = get_config(&config, text_document_caps); | ||
76 | log::info!("initial config: {:#?}", config); | ||
75 | 77 | ||
76 | // Windows scheduler implements priority boosts: if thread waits for an | 78 | // Windows scheduler implements priority boosts: if thread waits for an |
77 | // event (like a condvar), and event fires, priority of the thread is | 79 | // event (like a condvar), and event fires, priority of the thread is |
@@ -92,11 +94,8 @@ pub fn main_loop( | |||
92 | SetThreadPriority(thread, thread_priority_above_normal); | 94 | SetThreadPriority(thread, thread_priority_above_normal); |
93 | } | 95 | } |
94 | 96 | ||
95 | let text_document_caps = client_caps.text_document.as_ref(); | ||
96 | let mut loop_state = LoopState::default(); | 97 | let mut loop_state = LoopState::default(); |
97 | let mut world_state = { | 98 | let mut world_state = { |
98 | // TODO: refactor | ||
99 | let new_config = get_config(&config, text_document_caps); | ||
100 | // FIXME: support dynamic workspace loading. | 99 | // FIXME: support dynamic workspace loading. |
101 | let workspaces = { | 100 | let workspaces = { |
102 | let mut loaded_workspaces = Vec::new(); | 101 | let mut loaded_workspaces = Vec::new(); |
@@ -104,7 +103,7 @@ pub fn main_loop( | |||
104 | let workspace = ra_project_model::ProjectWorkspace::discover_with_sysroot( | 103 | let workspace = ra_project_model::ProjectWorkspace::discover_with_sysroot( |
105 | ws_root.as_path(), | 104 | ws_root.as_path(), |
106 | config.with_sysroot, | 105 | config.with_sysroot, |
107 | &config.cargo_features, | 106 | &config.cargo, |
108 | ); | 107 | ); |
109 | match workspace { | 108 | match workspace { |
110 | Ok(workspace) => loaded_workspaces.push(workspace), | 109 | Ok(workspace) => loaded_workspaces.push(workspace), |
@@ -114,7 +113,7 @@ pub fn main_loop( | |||
114 | if let Some(ra_project_model::CargoTomlNotFoundError { .. }) = | 113 | if let Some(ra_project_model::CargoTomlNotFoundError { .. }) = |
115 | e.downcast_ref() | 114 | e.downcast_ref() |
116 | { | 115 | { |
117 | if !new_config.notifications.cargo_toml_not_found { | 116 | if !config.notifications.cargo_toml_not_found { |
118 | continue; | 117 | continue; |
119 | } | 118 | } |
120 | } | 119 | } |
@@ -163,7 +162,7 @@ pub fn main_loop( | |||
163 | config.lru_capacity, | 162 | config.lru_capacity, |
164 | &globs, | 163 | &globs, |
165 | Watch(!config.use_client_watching), | 164 | Watch(!config.use_client_watching), |
166 | new_config, | 165 | config, |
167 | ) | 166 | ) |
168 | }; | 167 | }; |
169 | 168 | ||