Merge #7241
7241: Honor client's dynamic registration caps r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
60c501fa19
@ -334,6 +334,18 @@ pub fn linked_projects(&self) -> Vec<LinkedProject> {
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
try_or!(self.caps.text_document.as_ref()?.definition?.link_support?, false)
|
||||
}
|
||||
|
@ -108,6 +108,7 @@ fn run(mut self, inbox: Receiver<lsp_server::Message>) -> Result<()> {
|
||||
);
|
||||
};
|
||||
|
||||
if self.config.did_save_text_document_dynamic_registration() {
|
||||
let save_registration_options = lsp_types::TextDocumentSaveRegistrationOptions {
|
||||
include_text: Some(false),
|
||||
text_document_registration_options: lsp_types::TextDocumentRegistrationOptions {
|
||||
@ -140,6 +141,7 @@ fn run(mut self, inbox: Receiver<lsp_server::Message>) -> Result<()> {
|
||||
lsp_types::RegistrationParams { registrations: vec![registration] },
|
||||
|_, _| (),
|
||||
);
|
||||
}
|
||||
|
||||
self.fetch_workspaces_request();
|
||||
self.fetch_workspaces_if_needed();
|
||||
|
@ -182,6 +182,7 @@ pub(crate) fn switch_workspaces(&mut self, workspaces: Vec<anyhow::Result<Projec
|
||||
}
|
||||
|
||||
if let FilesWatcher::Client = self.config.files().watcher {
|
||||
if self.config.did_change_watched_files_dynamic_registration() {
|
||||
let registration_options = lsp_types::DidChangeWatchedFilesRegistrationOptions {
|
||||
watchers: workspaces
|
||||
.iter()
|
||||
@ -190,7 +191,10 @@ pub(crate) fn switch_workspaces(&mut self, workspaces: Vec<anyhow::Result<Projec
|
||||
.flat_map(|root| {
|
||||
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(),
|
||||
};
|
||||
let registration = lsp_types::Registration {
|
||||
@ -203,6 +207,7 @@ pub(crate) fn switch_workspaces(&mut self, workspaces: Vec<anyhow::Result<Projec
|
||||
|_, _| (),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let mut change = Change::new();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user