Skip to main content

Crate noyalib_lsp

Crate noyalib_lsp 

Source
Expand description

Library surface for noyalib-lsp.

Hosts the JSON-RPC 2.0 dispatch logic, the document store that tracks open buffers, and the LSP capability handlers (textDocument/formatting, textDocument/publishDiagnostics, textDocument/hover). The noyalib-lsp binary in main.rs is a thin stdio shim that drives Server::handle_message; tests reach the same handlers directly so coverage does not depend on standing up a real LSP client.

§Cargo features

This crate exposes no optional features; the LSP capability set is fixed at textDocumentSync (full), formatting, and hover. Optional noyalib features (schema, parallel, …) pulled in by a downstream binary do not change this crate’s wire surface — they only affect what noyalib::Error messages are produced inside diagnostics. The canonical noyalib feature matrix lives in crates/noyalib/src/lib.rs.

§MSRV

Rust 1.85.0 stable. The tower-lsp and async deps floor at 1.85; the core noyalib library still builds on 1.75. CI verifies both floors via the Per-crate MSRV workflow job. See workspace POLICIES.md.

§Panics

Public functions in this crate do not panic on well-formed input. The LSP binary’s stdin/stdout handling propagates I/O errors back to the host as JSON-RPC error envelopes.

§Errors

All handlers return JSON-RPC error envelopes per the LSP specification. Parse / format errors come from noyalib::Error and surface through the textDocument/publishDiagnostics channel as span-aware Diagnostic records.

§Concurrency

Each LSP request is processed sequentially on the binary’s stdio loop. The internal document store is reentrant: handlers &mut-borrow it serialised by the request loop. No internal threading; rayon is opt-in via the parallel feature on noyalib.

§Platform support

Tier-1 (CI-verified each PR): aarch64-apple-darwin, x86_64-unknown-linux-gnu, x86_64-pc-windows-msvc. Editor-specific notes for VS Code, Neovim, Helix, Emacs, Zed, Sublime, IntelliJ live under crates/noyalib-lsp/examples/.

§Performance

Each didOpen / didChange event re-parses the entire buffer in a single pass — O(n) in document bytes. A 1 MB YAML document typically reports diagnostics in under 5 ms on commodity hardware. The CST is cached per document so textDocument/formatting and textDocument/hover reuse the same parse on subsequent requests.

§Security

#![forbid(unsafe_code)]. No FFI. No network I/O — LSP is stdio-only. The server reads file contents only from the editor’s didOpen notifications; it does not autoload arbitrary paths from the filesystem. Resource-limit gates are inherited from noyalib’s ParserConfig defaults. Full posture: SECURITY.md.

§API stability and SemVer

Pre-1.0 (0.0.x): the LSP wire contract (method names, capability flags, JSON-RPC error code ranges, document store semantics) is stable within a 0.0.x line — bug fixes only. Adding a new LSP capability is allowed within a 0.0.x bump; removing or repurposing one is held to a 0.x bump (e.g. 0.0.x → 0.1.0). The Rust library surface (Server, HandleOutcome, Request, Response, ErrorResponse) is covered by the workspace SemVer policy in POLICIES.md. cargo-semver-checks runs in CI on every PR.

§Documentation

Modules§

diagnostics
textDocument/publishDiagnostics — turn YAML parse errors into LSP-compatible diagnostic objects.
format
textDocument/formatting — re-emit a YAML document via noyalib’s CST formatter and surface the result as LSP TextEdit objects.
hover
textDocument/hover — surface contextual information for the cursor position.

Structs§

ErrorObject
JSON-RPC 2.0 error object.
ErrorResponse
JSON-RPC 2.0 error envelope.
HandleOutcome
What the stdio loop should do with a parsed message — write a reply and / or zero or more server-initiated notifications, or stay silent.
Notification
LSP server-side notification envelope (e.g. for textDocument/publishDiagnostics).
Request
JSON-RPC 2.0 request envelope (LSP wire format).
Response
JSON-RPC 2.0 success response envelope.
Server
Stateful LSP server. One instance per stdio session; the document store owns the in-memory snapshot of every open buffer.

Functions§

error_str
Render a JSON-RPC error envelope to a single-line string.