Workspace

open class Workspace(val client: LSPClient)

Tracks the set of open files for an LSPClient and synchronizes their contents with the language server.

Mirrors upstream @codemirror/lsp-client's Workspace. Files are registered via openFile (which sends textDocument/didOpen) and removed via closeFile (which sends textDocument/didClose). Editor changes are recorded with updateFile and later flushed with syncFiles / LSPClient.sync, honoring the server's negotiated DocumentSyncMode.

Parameters

client

The owning LSPClient.

Constructors

Link copied to clipboard
constructor(client: LSPClient)

Properties

Link copied to clipboard
Link copied to clipboard

All currently-tracked files.

Functions

Link copied to clipboard
open fun closeFile(uri: String)

Remove a file from the workspace. Synchronous so it can run from a plugin's destroy; the textDocument/didClose notification is sent separately by didCloseFile.

Link copied to clipboard
open suspend fun didCloseFile(uri: String)

Send the textDocument/didClose notification for uri, if the server's sync capability advertises open/close notifications (DocumentSyncMode.openClose).

Link copied to clipboard
open suspend fun didOpenFile(uri: String)

Send the textDocument/didOpen notification for uri, if it is open and the server's sync capability advertises open/close notifications (DocumentSyncMode.openClose).

Link copied to clipboard

Surface the file at uri to the user and return the editor session showing it, or null when this is not possible.

Link copied to clipboard

Look up a tracked file by its URI.

Link copied to clipboard

Obtain a live WorkspaceMapping for uri that tracks edits applied after this call, or null if no such file is open. A feature that issues an LSP request should capture a mapping when it sends the request and use it to remap the response's positions; call releaseMapping when done.

Link copied to clipboard
open fun openFile(uri: String, languageId: String, session: EditorSession?): WorkspaceFile

Register a file as open in the workspace, snapshotting its current text as the version-1 baseline. Synchronous so it can run from a plugin's constructor; the textDocument/didOpen notification is sent separately by didOpenFile once the server handshake has completed.

Link copied to clipboard

Release a mapping previously obtained from getMapping.

Link copied to clipboard

Take all pending file updates, advancing each file's version/doc. Returns the updates that should be sent to the server as textDocument/didChange.

Link copied to clipboard
open fun updateFile(uri: String, change: ChangeSet)

Record an editor change against the file uri.