@orkestrel/lsp
v0.0.9
Published
A typed Language Server Protocol client over an injected byte transport — base-protocol framing, JSON-RPC and protocol guards, and a stdio child-process transport. Part of the @orkestrel line.
Maintainers
Readme
@orkestrel/lsp
A typed Language Server Protocol client over an injected byte transport: a host-independent core carrying the base-protocol framing codec, the JSON-RPC and protocol guards, and an
LSPClientthat completes the initialize handshake, owns opened document URIs, and selects pull or push diagnostics from the server's own capabilities, beside a server environment whoseStdioClientTransportcarries those bytes over a language server run as a child process.
Create a client with the createLSPClient function, hand it a transport, and
call start() before you open a document. The client reaches its peer only
through the transport it is handed, so any implementation of
LSPTransportInterface drives the same client, and the stdio transport ends the
child's whole tree inside a bounded termination window. Part of the @orkestrel
line.
Install
npm install @orkestrel/lspRequirements
- Node.js >= 22.12.0
- ESM and CommonJS builds for the
.and./serverentry points - TypeScript
moduleResolutionset tonode16,nodenext, orbundler
Usage
import { createLSPClient } from '@orkestrel/lsp'
import { createStdioClientTransport } from '@orkestrel/lsp/server'
import { pathToFileURL } from 'node:url'
declare const directory: string
const transport = createStdioClientTransport({
server: { command: ['my-language-server', '--stdio'], directory },
grace: 5_000,
})
const client = createLSPClient({ transport, workspace: pathToFileURL(directory).href })
await client.start()
await client.destroy()Guide
For the full surface — the client lifecycle, the transport seam, the stdio child
transport, the framing codec and its retained decode state, the protocol guards,
and the LSPError failure type — see the
Language Server Protocol client guide.
Package
Typed entry points per the exports field in package.json: the
host-independent client, framing codec, guards, constants, and LSPError from
@orkestrel/lsp, and the Node stdio transport — StdioClientTransport and
createStdioClientTransport — from @orkestrel/lsp/server.
