Expand description
bynkc-lsp β Bynk Language Server.
Implements the LSP capabilities listed in design/bynk-lsp-spec.md Β§4.3:
synchronisation (Full), diagnostics, hover, go-to-definition, formatting,
range formatting, document symbols, references, rename, code actions,
workspace symbols, document highlights, and file watching. Built on
tower-lsp.
Architecture:
Backendholds the project state: root path (the directory containingbynk.toml), parsed configuration, and an in-memory map of open files. State is guarded by atokio::sync::RwLock.- Document changes trigger
recompile_and_publishwhich re-runs the compiler (viabynk_ide::diagnose) and publishes resulting diagnostics. - Hover and definition consult the parsed AST for the file under the cursor; both are best-effort (return None for unrecognised positions).
- Formatting delegates to
bynk_fmt::format_source.
ModulesΒ§
- code_
actions π - v0.26 (ADR 0054): pure
codeActioncomputation β quick-fixes from the structuredbynk_syntax::error::Suggestions riding on a cached analysis roundβs diagnostics. - completion π
- Completion for the cursor, keyed off the line up to it.
- document_
symbols π - Document-symbol tree for the LSP
textDocument/documentSymbolrequest (v1.1; LSP spec Β§3.7). - index_
queries π - v0.25 (ADR 0053): pure queries over the project binding index.
- inlay_
hints π - v0.27 (ADR 0056): pure
inlayHintcomputation β inferred-type hints from a cached analysis roundβs harvested hint set. - locals_
nav π - v0.31 (ADR 0064): locals navigation β resolve the local binding under the
cursor and all its sites (its definition plus every use that resolves to
it), for
references, go-to-definition, anddocumentHighlight. - position π
- Byte-offset β LSP position conversion.
- project π
- Bynk project configuration (
bynk.toml). - publish π
- v0.24 (ADR 0052): the project-wide publish plan β a pure function so the clear semantics are unit-tested without an LSP transport (the JSON-RPC harness is deferred to the first interactive feature; recorded in the v0.24 proposal).
- signature_
help π - v0.32 (ADR 0065): signature help β
textDocument/signatureHelp. - structure π
- v0.37 (ADR 0070): structural ranges β
textDocument/foldingRangeandtextDocument/selectionRange. - symbols π
- Symbol lookups for hover and go-to-definition.
StructsΒ§
- Analysis π
- v0.25 (ADR 0053): one analysis roundβs retained outputs β the binding index plus the snapshots its spans are offsets into, and the open-doc versions captured when the overlay was built (rename emits versioned edits against exactly these versions).
- Backend π
- Document
State π - In-memory document state.
- SerKey π
- v0.34 (ADR 0067): a serializable mirror of
bynk_check::index::SymbolKeyfor round-tripping throughCallHierarchyItem.dataβ the index kind isnβtSerialize, so the kind travels as itsdisplay()string. - State π
- Mutable project state.
ConstantsΒ§
- SERVER_
NAME π - SERVER_
VERSION π
FunctionsΒ§
- cursor_
byte_ πoffset - The byte offset of an LSP
(line, character)position intext. Mirrors theline_prefixcomputation (character as a byte index β ASCII-faithful). - lsp_
symbol_ πkind - main π
- make_
diagnostic π - server_
capabilities π - The advertised capability set β
design/bynk-lsp-spec.mdΒ§4.3. Split out ofinitializeso the advertisement is unit-testable without transport. - stamp_
resolve_ πdata - Index symbol kind β LSP symbol kind, aligned with the document-symbol
outlineβs choices (capability=INTERFACE, service/agent=CLASS,
provider=OBJECT). The index does not distinguish type shapes, so every
type maps to STRUCT.
Map a
completion::Completionto an LSPCompletionItem. Stash the document URI in each itemβsdatasocompletion_resolvecan look the symbol up β a resolve request carries only the item, not a position. - to_
completion_ πitem