CompletionProvider

Trait CompletionProvider 

Source
pub trait CompletionProvider {
    // Required methods
    fn completions(
        &self,
        text: &Rope,
        offset: usize,
        trigger: CompletionContext,
        window: &mut Window,
        cx: &mut Context<'_, InputState>,
    ) -> Task<Result<CompletionResponse>>;
    fn is_completion_trigger(
        &self,
        offset: usize,
        new_text: &str,
        cx: &mut Context<'_, InputState>,
    ) -> bool;

    // Provided method
    fn resolve_completions(
        &self,
        _completion_indices: Vec<usize>,
        _completions: Rc<RefCell<Box<[Completion]>>>,
        _: &mut Context<'_, InputState>,
    ) -> Task<Result<bool>> { ... }
}
Expand description

A trait for providing code completions based on the current input state and context.

Required Methods§

Source

fn completions( &self, text: &Rope, offset: usize, trigger: CompletionContext, window: &mut Window, cx: &mut Context<'_, InputState>, ) -> Task<Result<CompletionResponse>>

Fetches completions based on the given byte offset.

  • The offset is in bytes of current cursor.

textDocument/completion

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_completion

Source

fn is_completion_trigger( &self, offset: usize, new_text: &str, cx: &mut Context<'_, InputState>, ) -> bool

Determines if the completion should be triggered based on the given byte offset.

This is called on the main thread.

Provided Methods§

Source

fn resolve_completions( &self, _completion_indices: Vec<usize>, _completions: Rc<RefCell<Box<[Completion]>>>, _: &mut Context<'_, InputState>, ) -> Task<Result<bool>>

Implementors§