Hex1bLanguageServerWorkspace
Namespace: Hex1b.LanguageServer
Assembly: Hex1b.dll
Manages language server instances for a workspace root directory. Multiple documents in the same workspace share the same server connection per language. Documents register with the workspace and receive a that uses the shared connection.
public sealed class Hex1bLanguageServerWorkspace : IAsyncDisposableInheritance
Object → Hex1bLanguageServerWorkspace
Implements
Constructors
Hex1bLanguageServerWorkspace(string)
Creates a workspace rooted at the specified path.
Parameters:
rootPath(String): The workspace root directory path. Converted to afile://URI for the LSPinitializerequest'srootUriparameter.
public Hex1bLanguageServerWorkspace(string rootPath)Methods
DisposeAsync()
Disposes all active server connections.
Returns: ValueTask
public ValueTask DisposeAsync()GetProvider(string, string?)
Gets or creates a decoration provider for a document, backed by the shared language server for that language. Call this from the
extension method.
Parameters:
documentUri(String): The document's URI (e.g.,file:///path/to/file.cs).languageId(String): The language ID. If null, inferred from the document URI extension.
Returns: LanguageServerDecorationProvider
A decoration provider wired to the shared server connection.
public LanguageServerDecorationProvider GetProvider(string documentUri, string? languageId = null)RegisterServer(string, Action<LanguageServerConfiguration>)
Registers a language server configuration for a given language ID. The server is not started until a document of this language is opened.
Parameters:
languageId(String): LSP language identifier (e.g., "csharp", "python", "typescript").configure(Action<LanguageServerConfiguration>): Configuration callback.
public void RegisterServer(string languageId, Action<LanguageServerConfiguration> configure)Remarks
In LSP, a single server process handles all documents in a workspace via textDocument/didOpen and textDocument/didChange notifications. This class manages that shared lifecycle — one per registered language, shared across all documents of that language.
Usage:
var workspace = new Hex1bLanguageServerWorkspace("/path/to/project");
workspace.RegisterServer("csharp", config => config
.WithServerCommand("csharp-ls")
.EnableSemanticHighlighting());
// In the widget builder:
ctx.Editor(state).LanguageServer(workspace, "file:///path/to/file.cs", "csharp")