Skip to content

Commit 1e012eb

Browse files
committed
Move all config to config
1 parent 797cd34 commit 1e012eb

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

crates/ra_project_model/src/cargo_workspace.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ impl ops::Index<Target> for CargoWorkspace {
4343
}
4444
}
4545

46+
// TODO: rename to CargoConfig, kill `rename_all`, kill serde dep?
4647
#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
4748
#[serde(rename_all = "camelCase", default)]
4849
pub struct CargoFeatures {

crates/rust-analyzer/src/config.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ pub struct Config {
3030
pub check: Option<FlycheckConfig>,
3131
pub vscode_lldb: bool,
3232
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,
3338
}
3439

3540
#[derive(Debug, Clone)]
@@ -101,6 +106,11 @@ pub(crate) fn get_config(
101106
rustfmt: RustfmtConfig::Rustfmt { extra_args: config.rustfmt_args.clone() },
102107
vscode_lldb: config.vscode_lldb,
103108
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,
104114
}
105115
}
106116

crates/rust-analyzer/src/main_loop.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ pub fn main_loop(
7171
config: ServerConfig,
7272
connection: Connection,
7373
) -> 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);
7577

7678
// Windows scheduler implements priority boosts: if thread waits for an
7779
// event (like a condvar), and event fires, priority of the thread is
@@ -92,19 +94,16 @@ pub fn main_loop(
9294
SetThreadPriority(thread, thread_priority_above_normal);
9395
}
9496

95-
let text_document_caps = client_caps.text_document.as_ref();
9697
let mut loop_state = LoopState::default();
9798
let mut world_state = {
98-
// TODO: refactor
99-
let new_config = get_config(&config, text_document_caps);
10099
// FIXME: support dynamic workspace loading.
101100
let workspaces = {
102101
let mut loaded_workspaces = Vec::new();
103102
for ws_root in &ws_roots {
104103
let workspace = ra_project_model::ProjectWorkspace::discover_with_sysroot(
105104
ws_root.as_path(),
106105
config.with_sysroot,
107-
&config.cargo_features,
106+
&config.cargo,
108107
);
109108
match workspace {
110109
Ok(workspace) => loaded_workspaces.push(workspace),
@@ -114,7 +113,7 @@ pub fn main_loop(
114113
if let Some(ra_project_model::CargoTomlNotFoundError { .. }) =
115114
e.downcast_ref()
116115
{
117-
if !new_config.notifications.cargo_toml_not_found {
116+
if !config.notifications.cargo_toml_not_found {
118117
continue;
119118
}
120119
}
@@ -163,7 +162,7 @@ pub fn main_loop(
163162
config.lru_capacity,
164163
&globs,
165164
Watch(!config.use_client_watching),
166-
new_config,
165+
config,
167166
)
168167
};
169168

0 commit comments

Comments
 (0)