Expand description
Per-buffer LSP response caches + outcome enums.
Phase 5.2: extracted from lattice-ui-tui::app to their proper
home in lattice-lsp. Every type here is renderer-agnostic
pure data describing the result of an LSP request – the
shape the App’s per-tick drain expects after the spawned task
delivers its response.
Cache types are keyed on (BufferId, document_version) so the
pump can invalidate-by-version when the buffer mutates.
Outcome enums carry the same key plus the actual payload (or
a sentinel variant for Empty / NoProvider / etc.) so the
drain can route to the appropriate echo / apply path.
lattice-ui-tui::app re-exports every type from this module
so existing crate::app::HoverOutcome etc. references in the
host crate’s source continue to resolve unchanged.
Structs§
- Code
Action Row - One row of a code-action picker. Carries the action title,
kind glyph, and the original
CodeActionpayload (or its rawCommand-only form). Action items survive on the App across the request → picker accept gap so the resolve / apply path can read them by index. - Completion
Item Row - One row of an LSP completion picker. Carries the item
label, kind glyph, optional detail blurb, and the insert
text.
replace_rangeis the byte range in the active line to splice the insert text over. - Completion
Resolve Outcome - Drain payload for
completionItem/resolve(Phase 4.2.g.3). CSM.8b.5:meta_indexis now the index of the fired candidate within state.raw’s LSP-row sequence; the drain decodes that row’s payload, applies the resolved fields, re-encodes in place. Multiple resolves in flight (selection change → cancel prior → fire new) cancel via the supplied token. - Decoded
Semantic Token - 4.4.h: one decoded LSP semantic token, expanded from the
server’s relative-position varint encoding into absolute
positions.
token_typeis the canonical name from the server’s legend (e.g."keyword","function") so the renderer can pick a style without looking up the index.lengthis in utf-16 code units per the LSP spec. - Document
Highlight Cache - 4.4.e: cached
textDocument/documentHighlightresult anchored at a specific buffer + cursor position. The renderer readshighlightsto paint a soft overlay; the pump comparescursorto the live cursor to decide whether to invalidate and re-request. - LspCode
Lens Cache - 4.5.d: per-buffer cache of
textDocument/codeLensresults. Filled by the pump on doc-version change or afterworkspace/codeLens/refreshevicts the entry. The:lsp-code-lenspicker reads the cache; accept routes the chosen lens’scommandthroughworkspace/executeCommand. - LspDocument
Color Cache - 4.5.e: per-buffer cache of color literals + their resolved
values. Filled by the per-tick pump on document-version
change; consumed by
:lsp-color-presentation. Renderer swatch overlay queued – today the cache only feeds the picker. - LspDocument
Links Cache - 4.5.c: per-buffer cache of
textDocument/documentLinkresponses. Filled by the pump on document-version change;gxwalks the entries looking for the first link whose range covers the cursor and follows it. Cache invalidates when the version changes. - LspFolds
Cache - 4.4.f: cached
textDocument/foldingRangeresponse for one buffer.document_versionis the buffer’s [lattice_core::Document] version at the time the request was issued; the pump compares it against the live version to decide whether to refresh. - LspInlay
Hint Cache - 4.4.g: cached
textDocument/inlayHintresponse for one buffer. Keyed on(BufferId, document_version); pump invalidates when the version changes.hintsare sorted by position so the renderer can stop scanning once it walks past the current line. - LspPull
Diagnostics Cache - 4.4.j: cached
textDocument/diagnosticstate per buffer.result_idis what the server issued on the previous response; threading it back inprevious_result_idlets the server answerUnchangedwhen nothing moved. - LspSelection
Chain - 4.4.e: cached
textDocument/selectionRangechain anchored at a specific buffer + cursor position. FlatVec<Range>(innermost first) instead of the LSP linked-list shape so the operator can index into it in O(1). Captured once on the first:lsp-expand-regionafter a fresh cursor; reused across subsequent expand/shrink steps until the cursor moves outsideranges[0](the innermost) or the buffer changes. - LspSemantic
Tokens Cache - 4.4.h: cached decoded
textDocument/semanticTokens/fullresponse for one buffer. Same shape as the other LSP per-buffer caches: keyed on(BufferId, document_version), invalidated by the pump when the version changes. - Symbol
Row - One row of a document-symbol / workspace-symbol picker.
Carries the symbol’s name, kind, depth (for in-document
hierarchy indent), and the location to jump to. Built
host-side from the LSP
DocumentSymbolResponse/Vec<SymbolInformation>so the picker doesn’t depend on lsp-types.
Enums§
- Code
Action Outcome - Outcome of a
:code-actionsrequest. Drained per frame. - Code
Lens Outcome - 4.5.d: outcome of an in-flight
textDocument/codeLensrequest. Carries the server id so the eviction-on-refresh path can match by server. - Completion
Outcome - Outcome of a
textDocument/completionrequest. - Document
Color Outcome - 4.5.e: outcome of an in-flight
documentColorrequest. - Document
Highlight Outcome - 4.4.e: in-flight
documentHighlightrequest outcome. - Document
Links Outcome - 4.5.c: outcome of an in-flight
textDocument/documentLinkrequest.Emptyfor server responses that returned no links (still updates the cache so we don’t keep re-issuing for the same version). - Folding
Range Outcome - 4.4.f: in-flight
foldingRangerequest outcome. - Format
Outcome - Outcome of a
:format/:format-rangerequest. Drained per frame; the App applies the edits as one undo unit or echoes the appropriate failure / no-op state. - Hover
Outcome - Result of a
K(LSP hover) request, sent from the spawned task to the App’s main thread. Carrying the no-result variants explicitly (instead of just dropping the channel send) lets the drain echo a clear message so the user always gets feedback onK. - Inlay
Hint Outcome - 4.4.g: in-flight
inlayHintrequest outcome. Therequested_*_linepair rides through so the drain can seat the cache with the range that actually produced these hints (matters for the viewport pump – subsequent scrolls reuse the cache only while the viewport sits inside that range). - LspNav
Kind - Which navigation request flavour produced an in-flight nav
response (Phase 4.2.c). All four share the same dispatch
shape (per-server
Vec<Location>merge + dedup + jump-or- list) – the kind only changes the LSP method called and the user-facing “no X found” echo. - Pull
Diagnostics Outcome - 4.4.j: in-flight
textDocument/diagnosticrequest outcome.Fullmeans “here are the diagnostics” (apply to the layer);Unchangedmeans “nothing moved since the previousresult_id” (no-op on the layer, just refresh the cache’s version).Emptyis the “no server / cancelled / error” path – still seats a cache entry with the current version so the pump doesn’t re-fire on the next tick without an actual edit. - References
Outcome - Result of a
gr(LSP references) request. Carries the symbol-under-cursor verbatim so the rendered help buffer’s title readsReferences for "foo"and the user has confirmation of what they searched for. - Rename
Outcome - Outcome of a
:renamerequest. The success arm pre-flattens the WorkspaceEdit into a per-fileVec<TextEdit>map so the App-side apply path doesn’t have to walk lsp-types’ enum shapes.NoProviderechoes when no attached server advertisesrenameProvider;NotRenameablewhen prepareRename refused;Emptywhen the rename succeeded but the server returned no edits. - Selection
Range Outcome - 4.4.e: outcome of an in-flight
textDocument/selectionRangerequest. The drain consumes one of these per response and either seats the chain intoApp::lsp_selection_chainor surfaces an error echo.pending_stepcarries whether the triggering invocation was:lsp-expand-regionor the first step of:lsp-shrink-region(the latter is rare – shrink without an existing chain is a user error – but the drain handles it uniformly). - Selection
Range Step - Semantic
Tokens Outcome - 4.4.h: in-flight
semanticTokens/fullrequest outcome. 4.4.i extends with theDeltavariant for thefull/deltapath. - Signature
Help Outcome - Outcome of a
textDocument/signatureHelprequest. The response carries multiple signatures (one per overload) plus the active signature/parameter indices. We collapse to the active overload + parameter highlight for the popup body. - Symbols
Outcome - Outcome of a document-symbol / workspace-symbol request – drained per frame and either opens a picker or echoes.
Functions§
- apply_
semantic_ token_ edits - 4.4.i: apply a server-issued
SemanticTokensEditscript toraw_datain place. Each edit specifies a start index (into the previous token vec), a count to delete, and a replacement slice. Edits are applied in order; the server constructs them against the index space of the input vec. - decode_
semantic_ tokens - 4.4.h: decode the LSP semantic-tokens stream into
absolute-position tokens. Format per LSP §3.17.6: each
token’s
delta_lineis relative to the previous token’s line;delta_startis relative to the previous token’s start when on the same line, otherwise relative to column 0.token_types/token_modifiersare the server’s legend slices – indexes outside the legend are dropped (defense-in-depth; real servers don’t emit out-of-range).