Skip to main content

Module completion

Module completion 

Source
Expand description

LSP completion source (CSM.8a / CSM.8b).

LspCompletionSource is the AsyncCompletionSource impl that the lsp-completion-mode contributes. It owns an LspSupervisorHandle and is wired into the ActiveCompletionSources cache via the mode’s completion_sources() contribution. The source’s produce_async future fans out across attached servers, dedupes by (label, kind), and pushes one RawCandidate per item into the supplied [CandidateSink]. Each candidate carries an CandidateData::Extension payload whose bytes are a JSON-encoded LspCompletionMeta; the host decodes the payload at accept / docs / commit-char time via decode_meta.

Structs§

LspCompletionMeta
LSP-sourced insert-completion candidate metadata. Carried inside the RawCandidate’s CandidateData::Extension payload as a JSON blob (see encode_meta / decode_meta). Replaces the pre-CSM.8b host-side sidecar – the candidate IS the metadata; the host decodes on demand.
LspCompletionMode
lsp-completion-mode – LSP-driven insert-mode completion (CSM.8a). M.6.0 declared it as a marker minor; CSM.8a makes it source-contributing. Holds the LspSupervisorHandle so the contributed source can fan out to attached servers. popup_filter_chord = Some('o') ⇒ <C-o> inside completion-popup-mode narrows the popup to LSP only (CSM.K2).
LspCompletionSource
CSM.8a stub. Holds the supervisor handle so CSM.8b can move the fan-out into produce_async without changing the mode’s public surface. Today the future is a no-op.

Constants§

LSP_COMPLETION_KIND_ID
Extension::kind_id discriminant for LSP-sourced candidates. Values 0-99 reserved for first-party host data (snippet uses 2); plugins use 1000+. The host’s decoder checks this id before attempting decode_meta.

Functions§

decode_meta
Decode a payload produced by encode_meta. Returns None when the bytes don’t deserialise as LspCompletionMeta – the candidate’s kind_id may not be ours (plugin source colliding on the kind, or a stray payload), or the wire format may have drifted across versions.
encode_meta
Encode meta to a JSON byte blob suitable for embedding in a RawCandidate’s CandidateData::Extension::payload. Errors are caller-handled by panicking in the source’s produce path – a serialize failure on lsp-types output indicates a malformed item, which the supervisor should have rejected before we got here.
register_lsp_completion_mode
Register lsp-completion-mode against registry. Called from the App’s boot path alongside crate::modes::register_lsp_log_modes; the supervisor handle is shared so source produce + host accept-path read the same data.