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§

agent_state_request
#2196: bynk/agentStateModel — the agent state view’s custom LSP request (agent-state-views track, slice 2).
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.
explain_request
#2098: bynk/explain — the in-editor, offline explanation of a diagnostic code, and the “Explain …” code action that opens it.
extract
v0.213 (ADR 0239): textDocument/codeAction extract-variable — CodeActionKind::REFACTOR_EXTRACT. The smallest expression node whose span fully contains the requested selection is bound to a fresh let inserted immediately above its enclosing statement (or block tail), and the selection’s span is replaced with the new name.
fill_arms
#2100 slice 3: the fill-match-arms quick fix. It adds an arm for every variant (or Bool value, or the _ an unbounded literal match or an extensible enum needs) that a non-exhaustive match leaves uncovered.
fix_all
#2100 slice 6: the source.fixAll.bynk code action — apply every machine-applicable diagnostic suggestion in a file as one edit.
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.
inline
#2100 slice 1: the inline-variable refactor (refactor.inline). It replaces every use of a let binding with the binding’s initialiser and deletes the let.
organise
#2100 slice 5: the source.organizeImports code action — organise a unit header’s uses and consumes clauses.
position
Byte-offset ↔ LSP position conversion.
provider_stub
#2100 slice 4: generate a provider stub. For a capability declared in this file that nothing in its context provides, the action scaffolds provides Cap = CapImpl { … } right below the declaration, with every operation’s signature copied and its body a typed default.
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.
transport
#1667: a framing pump in front of tower-lsp’s transport.
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.