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/main_loop.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/main_loop.rs')
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 51fb2eb74..6d2475a59 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -108,38 +108,40 @@ impl GlobalState { | |||
108 | ); | 108 | ); |
109 | }; | 109 | }; |
110 | 110 | ||
111 | let save_registration_options = lsp_types::TextDocumentSaveRegistrationOptions { | 111 | if self.config.did_save_text_document_dynamic_registration() { |
112 | include_text: Some(false), | 112 | let save_registration_options = lsp_types::TextDocumentSaveRegistrationOptions { |
113 | text_document_registration_options: lsp_types::TextDocumentRegistrationOptions { | 113 | include_text: Some(false), |
114 | document_selector: Some(vec![ | 114 | text_document_registration_options: lsp_types::TextDocumentRegistrationOptions { |
115 | lsp_types::DocumentFilter { | 115 | document_selector: Some(vec![ |
116 | language: None, | 116 | lsp_types::DocumentFilter { |
117 | scheme: None, | 117 | language: None, |
118 | pattern: Some("**/*.rs".into()), | 118 | scheme: None, |
119 | }, | 119 | pattern: Some("**/*.rs".into()), |
120 | lsp_types::DocumentFilter { | 120 | }, |
121 | language: None, | 121 | lsp_types::DocumentFilter { |
122 | scheme: None, | 122 | language: None, |
123 | pattern: Some("**/Cargo.toml".into()), | 123 | scheme: None, |
124 | }, | 124 | pattern: Some("**/Cargo.toml".into()), |
125 | lsp_types::DocumentFilter { | 125 | }, |
126 | language: None, | 126 | lsp_types::DocumentFilter { |
127 | scheme: None, | 127 | language: None, |
128 | pattern: Some("**/Cargo.lock".into()), | 128 | scheme: None, |
129 | }, | 129 | pattern: Some("**/Cargo.lock".into()), |
130 | ]), | 130 | }, |
131 | }, | 131 | ]), |
132 | }; | 132 | }, |
133 | 133 | }; | |
134 | let registration = lsp_types::Registration { | 134 | |
135 | id: "textDocument/didSave".to_string(), | 135 | let registration = lsp_types::Registration { |
136 | method: "textDocument/didSave".to_string(), | 136 | id: "textDocument/didSave".to_string(), |
137 | register_options: Some(serde_json::to_value(save_registration_options).unwrap()), | 137 | method: "textDocument/didSave".to_string(), |
138 | }; | 138 | register_options: Some(serde_json::to_value(save_registration_options).unwrap()), |
139 | self.send_request::<lsp_types::request::RegisterCapability>( | 139 | }; |
140 | lsp_types::RegistrationParams { registrations: vec![registration] }, | 140 | self.send_request::<lsp_types::request::RegisterCapability>( |
141 | |_, _| (), | 141 | lsp_types::RegistrationParams { registrations: vec![registration] }, |
142 | ); | 142 | |_, _| (), |
143 | ); | ||
144 | } | ||
143 | 145 | ||
144 | self.fetch_workspaces_request(); | 146 | self.fetch_workspaces_request(); |
145 | self.fetch_workspaces_if_needed(); | 147 | self.fetch_workspaces_if_needed(); |