pub enum CompletionType {
Auto,
File,
Line(CompletionScope),
Word(CompletionScope),
}Expand description
What type of phrase we are completing.
Typically, most editors use the cursor’s context to determine what to complete. In those cases, CompletionType::Auto is sufficient, but other variants are provided here to accomodate keybindings that specifically complete context-independent values.
Variants§
Auto
Determine what to complete by the buffer context.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, EditorAction};
let ct = CompletionType::Auto;
let style = CompletionStyle::Prefix;
let display = CompletionDisplay::List;
let act: Action = EditorAction::Complete(style, ct, display).into();
assert_eq!(act, action!("complete -s prefix -T auto -D list"));File
Complete a filename.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, EditorAction};
let ct = CompletionType::File;
let style = CompletionStyle::Prefix;
let display = CompletionDisplay::List;
let act: Action = EditorAction::Complete(style, ct, display).into();
assert_eq!(act, action!("complete -s prefix -T file -D list"));Line(CompletionScope)
Complete the rest of the line.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, EditorAction};
let ct = CompletionType::Line(CompletionScope::Global);
let style = CompletionStyle::Prefix;
let display = CompletionDisplay::List;
let act: Action = EditorAction::Complete(style, ct, display).into();
assert_eq!(act, action!("complete -s prefix -T (line global) -D list"));Word(CompletionScope)
Complete the current word.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, EditorAction};
let ct = CompletionType::Word(CompletionScope::Buffer);
let style = CompletionStyle::Prefix;
let display = CompletionDisplay::List;
let act: Action = EditorAction::Complete(style, ct, display).into();
assert_eq!(act, action!("complete -s prefix -T (word buffer) -D list"));Trait Implementations§
Source§impl Clone for CompletionType
impl Clone for CompletionType
Source§fn clone(&self) -> CompletionType
fn clone(&self) -> CompletionType
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CompletionType
impl Debug for CompletionType
Source§impl PartialEq for CompletionType
impl PartialEq for CompletionType
impl Eq for CompletionType
impl StructuralPartialEq for CompletionType
Auto Trait Implementations§
impl Freeze for CompletionType
impl RefUnwindSafe for CompletionType
impl Send for CompletionType
impl Sync for CompletionType
impl Unpin for CompletionType
impl UnwindSafe for CompletionType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more