aboutsummaryrefslogtreecommitdiff
path: root/crates/completion/src/config.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-10-26 19:06:34 +0000
committerGitHub <[email protected]>2020-10-26 19:06:34 +0000
commitd10e2a04c8a5ff157acd95bc7458d36d9f396390 (patch)
treefb68b034d7e56053e5d1b4302e2996f64b024e11 /crates/completion/src/config.rs
parentd01e412eb1572676a33ad145f3370a7157dbc9df (diff)
parent357bf0cedc658b7c95952324fda4bbe7f41a3e6a (diff)
Merge #6351
6351: Organized completions r=popzxc a=popzxc This PR continues the work on refactoring of the `completions` crate. In this episode: - Actual completions methods are encapsulated into `completions` module, so they aren't mixed with the rest of the code. - Name duplication was removed (`complete_attribute` => `completions::attribute`, `completion_context` => `context`). - `Completions` structure was moved from `item` module to the `completions`. - `presentation` module was removed, as it was basically a module with `impl` for `Completions`. - Code approaches were a bit unified here and there. Co-authored-by: Igor Aleksanov <[email protected]>
Diffstat (limited to 'crates/completion/src/config.rs')
-rw-r--r--crates/completion/src/config.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/crates/completion/src/config.rs b/crates/completion/src/config.rs
new file mode 100644
index 000000000..71b49ace8
--- /dev/null
+++ b/crates/completion/src/config.rs
@@ -0,0 +1,35 @@
1//! Settings for tweaking completion.
2//!
3//! The fun thing here is `SnippetCap` -- this type can only be created in this
4//! module, and we use to statically check that we only produce snippet
5//! completions if we are allowed to.
6
7#[derive(Clone, Debug, PartialEq, Eq)]
8pub struct CompletionConfig {
9 pub enable_postfix_completions: bool,
10 pub add_call_parenthesis: bool,
11 pub add_call_argument_snippets: bool,
12 pub snippet_cap: Option<SnippetCap>,
13}
14
15impl CompletionConfig {
16 pub fn allow_snippets(&mut self, yes: bool) {
17 self.snippet_cap = if yes { Some(SnippetCap { _private: () }) } else { None }
18 }
19}
20
21#[derive(Clone, Copy, Debug, PartialEq, Eq)]
22pub struct SnippetCap {
23 _private: (),
24}
25
26impl Default for CompletionConfig {
27 fn default() -> Self {
28 CompletionConfig {
29 enable_postfix_completions: true,
30 add_call_parenthesis: true,
31 add_call_argument_snippets: true,
32 snippet_cap: Some(SnippetCap { _private: () }),
33 }
34 }
35}