Skip to main content

CompletionSourceContribution

Struct CompletionSourceContribution 

Source
pub struct CompletionSourceContribution {
    pub id: SourceId,
    pub default_priority: u32,
    pub auto_trigger: bool,
    pub trigger_chars: Vec<char>,
    pub popup_filter_chord: Option<char>,
    pub accepts_non_word_query: bool,
    pub kind: CompletionSourceKind,
}
Expand description

One source’s contribution to the active completion set for a buffer. Returned from lattice_mode::Mode::completion_sources (the new declarative contribution method on Mode – see lattice-mode). The aggregator’s per-buffer cache holds a list of these; the active-source resolver in the host recomputes the cache only on mode-activation / -deactivation transitions, so the keystroke-frequency refilter pays an O(1) buffer-local lookup.

Cloning is cheap: every field is either Copy or an Arc.

Fields§

§id: SourceId

Stable identifier ("gen:lsp-completion", "gen:buffer-words", …). Surfaces in :set completion.source.<id>.priority=..., in :describe-mode <name> output, and in the per-language sources allowlist.

§default_priority: u32

Default priority bucket. Higher buckets sort above lower; the host’s per-buffer priority_for_source override may replace this value before the ranker reads it.

§auto_trigger: bool

Whether typing identifier chars opens the popup with this source included. Manual triggers (<C-x><C-o> / <C-Space>) always include every enabled source.

§trigger_chars: Vec<char>

Server-advertised or source-supplied characters that should fire this source. Empty = “fire on identifier- threshold or manual.” The LSP source populates this from completionProvider.triggerCharacters at activation.

§popup_filter_chord: Option<char>

CSM.K1 (insert-completion.md §12): single-char filter chord inside completion-popup-mode. Some('o') ⇒ <C-o> while the popup is live narrows the rendered candidate set to only this source’s contributions (mnemonic: o for omni → LSP). None ⇒ no dedicated chord; the source still participates in the unfiltered all-sources view + any TOML allowlist.

CSM.K2 wires the binding – completion-popup-mode’s keymap walks ActiveCompletionSources at push time and registers <C-?> for every contribution whose popup_filter_chord is Some. Until then this field is plumbing: CSM.4 – CSM.8 fill it in for each migrated source so CSM.K2 can ship one slice’s worth of behavior at a time.

§accepts_non_word_query: bool

OR.7: this source can still match after a non-word character is typed, so the popup must not dismiss on one.

The host closes the popup as soon as the query contains a byte that is not a word character — the right default, because a query is normally an identifier and vim closes there too. It is wrong for a source whose candidates are phrases: org-roam completes node titles like “Honey Garlic Chicken Breast”, and the popup used to die at the first space, which made every multi-word title unreachable.

Per-source rather than global because the dismissal is right for buffer-words and identifiers; the host ORs the flag across the round, so one phrase source keeps the popup alive and every other source simply stops matching, which is the correct outcome for them.

§kind: CompletionSourceKind

The actual producer – sync or async.

Trait Implementations§

Source§

impl Clone for CompletionSourceContribution

Source§

fn clone(&self) -> CompletionSourceContribution

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CompletionSourceContribution

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more