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§
Sourcefn id(&self) -> &SourceId
fn id(&self) -> &SourceId
Stable id (e.g. "gen:buffer-words"). Surfaces in
:set completion.source.<id>.priority=… keys.
Sourcefn produce(&self, ctx: &InsertContext<'_>) -> Vec<RawCandidate>
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§
Sourcefn default_priority(&self) -> u32
fn default_priority(&self) -> u32
Default priority bucket. Higher buckets sort above lower; the ranker adds it to the matcher’s score.
Sourcefn auto_trigger(&self) -> bool
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.
Sourcefn trigger_chars(&self, _ctx: &InsertContext<'_>) -> Vec<char>
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".