Expand description
Phase 5.5.LSP.1 step 2: pure LSP utility helpers, lifted from
lattice_ui_tui::app. These functions translate between the
editor’s internal byte-indexed shapes and lsp-types’s wire
shapes (UTF-16 column positions, hover-content markdown). They
depend only on lattice_core::Buffer, lattice_grammar::Position,
and lattice_lsp::position – all host-side – so they have no
reason to live in the renderer crate.
lattice_ui_tui::app re-exports both names under their original
crate::app:: paths so the existing ~18 call sites (App-side LSP
request helpers) continue to compile unchanged through the rest
of the LSP cluster migration.
Functions§
- app_
to_ lsp_ position - Convert an editor-side
Position(line + utf-8 byte column) into the LSP-sidelattice_lsp::lsp_types::Position(line + utf-16 code- unit column). ReturnsNonewhen the line index is past the end of the buffer – e.g. cursor on a sentinel row past EOF. - call_
hierarchy_ to_ row - Render one
CallHierarchyItem(the caller / callee) as aSymbolRowfor the picker. The item’sdetail(if any) plus the originating callable’s name ride incontainer. Phase 5.8.AD.2: hoisted from TUI App. - code_
action_ kind_ glyph - Map an LSP
CodeActionKindto a one-char glyph used in the picker margin (🛠,♻,↗, etc.). Unknown / custom kinds and bareCommandpayloads land on?. Phase 5.8.AD.2. - completion_
kind_ glyph - 5.5.LSP.4: single-character glyph for an LSP
CompletionItemKind. Same shape assymbol_kind_glyphbut maps the completion-item kind enum (which is wider – snippets, keywords, folders, etc.). Used by the LSP completion picker / insert-completion overlay row marginalia. - cursor_
inside_ range - Is the editor cursor inside the half-open LSP
range? Compares only by (line, character) in LSP utf-16 space because the range is LSP-shape; the host cursor is assumed converted. Phase 5.8.AD.2: hoisted from TUI App. - definition_
response_ to_ locations - 5.5.LSP.2: flatten an LSP
GotoDefinitionResponse(Scalar / Array / Link) into a uniformVec<Location>. TheLinkshape carries richer per-result info (origin selection range used to highlight the symbol the user clicked); we drop it for now and keep the target location only – the App’s jump path is position-only. When 4.2.d’s picker buffer lands the link metadata (e.g.,target_selection_rangefor narrower jump destinations) becomes useful and this function gains a richer sibling. - flatten_
document_ symbol_ response - 5.5.LSP.5: flatten an LSP
DocumentSymbolResponseinto a pre-renderedVec<SymbolRow>. The legacyFlat(Vec<SymbolInformation>)variant is one row per symbol with no nesting; the modernNested(Vec<DocumentSymbol>)variant carrieschildren: Vec<DocumentSymbol>, walked depth-first to preserve outline ordering. - flatten_
selection_ range_ chain - 4.4.e: flatten an LSP
SelectionRange(linked list viaparent) into aVec<Range>ordered innermost-first. Phase 5.8.AD.2: hoisted from TUI App. - hover_
contents_ to_ markdown - prepare_
rename_ placeholder - Extract a placeholder name from a
PrepareRenameResponse, if the server supplied one. Used when the user invoked:renamewithout a name. Phase 5.8.AD.2. - range_
covers - Render an LSP
HoverContentspayload to a markdown string the renderer’s hover popup pipeline can highlight via the markdown grammar. - signature_
help_ to_ markdown - 5.5.LSP.4: render an LSP
SignatureHelppayload to a markdown string the popup renderer can display. Picks the active signature (server-suppliedactive_signatureindex, default 0) and inlines the active parameter’s documentation when present. Returns the empty string when the response carries no signatures – the caller surfaces “no signature info”. - symbol_
information_ to_ row - 5.5.LSP.5: project an LSP
SymbolInformation(legacy outline + workspace-symbol shape) into aSymbolRow. ReturnsNonewhen the location’s URI doesn’t resolve to a path. - symbol_
kind_ glyph - 5.5.LSP.5: single-character glyph for an LSP
SymbolKind. Picked to fit a fixed-width column in picker rows so the marginalia column stays aligned. Falls back to?for kinds we don’t have a specific glyph for. - type_
hierarchy_ to_ row - 4.5.b: render one
TypeHierarchyItem(a supertype or subtype of the cursor’s type) as a [SymbolRow] for the picker. Same projection ascall_hierarchy_to_rowbecause the item shape is identical. Phase 5.8.AD.2. - word_
under_ cursor - 5.5.LSP.2: extract the word-class span straddling
cursoron the cursor’s line. ReturnsNonewhen the cursor is not on a word character – “no symbol under cursor” is preferable to a label that jumps to a different identifier than the user pointed at. Used by the LSP nav / references dispatchers to label the tag-stack entry + the picker title. - workspace_
symbol_ to_ row - 5.5.LSP.5: convert a modern (LSP 3.17+)
WorkspaceSymbolinto aSymbolRow. When the symbol’slocationcame back as theWorkspaceLocation(URI-only) variant, firesworkspaceSymbol/resolveagainst the originating server to upgrade to a realLocationwithrange. ReturnsNonewhen the URI doesn’t map to a path; resolve failures fall back to(0, 0)so the row stays navigable.