From 2347c03dcd717fbc0648c1e4e3d64a886217de5d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 10 Mar 2020 18:39:17 +0100 Subject: Introduce CompletionOptions --- crates/ra_ide/src/completion.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/src/completion.rs') diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs index c378c2c62..a27e0fc15 100644 --- a/crates/ra_ide/src/completion.rs +++ b/crates/ra_ide/src/completion.rs @@ -33,6 +33,23 @@ pub use crate::completion::completion_item::{ CompletionItem, CompletionItemKind, InsertTextFormat, }; +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct CompletionOptions { + pub enable_postfix_completions: bool, + pub add_call_parenthesis: bool, + pub add_call_argument_snippets: bool, +} + +impl Default for CompletionOptions { + fn default() -> Self { + CompletionOptions { + enable_postfix_completions: true, + add_call_parenthesis: true, + add_call_argument_snippets: true, + } + } +} + /// Main entry point for completion. We run completion as a two-phase process. /// /// First, we look at the position and collect a so-called `CompletionContext. @@ -55,8 +72,12 @@ pub use crate::completion::completion_item::{ /// `foo` *should* be present among the completion variants. Filtering by /// identifier prefix/fuzzy match should be done higher in the stack, together /// with ordering of completions (currently this is done by the client). -pub(crate) fn completions(db: &RootDatabase, position: FilePosition) -> Option { - let ctx = CompletionContext::new(db, position)?; +pub(crate) fn completions( + db: &RootDatabase, + position: FilePosition, + opts: &CompletionOptions, +) -> Option { + let ctx = CompletionContext::new(db, position, opts)?; let mut acc = Completions::default(); -- cgit v1.2.3