diff options
Diffstat (limited to 'crates/rust-analyzer/src/config.rs')
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index b700d025f..570534c9a 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -236,6 +236,7 @@ impl Default for ConfigData { | |||
236 | pub struct Config { | 236 | pub struct Config { |
237 | caps: lsp_types::ClientCapabilities, | 237 | caps: lsp_types::ClientCapabilities, |
238 | data: ConfigData, | 238 | data: ConfigData, |
239 | detached_files: Vec<ProjectManifest>, | ||
239 | pub discovered_projects: Option<Vec<ProjectManifest>>, | 240 | pub discovered_projects: Option<Vec<ProjectManifest>>, |
240 | pub root_path: AbsPathBuf, | 241 | pub root_path: AbsPathBuf, |
241 | } | 242 | } |
@@ -328,13 +329,24 @@ pub struct WorkspaceSymbolConfig { | |||
328 | 329 | ||
329 | impl Config { | 330 | impl Config { |
330 | pub fn new(root_path: AbsPathBuf, caps: ClientCapabilities) -> Self { | 331 | pub fn new(root_path: AbsPathBuf, caps: ClientCapabilities) -> Self { |
331 | Config { caps, data: ConfigData::default(), discovered_projects: None, root_path } | 332 | Config { |
333 | caps, | ||
334 | data: ConfigData::default(), | ||
335 | detached_files: Vec::new(), | ||
336 | discovered_projects: None, | ||
337 | root_path, | ||
338 | } | ||
332 | } | 339 | } |
333 | pub fn update(&mut self, json: serde_json::Value) { | 340 | pub fn update(&mut self, mut json: serde_json::Value) { |
334 | log::info!("updating config from JSON: {:#}", json); | 341 | log::info!("updating config from JSON: {:#}", json); |
335 | if json.is_null() || json.as_object().map_or(false, |it| it.is_empty()) { | 342 | if json.is_null() || json.as_object().map_or(false, |it| it.is_empty()) { |
336 | return; | 343 | return; |
337 | } | 344 | } |
345 | self.detached_files = get_field::<Vec<PathBuf>>(&mut json, "detachedFiles", None, "[]") | ||
346 | .into_iter() | ||
347 | .map(AbsPathBuf::assert) | ||
348 | .map(ProjectManifest::DetachedFile) | ||
349 | .collect(); | ||
338 | self.data = ConfigData::from_json(json); | 350 | self.data = ConfigData::from_json(json); |
339 | } | 351 | } |
340 | 352 | ||
@@ -387,6 +399,10 @@ impl Config { | |||
387 | } | 399 | } |
388 | } | 400 | } |
389 | 401 | ||
402 | pub fn detached_files(&self) -> &[ProjectManifest] { | ||
403 | &self.detached_files | ||
404 | } | ||
405 | |||
390 | pub fn did_save_text_document_dynamic_registration(&self) -> bool { | 406 | pub fn did_save_text_document_dynamic_registration(&self) -> bool { |
391 | let caps = | 407 | let caps = |
392 | try_or!(self.caps.text_document.as_ref()?.synchronization.clone()?, Default::default()); | 408 | try_or!(self.caps.text_document.as_ref()?.synchronization.clone()?, Default::default()); |