Architecture
noyalib-lsp is a Language Server Protocol implementation for YAML,
built on noyalib’s parser, CST formatter, and error locations. The
transport is stdio with the standard Content-Length framing.
Layers
src/main.rsis the transport shim: it frames messages and drivesServer::handle_message. All behaviour lives in the library socargo testcovers it without an editor.src/lib.rsholdsServer, which owns the document store of open buffers, andhandle_message, which parses the JSON-RPC envelope, routes by method, and returns aHandleOutcomeof one of three kinds:reply(a response),notify(a server-initiated notification such as diagnostics), orsilent. The capability set advertised atinitializeis fixed:textDocumentSync(full),textDocument/formatting, andtextDocument/hover, withtextDocument/publishDiagnosticspushed after each change.src/diagnostics.rsturns noyalib parse errors into LSP diagnostic objects (collect) and wraps them in thepublishDiagnosticsnotification (publish_diagnostics).src/format.rsimplements formatting as a singleTextEditreplacing the whole document with noyalib’s CST formatter output (full_document_edits). One edit keeps the response self-contained; the client needs no cross-document reasoning to apply it.src/hover.rsanswerstextDocument/hover(hover_at): a small Markdown card with the position and the document’s overall type when the buffer parses, or the parse error at the cursor when it does not.byte_offset_ofmaps an LSP line and column to a byte offset. Schema-driven hover descriptions are tracked as future work.
Data flow
Editor sends didOpen or didChange with the full text; the server
stores it, parses it, and pushes diagnostics. Formatting and hover read
the stored text on request. Nothing is written to disk.
Testing
Unit tests drive Server::handle_message with raw JSON-RPC strings.
Two libFuzzer targets feed it arbitrary messages (fuzz_handle_message)
and arbitrary document text through didChange (fuzz_did_change);
CI replays the seed corpus on every push. docs/protocol-coverage.md
lists which LSP methods are implemented.
Lockstep
The crate pins noyalib at the identical =0.0.X and releases with
it (core ADR-0005).