Skip to main content

lattice_completion/
lib.rs

1//! Pluggable completion pipeline (DESIGN.md §5.11.3).
2//!
3//! Powers `:`-line completion and (eventually) any minibuffer-shaped
4//! prompt the editor surfaces. Architecturally vertico-shaped:
5//! generators, matchers, rankers, annotators are independent
6//! pluggable stages registered against a [`CompletionRegistry`].
7//! Plugin authors target the public traits to extend any stage.
8//!
9//! - Generators ([`CandidateGenerator`]) produce raw candidates.
10//! - The matcher ([`CandidateMatcher`]) filters + scores them
11//!   against a query.
12//! - The ranker ([`CandidateRanker`]) reorders the matched set.
13//! - Annotators ([`CandidateAnnotator`]) add display metadata.
14//!
15//! The host (the editor crate, not this one) wires the pipeline
16//! into the cmdline and the renderer. This crate stays
17//! pure-traits + types + reusable built-ins; tests run without any
18//! UI dependency.
19//!
20//! Source provenance for every registered stage is captured via
21//! `#[track_caller]` (DESIGN.md §5.11.1) so
22//! `:describe-completion-source <name>` resolves to the registration
23//! site.
24
25pub mod builtins;
26pub mod cache;
27pub mod candidate;
28pub mod insert;
29pub mod orderless;
30pub mod path;
31pub mod pipeline;
32pub mod registry;
33pub mod slot;
34pub mod source;
35pub mod source_registration;
36pub mod traits;
37
38pub use crate::builtins::annotators::{
39    DocSnippetAnnotator, KeybindingAnnotator, KeybindingSource, KeymapReverseLookup,
40    KindLabelAnnotator,
41};
42pub use crate::builtins::matchers::{
43    FuzzyDisplayMatcher, FuzzyMatcher, OrderlessDisplayMatcher, PrefixMatcher, SubstringMatcher,
44};
45pub use crate::builtins::rankers::{AlphabeticalRanker, MruRanker, ScoreRanker};
46pub use crate::builtins::{CompletionBuiltins, populate};
47pub use crate::cache::GeneratorCache;
48pub use crate::candidate::{
49    Annotation, AnnotationColumns, AnnotationSegment, CacheKey, CandidateData, CandidateKind,
50    DisplaySpan, MatchScore, RawCandidate, RenderedCandidate, ScoredCandidate,
51};
52pub use crate::insert::{
53    BufferWordsSource, CompletionTrigger, DocPopupState, FuzzyInsertMatcher, InsertCompletionState,
54    InsertContext, InsertRanker, InsertSource, LSP_COMPLETION_SOURCE_ID, PATH_SOURCE_ID,
55    PerLanguageOverrides, SNIPPET_SOURCE_ID, SourceId, TREE_SITTER_SYMBOL_SOURCE_ID,
56    canonical_source_id, fuzzy_match, per_language_defaults,
57};
58pub use crate::orderless::{
59    ORDER_BONUS, OrderlessComponent, orderless_match, parse_orderless_query,
60};
61pub use crate::path::PathCompletionSource;
62pub use crate::pipeline::CompletionPipeline;
63pub use crate::registry::{
64    AnnotatorId, CompletionRegistry, GeneratorId, MatcherId, RankerId, RegisteredAnnotator,
65    RegisteredGenerator, RegisteredMatcher, RegisteredRanker,
66};
67pub use crate::slot::{CommandLineSlot, current_slot};
68pub use crate::source::{
69    AsyncCompletionOutcome, AsyncCompletionSource, CandidateSink, CompletionSourceContribution,
70    CompletionSourceKind, InsertContextSnapshot, SyncCompletionSource, line_before_cursor,
71};
72pub use crate::source_registration::{
73    AcceptAction, AcceptHandler, AcceptToken, ArgsSchema, CandidateSourceKind, CustomAcceptPayload,
74    DefaultAcceptHandler, SourceRegistration, SourceSpec,
75};
76pub use crate::traits::{
77    CandidateAnnotator, CandidateGenerator, CandidateMatcher, CandidateRanker, GenerateContext,
78};