diff options
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 8 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 67 |
2 files changed, 32 insertions, 43 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index ad62571ef..8947ccf07 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -128,7 +128,6 @@ pub struct ClientCapsConfig { | |||
128 | pub hover_actions: bool, | 128 | pub hover_actions: bool, |
129 | pub status_notification: bool, | 129 | pub status_notification: bool, |
130 | pub signature_help_label_offsets: bool, | 130 | pub signature_help_label_offsets: bool, |
131 | pub dynamic_watched_files: bool, | ||
132 | } | 131 | } |
133 | 132 | ||
134 | impl Config { | 133 | impl Config { |
@@ -291,13 +290,6 @@ impl Config { | |||
291 | } | 290 | } |
292 | 291 | ||
293 | pub fn update_caps(&mut self, caps: &ClientCapabilities) { | 292 | pub fn update_caps(&mut self, caps: &ClientCapabilities) { |
294 | if let Some(ws_caps) = caps.workspace.as_ref() { | ||
295 | if let Some(did_change_watched_files) = ws_caps.did_change_watched_files.as_ref() { | ||
296 | self.client_caps.dynamic_watched_files = | ||
297 | did_change_watched_files.dynamic_registration.unwrap_or(false); | ||
298 | } | ||
299 | } | ||
300 | |||
301 | if let Some(doc_caps) = caps.text_document.as_ref() { | 293 | if let Some(doc_caps) = caps.text_document.as_ref() { |
302 | if let Some(value) = doc_caps.definition.as_ref().and_then(|it| it.link_support) { | 294 | if let Some(value) = doc_caps.definition.as_ref().and_then(|it| it.link_support) { |
303 | self.client_caps.location_link = value; | 295 | self.client_caps.location_link = value; |
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index b44fd9eb4..e95d4157c 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -106,41 +106,38 @@ impl GlobalState { | |||
106 | ); | 106 | ); |
107 | }; | 107 | }; |
108 | 108 | ||
109 | if self.config.client_caps.dynamic_watched_files { | 109 | let save_registration_options = lsp_types::TextDocumentSaveRegistrationOptions { |
110 | let save_registration_options = lsp_types::TextDocumentSaveRegistrationOptions { | 110 | include_text: Some(false), |
111 | include_text: Some(false), | 111 | text_document_registration_options: lsp_types::TextDocumentRegistrationOptions { |
112 | text_document_registration_options: lsp_types::TextDocumentRegistrationOptions { | 112 | document_selector: Some(vec![ |
113 | document_selector: Some(vec![ | 113 | lsp_types::DocumentFilter { |
114 | lsp_types::DocumentFilter { | 114 | language: None, |
115 | language: None, | 115 | scheme: None, |
116 | scheme: None, | 116 | pattern: Some("**/*.rs".into()), |
117 | pattern: Some("**/*.rs".into()), | 117 | }, |
118 | }, | 118 | lsp_types::DocumentFilter { |
119 | lsp_types::DocumentFilter { | 119 | language: None, |
120 | language: None, | 120 | scheme: None, |
121 | scheme: None, | 121 | pattern: Some("**/Cargo.toml".into()), |
122 | pattern: Some("**/Cargo.toml".into()), | 122 | }, |
123 | }, | 123 | lsp_types::DocumentFilter { |
124 | lsp_types::DocumentFilter { | 124 | language: None, |
125 | language: None, | 125 | scheme: None, |
126 | scheme: None, | 126 | pattern: Some("**/Cargo.lock".into()), |
127 | pattern: Some("**/Cargo.lock".into()), | 127 | }, |
128 | }, | 128 | ]), |
129 | ]), | 129 | }, |
130 | }, | 130 | }; |
131 | }; | 131 | |
132 | 132 | let registration = lsp_types::Registration { | |
133 | let registration = lsp_types::Registration { | 133 | id: "textDocument/didSave".to_string(), |
134 | id: "textDocument/didSave".to_string(), | 134 | method: "textDocument/didSave".to_string(), |
135 | method: "textDocument/didSave".to_string(), | 135 | register_options: Some(serde_json::to_value(save_registration_options).unwrap()), |
136 | register_options: Some(serde_json::to_value(save_registration_options).unwrap()), | 136 | }; |
137 | }; | 137 | self.send_request::<lsp_types::request::RegisterCapability>( |
138 | 138 | lsp_types::RegistrationParams { registrations: vec![registration] }, | |
139 | self.send_request::<lsp_types::request::RegisterCapability>( | 139 | |_, _| (), |
140 | lsp_types::RegistrationParams { registrations: vec![registration] }, | 140 | ); |
141 | |_, _| (), | ||
142 | ); | ||
143 | } | ||
144 | 141 | ||
145 | self.fetch_workspaces(); | 142 | self.fetch_workspaces(); |
146 | 143 | ||