]> git.lizzy.rs Git - rust.git/commitdiff
Honor snippet capability
authorAleksey Kladov <aleksey.kladov@gmail.com>
Fri, 24 Apr 2020 00:39:07 +0000 (02:39 +0200)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Fri, 24 Apr 2020 00:41:07 +0000 (02:41 +0200)
closes #2518

crates/ra_ide/src/completion/completion_config.rs
crates/rust-analyzer/src/config.rs

index 6cf7ed6e4c97d7875716c699e358698965d88df2..71b49ace8bfb0e38a746ff34866d9f3a3cfb46dc 100644 (file)
@@ -12,6 +12,12 @@ pub struct CompletionConfig {
     pub snippet_cap: Option<SnippetCap>,
 }
 
+impl CompletionConfig {
+    pub fn allow_snippets(&mut self, yes: bool) {
+        self.snippet_cap = if yes { Some(SnippetCap { _private: () }) } else { None }
+    }
+}
+
 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
 pub struct SnippetCap {
     _private: (),
index 33d7c95a802fa61c9d9a360bc1a0dfdb5fb587ef..715eddadb6872587676a572187e0f8ffe792f6d0 100644 (file)
@@ -215,5 +215,13 @@ pub fn update_caps(&mut self, caps: &TextDocumentClientCapabilities) {
         if let Some(value) = caps.folding_range.as_ref().and_then(|it| it.line_folding_only) {
             self.client_caps.line_folding_only = value
         }
+        self.completion.allow_snippets(false);
+        if let Some(completion) = &caps.completion {
+            if let Some(completion_item) = &completion.completion_item {
+                if let Some(value) = completion_item.snippet_support {
+                    self.completion.allow_snippets(value);
+                }
+            }
+        }
     }
 }