mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 14:13:58 +00:00
Honor client's dynamic registration caps
cc https://github.com/rust-analyzer/rust-analyzer/pull/5516#issuecomment-757520828
This commit is contained in:
parent
035fed5f9f
commit
bb453edebe
3 changed files with 70 additions and 51 deletions
|
@ -334,6 +334,18 @@ impl Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn did_save_text_document_dynamic_registration(&self) -> bool {
|
||||||
|
let caps =
|
||||||
|
try_or!(self.caps.text_document.as_ref()?.synchronization.clone()?, Default::default());
|
||||||
|
caps.did_save == Some(true) && caps.dynamic_registration == Some(true)
|
||||||
|
}
|
||||||
|
pub fn did_change_watched_files_dynamic_registration(&self) -> bool {
|
||||||
|
try_or!(
|
||||||
|
self.caps.workspace.as_ref()?.did_change_watched_files.as_ref()?.dynamic_registration?,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn location_link(&self) -> bool {
|
pub fn location_link(&self) -> bool {
|
||||||
try_or!(self.caps.text_document.as_ref()?.definition?.link_support?, false)
|
try_or!(self.caps.text_document.as_ref()?.definition?.link_support?, false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,7 @@ impl GlobalState {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if self.config.did_save_text_document_dynamic_registration() {
|
||||||
let save_registration_options = lsp_types::TextDocumentSaveRegistrationOptions {
|
let save_registration_options = lsp_types::TextDocumentSaveRegistrationOptions {
|
||||||
include_text: Some(false),
|
include_text: Some(false),
|
||||||
text_document_registration_options: lsp_types::TextDocumentRegistrationOptions {
|
text_document_registration_options: lsp_types::TextDocumentRegistrationOptions {
|
||||||
|
@ -140,6 +141,7 @@ impl GlobalState {
|
||||||
lsp_types::RegistrationParams { registrations: vec![registration] },
|
lsp_types::RegistrationParams { registrations: vec![registration] },
|
||||||
|_, _| (),
|
|_, _| (),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
self.fetch_workspaces_request();
|
self.fetch_workspaces_request();
|
||||||
self.fetch_workspaces_if_needed();
|
self.fetch_workspaces_if_needed();
|
||||||
|
|
|
@ -182,6 +182,7 @@ impl GlobalState {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let FilesWatcher::Client = self.config.files().watcher {
|
if let FilesWatcher::Client = self.config.files().watcher {
|
||||||
|
if self.config.did_change_watched_files_dynamic_registration() {
|
||||||
let registration_options = lsp_types::DidChangeWatchedFilesRegistrationOptions {
|
let registration_options = lsp_types::DidChangeWatchedFilesRegistrationOptions {
|
||||||
watchers: workspaces
|
watchers: workspaces
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -190,7 +191,10 @@ impl GlobalState {
|
||||||
.flat_map(|root| {
|
.flat_map(|root| {
|
||||||
root.include.into_iter().map(|it| format!("{}/**/*.rs", it.display()))
|
root.include.into_iter().map(|it| format!("{}/**/*.rs", it.display()))
|
||||||
})
|
})
|
||||||
.map(|glob_pattern| lsp_types::FileSystemWatcher { glob_pattern, kind: None })
|
.map(|glob_pattern| lsp_types::FileSystemWatcher {
|
||||||
|
glob_pattern,
|
||||||
|
kind: None,
|
||||||
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
};
|
};
|
||||||
let registration = lsp_types::Registration {
|
let registration = lsp_types::Registration {
|
||||||
|
@ -203,6 +207,7 @@ impl GlobalState {
|
||||||
|_, _| (),
|
|_, _| (),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut change = Change::new();
|
let mut change = Change::new();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue