Skip to main content

InsertSource

Trait InsertSource 

Source
pub trait InsertSource:
    Send
    + Sync
    + Debug {
    // Required methods
    fn id(&self) -> &SourceId;
    fn produce(&self, ctx: &InsertContext<'_>) -> Vec<RawCandidate>;

    // Provided methods
    fn default_priority(&self) -> u32 { ... }
    fn auto_trigger(&self) -> bool { ... }
    fn trigger_chars(&self, _ctx: &InsertContext<'_>) -> Vec<char> { ... }
}
Expand description

A sync candidate source. Implementations are cheap to call – the aggregator invokes produce() once per query change (a re-filter on each keystroke). Async sources don’t implement this trait; they are orchestrated host-side via tokio::spawn + a channel that pushes into InsertCompletionState.raw directly.

Default priority is 100; the host’s [completion.source.<id>] config can override.

Required Methods§

Source

fn id(&self) -> &SourceId

Stable id (e.g. "gen:buffer-words"). Surfaces in :set completion.source.<id>.priority=… keys.

Source

fn produce(&self, ctx: &InsertContext<'_>) -> Vec<RawCandidate>

Produce raw candidates for the supplied context. Cheap (microseconds); the aggregator calls this whenever the query changes.

Provided Methods§

Source

fn default_priority(&self) -> u32

Default priority bucket. Higher buckets sort above lower; the ranker adds it to the matcher’s score.

Source

fn auto_trigger(&self) -> bool

Whether this source contributes when the popup opens via auto-trigger (identifier threshold). Manual triggers and <C-x>-prefixed dedicated chords always include every enabled source.

Source

fn trigger_chars(&self, _ctx: &InsertContext<'_>) -> Vec<char>

Server-advertised characters that should fire this source. Empty = “I’m fine on identifier-threshold or manual.” The LSP source’s bridge populates this from completionProvider.triggerCharacters.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§