#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.label: StringThe text shown in the popup row (and the default filter/insert text).
kind: CompletionKindThe 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: InsertTextWhat 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: StringTier prefix + label, sorted lexicographically: 0_ params (required
before optional), 1_ symbols, 2_ constructs, 3_ keywords. Defaults
to the label when not set explicitly.
retrigger: boolWhen 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
impl CompletionItem
Sourcepub fn new(
label: impl Into<String>,
kind: CompletionKind,
insert: InsertText,
) -> Self
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.
Sourcepub fn plain(label: impl Into<String>, kind: CompletionKind) -> Self
pub fn plain(label: impl Into<String>, kind: CompletionKind) -> Self
Convenience: a plain-text item whose insertion equals its label.
Sourcepub fn with_detail(self, detail: impl Into<String>) -> Self
pub fn with_detail(self, detail: impl Into<String>) -> Self
Set the right-aligned type/shape hint.
Sourcepub fn with_replace(self, replace: Range<u32>) -> Self
pub fn with_replace(self, replace: Range<u32>) -> Self
Override the replace range (default = the live word range at accept time).
Sourcepub fn with_sort_key(self, sort_key: impl Into<String>) -> Self
pub fn with_sort_key(self, sort_key: impl Into<String>) -> Self
Set the sort key (tier prefix + label); defaults to the label.
Sourcepub fn with_retrigger(self, retrigger: bool) -> Self
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
impl Clone for CompletionItem
Source§fn clone(&self) -> CompletionItem
fn clone(&self) -> CompletionItem
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more