LSPClient

class LSPClient(val server: LanguageServer, val config: LSPClientConfig = LSPClientConfig())

A client that connects a kodemirror editor to a language server.

Deviation from upstream: upstream @codemirror/lsp-client owns the JSON-RPC Transport and serializes/deserializes LSP messages itself. In kodemirror the consumer instead provides a LanguageServer — the typed suspend interface from com.monkopedia.lsp — and this client simply wraps it. That means transport, framing and JSON-RPC concerns live entirely in the provided LanguageServer implementation (e.g. backed by lsp-ksrpc), and this class focuses on lifecycle (initialize/initialized/shutdown) and exposing typed suspend calls plus serverCapabilities.

Parameters

server

The language server implementation supplied by the consumer.

config

Client configuration. See LSPClientConfig.

Constructors

Link copied to clipboard
constructor(server: LanguageServer, config: LSPClientConfig = LSPClientConfig())

Properties

Link copied to clipboard
Link copied to clipboard
var initializeResult: InitializeResult?

The full result of the initialize request, or null until initialized.

Link copied to clipboard

Whether initialize has completed successfully.

Link copied to clipboard
val languageClient: LanguageClient

The LanguageClient the consumer registers as the client side of their transport (e.g. ksrpc's connectAsLspClient).

Link copied to clipboard
val scope: CoroutineScope

Client-lifetime coroutine scope, used for work that must outlive any single editor session (e.g. sending textDocument/didClose as a plugin tears down its own scope).

Link copied to clipboard
val server: LanguageServer
Link copied to clipboard
val serverCapabilities: ServerCapabilities?

The capabilities reported by the server during initialize, or null if the client has not been initialized yet.

Link copied to clipboard

The Workspace managed by this client.

Functions

Link copied to clipboard
suspend fun initialize(): InitializeResult

Perform the LSP initialize / initialized handshake.

Link copied to clipboard
suspend fun shutdown()

Shut the server down via the LSP shutdown / exit sequence.

Link copied to clipboard
suspend fun sync()

Flush any pending document changes to the server.