Skip to main content

CompletionItem

Struct CompletionItem 

Source
#[non_exhaustive]
pub struct CompletionItem { pub label: String, pub kind: CompletionKind, pub detail: Option<String>, pub doc: Option<String>, pub insert: InsertText, pub replace: Option<Range<u32>>, pub sort_key: String, pub retrigger: bool, }
Expand description

One structured completion item. #[non_exhaustive] with a new() + with_* builder chain, so adding a field never breaks an app that builds these: construct with CompletionItem::new, then layer on optional detail/doc/replace/sort-key/retrigger.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§label: String

The text shown in the popup row (and the default filter/insert text).

§kind: CompletionKind

The item’s category (drives the row icon/color).

§detail: Option<String>

Short type/shape hint, rendered right-aligned in the popup row.

§doc: Option<String>

Plain-text documentation, rendered as a plain block in the popup; markdown rendering lives in the hover popup, not here.

§insert: InsertText

What accepting the item inserts (plain text or a snippet).

§replace: Option<Range<u32>>

Absolute byte range to replace; None = the word range recomputed live at accept time (the word may have grown since the request).

§sort_key: String

Tier prefix + label, sorted lexicographically: 0_ params (required before optional), 1_ symbols, 2_ constructs, 3_ keywords. Defaults to the label when not set explicitly.

§retrigger: bool

When set, accepting the item fires exactly one Manual re-request after the transaction commits (e.g. param= reopens the popup in value position).

Implementations§

Source§

impl CompletionItem

Source

pub fn new( label: impl Into<String>, kind: CompletionKind, insert: InsertText, ) -> Self

A minimal item: label, kind, and insertion. sort_key defaults to the label; detail/doc/replace default absent; retrigger false.

Source

pub fn plain(label: impl Into<String>, kind: CompletionKind) -> Self

Convenience: a plain-text item whose insertion equals its label.

Source

pub fn with_detail(self, detail: impl Into<String>) -> Self

Set the right-aligned type/shape hint.

Source

pub fn with_doc(self, doc: impl Into<String>) -> Self

Set the plain-text documentation block.

Source

pub fn with_replace(self, replace: Range<u32>) -> Self

Override the replace range (default = the live word range at accept time).

Source

pub fn with_sort_key(self, sort_key: impl Into<String>) -> Self

Set the sort key (tier prefix + label); defaults to the label.

Source

pub fn with_retrigger(self, retrigger: bool) -> Self

Mark the item to fire one Manual re-request after acceptance commits.

Trait Implementations§

Source§

impl Clone for CompletionItem

Source§

fn clone(&self) -> CompletionItem

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 CompletionItem

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.

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.