aboutsummaryrefslogtreecommitdiff
path: root/crates/completion/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/completion/src/config.rs')
-rw-r--r--crates/completion/src/config.rs48
1 files changed, 1 insertions, 47 deletions
diff --git a/crates/completion/src/config.rs b/crates/completion/src/config.rs
index 30577dc11..b4439b7d1 100644
--- a/crates/completion/src/config.rs
+++ b/crates/completion/src/config.rs
@@ -4,8 +4,7 @@
4//! module, and we use to statically check that we only produce snippet 4//! module, and we use to statically check that we only produce snippet
5//! completions if we are allowed to. 5//! completions if we are allowed to.
6 6
7use ide_db::helpers::insert_use::MergeBehavior; 7use ide_db::helpers::{insert_use::MergeBehavior, SnippetCap};
8use rustc_hash::FxHashSet;
9 8
10#[derive(Clone, Debug, PartialEq, Eq)] 9#[derive(Clone, Debug, PartialEq, Eq)]
11pub struct CompletionConfig { 10pub struct CompletionConfig {
@@ -15,49 +14,4 @@ pub struct CompletionConfig {
15 pub add_call_argument_snippets: bool, 14 pub add_call_argument_snippets: bool,
16 pub snippet_cap: Option<SnippetCap>, 15 pub snippet_cap: Option<SnippetCap>,
17 pub merge: Option<MergeBehavior>, 16 pub merge: Option<MergeBehavior>,
18 /// A set of capabilities, enabled on the client and supported on the server.
19 pub active_resolve_capabilities: FxHashSet<CompletionResolveCapability>,
20}
21
22/// A resolve capability, supported on the server.
23/// If the client registers any completion resolve capabilities,
24/// the server is able to render completion items' corresponding fields later,
25/// not during an initial completion item request.
26/// See https://github.com/rust-analyzer/rust-analyzer/issues/6366 for more details.
27#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)]
28pub enum CompletionResolveCapability {
29 Documentation,
30 Detail,
31 AdditionalTextEdits,
32}
33
34impl CompletionConfig {
35 pub fn allow_snippets(&mut self, yes: bool) {
36 self.snippet_cap = if yes { Some(SnippetCap { _private: () }) } else { None }
37 }
38
39 /// Whether the completions' additional edits are calculated when sending an initional completions list
40 /// or later, in a separate resolve request.
41 pub fn resolve_additional_edits_lazily(&self) -> bool {
42 self.active_resolve_capabilities.contains(&CompletionResolveCapability::AdditionalTextEdits)
43 }
44}
45
46#[derive(Clone, Copy, Debug, PartialEq, Eq)]
47pub struct SnippetCap {
48 _private: (),
49}
50
51impl Default for CompletionConfig {
52 fn default() -> Self {
53 CompletionConfig {
54 enable_postfix_completions: true,
55 enable_autoimport_completions: true,
56 add_call_parenthesis: true,
57 add_call_argument_snippets: true,
58 snippet_cap: Some(SnippetCap { _private: () }),
59 merge: Some(MergeBehavior::Full),
60 active_resolve_capabilities: FxHashSet::default(),
61 }
62 }
63} 17}