diff options
author | Aleksey Kladov <[email protected]> | 2021-01-06 17:43:46 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-01-06 18:22:24 +0000 |
commit | f8a056117898c56d34d1758455bc54df50e2e426 (patch) | |
tree | 429e2c7284476213432b66b02ab9b76f6525eb92 /crates/completion/src/config.rs | |
parent | 7ae4b8bdb62735ee767dff25ce1485ae8bffe199 (diff) |
Align config's API with usage
The config now is mostly immutable, optimize for that.
Diffstat (limited to 'crates/completion/src/config.rs')
-rw-r--r-- | crates/completion/src/config.rs | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/crates/completion/src/config.rs b/crates/completion/src/config.rs index 9f82b0346..b4439b7d1 100644 --- a/crates/completion/src/config.rs +++ b/crates/completion/src/config.rs | |||
@@ -4,7 +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 | ||
7 | use ide_db::helpers::insert_use::MergeBehavior; | 7 | use ide_db::helpers::{insert_use::MergeBehavior, SnippetCap}; |
8 | 8 | ||
9 | #[derive(Clone, Debug, PartialEq, Eq)] | 9 | #[derive(Clone, Debug, PartialEq, Eq)] |
10 | pub struct CompletionConfig { | 10 | pub struct CompletionConfig { |
@@ -15,27 +15,3 @@ pub struct CompletionConfig { | |||
15 | pub snippet_cap: Option<SnippetCap>, | 15 | pub snippet_cap: Option<SnippetCap>, |
16 | pub merge: Option<MergeBehavior>, | 16 | pub merge: Option<MergeBehavior>, |
17 | } | 17 | } |
18 | |||
19 | impl CompletionConfig { | ||
20 | pub fn allow_snippets(&mut self, yes: bool) { | ||
21 | self.snippet_cap = if yes { Some(SnippetCap { _private: () }) } else { None } | ||
22 | } | ||
23 | } | ||
24 | |||
25 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
26 | pub struct SnippetCap { | ||
27 | _private: (), | ||
28 | } | ||
29 | |||
30 | impl Default for CompletionConfig { | ||
31 | fn default() -> Self { | ||
32 | CompletionConfig { | ||
33 | enable_postfix_completions: true, | ||
34 | enable_autoimport_completions: true, | ||
35 | add_call_parenthesis: true, | ||
36 | add_call_argument_snippets: true, | ||
37 | snippet_cap: Some(SnippetCap { _private: () }), | ||
38 | merge: Some(MergeBehavior::Full), | ||
39 | } | ||
40 | } | ||
41 | } | ||