feat: correctly fallback to notify if the clinet-side file watching is not supported
This commit is contained in:
parent
3d63abf1d8
commit
b9417f3483
@ -723,7 +723,10 @@ pub fn files(&self) -> FilesConfig {
|
|||||||
FilesConfig {
|
FilesConfig {
|
||||||
watcher: match self.data.files_watcher.as_str() {
|
watcher: match self.data.files_watcher.as_str() {
|
||||||
"notify" => FilesWatcher::Notify,
|
"notify" => FilesWatcher::Notify,
|
||||||
"client" | _ => FilesWatcher::Client,
|
"client" if self.did_change_watched_files_dynamic_registration() => {
|
||||||
|
FilesWatcher::Client
|
||||||
|
}
|
||||||
|
_ => FilesWatcher::Notify,
|
||||||
},
|
},
|
||||||
exclude: self.data.files_excludeDirs.iter().map(|it| self.root_path.join(it)).collect(),
|
exclude: self.data.files_excludeDirs.iter().map(|it| self.root_path.join(it)).collect(),
|
||||||
}
|
}
|
||||||
|
@ -241,38 +241,33 @@ fn eq_ignore_build_data<'a>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
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: self
|
||||||
watchers: self
|
.workspaces
|
||||||
.workspaces
|
.iter()
|
||||||
.iter()
|
.flat_map(|ws| ws.to_roots())
|
||||||
.flat_map(|ws| ws.to_roots())
|
.filter(|it| it.is_local)
|
||||||
.filter(|it| it.is_local)
|
.flat_map(|root| {
|
||||||
.flat_map(|root| {
|
root.include.into_iter().flat_map(|it| {
|
||||||
root.include.into_iter().flat_map(|it| {
|
[
|
||||||
[
|
format!("{}/**/*.rs", it.display()),
|
||||||
format!("{}/**/*.rs", it.display()),
|
format!("{}/**/Cargo.toml", it.display()),
|
||||||
format!("{}/**/Cargo.toml", it.display()),
|
format!("{}/**/Cargo.lock", it.display()),
|
||||||
format!("{}/**/Cargo.lock", it.display()),
|
]
|
||||||
]
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.map(|glob_pattern| lsp_types::FileSystemWatcher {
|
})
|
||||||
glob_pattern,
|
.map(|glob_pattern| lsp_types::FileSystemWatcher { glob_pattern, kind: None })
|
||||||
kind: None,
|
.collect(),
|
||||||
})
|
};
|
||||||
.collect(),
|
let registration = lsp_types::Registration {
|
||||||
};
|
id: "workspace/didChangeWatchedFiles".to_string(),
|
||||||
let registration = lsp_types::Registration {
|
method: "workspace/didChangeWatchedFiles".to_string(),
|
||||||
id: "workspace/didChangeWatchedFiles".to_string(),
|
register_options: Some(serde_json::to_value(registration_options).unwrap()),
|
||||||
method: "workspace/didChangeWatchedFiles".to_string(),
|
};
|
||||||
register_options: Some(serde_json::to_value(registration_options).unwrap()),
|
self.send_request::<lsp_types::request::RegisterCapability>(
|
||||||
};
|
lsp_types::RegistrationParams { registrations: vec![registration] },
|
||||||
self.send_request::<lsp_types::request::RegisterCapability>(
|
|_, _| (),
|
||||||
lsp_types::RegistrationParams { registrations: vec![registration] },
|
);
|
||||||
|_, _| (),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut change = Change::new();
|
let mut change = Change::new();
|
||||||
|
Loading…
Reference in New Issue
Block a user