diff options
Diffstat (limited to 'crates/rust-analyzer/src/config.rs')
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index b700d025f..7c02a507c 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<AbsPathBuf>, | ||
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,23 @@ 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 | .collect(); | ||
338 | self.data = ConfigData::from_json(json); | 349 | self.data = ConfigData::from_json(json); |
339 | } | 350 | } |
340 | 351 | ||
@@ -387,6 +398,10 @@ impl Config { | |||
387 | } | 398 | } |
388 | } | 399 | } |
389 | 400 | ||
401 | pub fn detached_files(&self) -> &[AbsPathBuf] { | ||
402 | &self.detached_files | ||
403 | } | ||
404 | |||
390 | pub fn did_save_text_document_dynamic_registration(&self) -> bool { | 405 | pub fn did_save_text_document_dynamic_registration(&self) -> bool { |
391 | let caps = | 406 | let caps = |
392 | try_or!(self.caps.text_document.as_ref()?.synchronization.clone()?, Default::default()); | 407 | try_or!(self.caps.text_document.as_ref()?.synchronization.clone()?, Default::default()); |