Skip to main content

Crate bynkc_lsp

Crate bynkc_lsp 

Source
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:

  • Backend holds the project state: root path (the directory containing bynk.toml), parsed configuration, and an in-memory map of open files. State is guarded by a tokio::sync::RwLock.
  • Document changes trigger recompile_and_publish which re-runs the compiler (via bynk_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 codeAction computation β€” quick-fixes from the structured bynk_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/documentSymbol request (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 inlayHint computation β€” 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, and documentHighlight.
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/foldingRange and textDocument/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 πŸ”’
DocumentState πŸ”’
In-memory document state.
SerKey πŸ”’
v0.34 (ADR 0067): a serializable mirror of bynk_check::index::SymbolKey for round-tripping through CallHierarchyItem.data β€” the index kind isn’t Serialize, so the kind travels as its display() string.
State πŸ”’
Mutable project state.

ConstantsΒ§

SERVER_NAME πŸ”’
SERVER_VERSION πŸ”’

FunctionsΒ§

cursor_byte_offset πŸ”’
The byte offset of an LSP (line, character) position in text. Mirrors the line_prefix computation (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 of initialize so 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::Completion to an LSP CompletionItem. Stash the document URI in each item’s data so completion_resolve can look the symbol up β€” a resolve request carries only the item, not a position.
to_completion_item πŸ”’