|
9 | 9 |
|
10 | 10 | use std::{ffi::OsString, path::PathBuf}; |
11 | 11 |
|
12 | | -use lsp_types::TextDocumentClientCapabilities; |
| 12 | +use lsp_types::ClientCapabilities; |
13 | 13 | use ra_flycheck::FlycheckConfig; |
14 | 14 | use ra_ide::{CompletionConfig, InlayHintsConfig}; |
15 | 15 | use ra_project_model::CargoConfig; |
@@ -70,6 +70,7 @@ pub struct ClientCapsConfig { |
70 | 70 | pub line_folding_only: bool, |
71 | 71 | pub hierarchical_symbols: bool, |
72 | 72 | pub code_action_literals: bool, |
| 73 | + pub work_done_progress: bool, |
73 | 74 | } |
74 | 75 |
|
75 | 76 | impl Default for Config { |
@@ -208,30 +209,43 @@ impl Config { |
208 | 209 | } |
209 | 210 | } |
210 | 211 |
|
211 | | - pub fn update_caps(&mut self, caps: &TextDocumentClientCapabilities) { |
212 | | - if let Some(value) = caps.definition.as_ref().and_then(|it| it.link_support) { |
213 | | - self.client_caps.location_link = value; |
214 | | - } |
215 | | - if let Some(value) = caps.folding_range.as_ref().and_then(|it| it.line_folding_only) { |
216 | | - self.client_caps.line_folding_only = value |
217 | | - } |
218 | | - if let Some(value) = |
219 | | - caps.document_symbol.as_ref().and_then(|it| it.hierarchical_document_symbol_support) |
220 | | - { |
221 | | - self.client_caps.hierarchical_symbols = value |
222 | | - } |
223 | | - if let Some(value) = |
224 | | - caps.code_action.as_ref().and_then(|it| Some(it.code_action_literal_support.is_some())) |
225 | | - { |
226 | | - self.client_caps.code_action_literals = value; |
227 | | - } |
228 | | - self.completion.allow_snippets(false); |
229 | | - if let Some(completion) = &caps.completion { |
230 | | - if let Some(completion_item) = &completion.completion_item { |
231 | | - if let Some(value) = completion_item.snippet_support { |
232 | | - self.completion.allow_snippets(value); |
| 212 | + pub fn update_caps(&mut self, caps: &ClientCapabilities) { |
| 213 | + if let Some(doc_caps) = caps.text_document.as_ref() { |
| 214 | + if let Some(value) = doc_caps.definition.as_ref().and_then(|it| it.link_support) { |
| 215 | + self.client_caps.location_link = value; |
| 216 | + } |
| 217 | + if let Some(value) = doc_caps.folding_range.as_ref().and_then(|it| it.line_folding_only) |
| 218 | + { |
| 219 | + self.client_caps.line_folding_only = value |
| 220 | + } |
| 221 | + if let Some(value) = doc_caps |
| 222 | + .document_symbol |
| 223 | + .as_ref() |
| 224 | + .and_then(|it| it.hierarchical_document_symbol_support) |
| 225 | + { |
| 226 | + self.client_caps.hierarchical_symbols = value |
| 227 | + } |
| 228 | + if let Some(value) = doc_caps |
| 229 | + .code_action |
| 230 | + .as_ref() |
| 231 | + .and_then(|it| Some(it.code_action_literal_support.is_some())) |
| 232 | + { |
| 233 | + self.client_caps.code_action_literals = value; |
| 234 | + } |
| 235 | + self.completion.allow_snippets(false); |
| 236 | + if let Some(completion) = &doc_caps.completion { |
| 237 | + if let Some(completion_item) = &completion.completion_item { |
| 238 | + if let Some(value) = completion_item.snippet_support { |
| 239 | + self.completion.allow_snippets(value); |
| 240 | + } |
233 | 241 | } |
234 | 242 | } |
235 | 243 | } |
| 244 | + |
| 245 | + if let Some(window_caps) = caps.window.as_ref() { |
| 246 | + if let Some(value) = window_caps.work_done_progress { |
| 247 | + self.client_caps.work_done_progress = value; |
| 248 | + } |
| 249 | + } |
236 | 250 | } |
237 | 251 | } |
0 commit comments