lspeasy / client/src
client/src
LSP client package for connecting to language servers.
Remarks
Use @lspeasy/client when you need to build the consumer side of the Language Server Protocol — an editor extension, a CLI analysis tool, a test harness, or any process that speaks to a language server process.
The primary entry point is LSPClient. Construct it with ClientOptions, call connect(transport) to complete the LSP handshake, then use expect<ServerCaps>() to get typed access to capability-aware namespaces (e.g. client.textDocument.hover(params)).
Transport Decision Tree
Stdio (StdioTransport from @lspeasy/core/node) — Use when: spawning the language server as a child process (the canonical editor extension pattern). Zero network overhead; server and client share a lifespan. Failure mode: server process dies silently → stdout EOF fires onClose; pair with HeartbeatMonitor on long-lived processes.
WebSocket (WebSocketTransport from @lspeasy/core) — Use when: the language server runs remotely (CI, container, cloud dev env) or must be browser-accessible. Supports reconnect with exponential back-off. Failure mode: network partition → onError fires without onClose; enable enableReconnect and subscribe to ConnectionHealthTracker events.
TCP (TcpTransport from @lspeasy/core/node) — Use when: you need a persistent local socket and control both ends (e.g. a test harness or a daemon that outlives the client process). Failure mode: port conflict at startup; use mode: 'client' only after confirming the server is listening, or wrap in a retry loop.
DedicatedWorkerTransport (DedicatedWorkerTransport from @lspeasy/core) — Use when: running the language server in a Web Worker for browser isolation. Zero latency (shared memory), no WebSocket overhead. Failure mode: worker uncaught exception terminates silently; subscribe to worker.onerror.
Connection health
Use ConnectionHealthTracker and HeartbeatMonitor to detect silent transport failures. Subscribe to state-change events via ConnectionState.
Dynamic registration
The client handles client/registerCapability and client/unregisterCapability requests from the server automatically, updating the typed namespaces at runtime.
Client
| Name | Description |
|---|---|
| ConnectionState | Lifecycle state of an LSPClient connection. |
| CapabilityGuard | Validates outgoing client requests and notifications against the server's declared capabilities. |
| ClientCapabilityGuard | Validates that server-to-client handler registrations are backed by client capabilities declared in the initialize request. |
| ConnectionHealthTracker | Tracks connection state transitions and message activity timestamps. |
| HeartbeatMonitor | Runs interval-based heartbeat checks for active transports. |
| NotificationWaiter | Tracks a single wait-for-notification operation and its timeout lifecycle. |
| CancellableRequest | Return value of LSPClient.sendCancellableRequest. |
| ClientOptions | Configuration for an LSPClient instance. |
| ConnectionHealth | Aggregated connection health snapshot returned by LSPClient.getConnectionHealth(). |
| HeartbeatConfig | Configuration for optional heartbeat monitoring. |
| HeartbeatStatus | Snapshot of the current heartbeat monitoring status. |
| InitializeResult | Initialize result from server. |
| NotebookDocumentNamespace | Namespace for sending notebook-document lifecycle notifications to a server. |
| NotificationWaitOptions | Options for NotificationWaiter and LSPClient.waitForNotification. |
| PartialRequestOptions | Options for LSPClient.sendRequestWithPartialResults. |
| StateChangeEvent | Payload emitted when the connection state changes. Subscribe via LSPClient.onConnectionStateChange(). |
| LSPClient | Typed LSP client that connects to a language server, manages the LSP handshake, and exposes capability-aware request namespaces. |
| LSPClient | Constructs an LSPClient instance. |
Other
Disposable
Renames and re-exports Transport
Logger
Renames and re-exports Transport
LogLevel
Renames and re-exports Transport