diff options
author | Aleksey Kladov <[email protected]> | 2021-01-10 19:38:35 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-01-10 19:38:35 +0000 |
commit | bb453edebe477ab754d6c78e11db1bf3af08833c (patch) | |
tree | 262275f1d401de42d0410d87feb8c789d9f0015c /crates/rust-analyzer/src/reload.rs | |
parent | 035fed5f9f7c062da7d23190dab1a7021fd48a5d (diff) |
Honor client's dynamic registration caps
cc https://github.com/rust-analyzer/rust-analyzer/pull/5516#issuecomment-757520828
Diffstat (limited to 'crates/rust-analyzer/src/reload.rs')
-rw-r--r-- | crates/rust-analyzer/src/reload.rs | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index accf2ef8c..97e20362f 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs | |||
@@ -182,26 +182,31 @@ impl GlobalState { | |||
182 | } | 182 | } |
183 | 183 | ||
184 | if let FilesWatcher::Client = self.config.files().watcher { | 184 | if let FilesWatcher::Client = self.config.files().watcher { |
185 | let registration_options = lsp_types::DidChangeWatchedFilesRegistrationOptions { | 185 | if self.config.did_change_watched_files_dynamic_registration() { |
186 | watchers: workspaces | 186 | let registration_options = lsp_types::DidChangeWatchedFilesRegistrationOptions { |
187 | .iter() | 187 | watchers: workspaces |
188 | .flat_map(ProjectWorkspace::to_roots) | 188 | .iter() |
189 | .filter(|it| it.is_member) | 189 | .flat_map(ProjectWorkspace::to_roots) |
190 | .flat_map(|root| { | 190 | .filter(|it| it.is_member) |
191 | root.include.into_iter().map(|it| format!("{}/**/*.rs", it.display())) | 191 | .flat_map(|root| { |
192 | }) | 192 | root.include.into_iter().map(|it| format!("{}/**/*.rs", it.display())) |
193 | .map(|glob_pattern| lsp_types::FileSystemWatcher { glob_pattern, kind: None }) | 193 | }) |
194 | .collect(), | 194 | .map(|glob_pattern| lsp_types::FileSystemWatcher { |
195 | }; | 195 | glob_pattern, |
196 | let registration = lsp_types::Registration { | 196 | kind: None, |
197 | id: "workspace/didChangeWatchedFiles".to_string(), | 197 | }) |
198 | method: "workspace/didChangeWatchedFiles".to_string(), | 198 | .collect(), |
199 | register_options: Some(serde_json::to_value(registration_options).unwrap()), | 199 | }; |
200 | }; | 200 | let registration = lsp_types::Registration { |
201 | self.send_request::<lsp_types::request::RegisterCapability>( | 201 | id: "workspace/didChangeWatchedFiles".to_string(), |
202 | lsp_types::RegistrationParams { registrations: vec![registration] }, | 202 | method: "workspace/didChangeWatchedFiles".to_string(), |
203 | |_, _| (), | 203 | register_options: Some(serde_json::to_value(registration_options).unwrap()), |
204 | ); | 204 | }; |
205 | self.send_request::<lsp_types::request::RegisterCapability>( | ||
206 | lsp_types::RegistrationParams { registrations: vec![registration] }, | ||
207 | |_, _| (), | ||
208 | ); | ||
209 | } | ||
205 | } | 210 | } |
206 | 211 | ||
207 | let mut change = Change::new(); | 212 | let mut change = Change::new(); |