Skip to main content

Crate bynk_lsp

Crate bynk_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 and -type/-impl, formatting, document symbols, completion, signature help, references, rename, code actions, code lens, call hierarchy, document links, inlay hints, semantic tokens, workspace symbols, real multi-root workspace folders, and server-registered file watching. Built on tower-lsp.

Architecture:

  • Backend holds the server state (behind a tokio::sync::RwLock): a map of projects keyed by discovered root — each with its own config, analysis round, and published set — plus the workspace-folder discovery seeds and the client-global map of open documents. A request routes by URI to its project (its nearest enclosing bynk.toml); a file under none is single-file.
  • Document changes trigger schedule_diagnostics, one generation-based debounce (a project-wide round via bynk_ide::diagnose_project_with, or single-file bynk_ide::diagnose) that publishes the 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.

Slice C (the [lib] seam): this crate exposes a library target so its integration tests can use bynk_lsp::… instead of #[path]-including source modules. The pub mods below are exposed for that testing, not as a stable API — bynk-lsp is a language-server binary and makes no library compatibility promise.

Modules§

architecture_request
#851: bynk/architectureModel — the architecture-map custom LSP request.
capability_fixes
#852 (capability-aware quick-fixes): the codeAction producers that repair resolution/boundary diagnostics by editing a unit’s header — add consumes for an unconsumed cross-context call, and the Bynk analogue of auto-import (add uses/add consumes) for an unresolved name that the binding index places in a mixable commons or a consumable context.
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
Re-exports bynk-ide’s completion logic (#808) — moved there so it’s reachable from bynk-wasm too, which can’t depend on this crate’s tower-lsp/tokio stack. See bynk_ide::completion for the real module.
documentation_request
#847: bynk/documentationModel — the documentation-view custom LSP request.
hover
#611 (ADR 0190): hover’s resolution ladder, as one pure function.
index_queries
v0.25 (ADR 0053): pure queries over the project binding index.
position
Byte-offset ↔ LSP position conversion.
sequence_request
#846: bynk/sequenceModel — the sequence-diagram custom LSP request.
symbols
Re-exports bynk-ide’s symbol logic (#808) — moved there so it’s reachable from bynk-wasm too, which can’t depend on this crate’s tower-lsp/tokio stack. See bynk_ide::symbols for the real module.
wire_contract_request
#855: bynk/wireContract — the wire-contract-peek custom LSP request.

Structs§

Backend

Functions§

run
Slice C: the server’s entry point, moved out of main.rs so the crate has a [lib] target. main.rs is now a thin shim over this.