Skip to content

Commit 7410cfa

Browse files
bors[bot]matklad
andauthored
Merge #4117
4117: Honor snippet capability r=matklad a=matklad closes #2518 bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 3a0a708 + 440cd05 commit 7410cfa

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

crates/ra_ide/src/completion/completion_config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ pub struct CompletionConfig {
1212
pub snippet_cap: Option<SnippetCap>,
1313
}
1414

15+
impl CompletionConfig {
16+
pub fn allow_snippets(&mut self, yes: bool) {
17+
self.snippet_cap = if yes { Some(SnippetCap { _private: () }) } else { None }
18+
}
19+
}
20+
1521
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
1622
pub struct SnippetCap {
1723
_private: (),

crates/rust-analyzer/src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,13 @@ impl Config {
215215
if let Some(value) = caps.folding_range.as_ref().and_then(|it| it.line_folding_only) {
216216
self.client_caps.line_folding_only = value
217217
}
218+
self.completion.allow_snippets(false);
219+
if let Some(completion) = &caps.completion {
220+
if let Some(completion_item) = &completion.completion_item {
221+
if let Some(value) = completion_item.snippet_support {
222+
self.completion.allow_snippets(value);
223+
}
224+
}
225+
}
218226
}
219227
}

0 commit comments

Comments
 (0)