This repository has been archived on 2025-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nub-lang-archive-2/compiler/NubLang.LSP/Program.cs
nub31 ec422cf1cd ...
2025-10-23 17:55:21 +02:00

34 lines
1.0 KiB
C#

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NubLang.LSP;
using OmniSharp.Extensions.LanguageServer.Server;
var server = await LanguageServer.From(options => options
.WithInput(Console.OpenStandardInput())
.WithOutput(Console.OpenStandardOutput())
.WithServices(services =>
{
services.AddSingleton<DiagnosticsPublisher>();
services.AddSingleton<WorkspaceManager>();
})
.ConfigureLogging(x => x
.AddLanguageProtocolLogging()
.SetMinimumLevel(LogLevel.Debug))
.WithHandler<TextDocumentSyncHandler>()
.WithHandler<HoverHandler>()
.WithHandler<CompletionHandler>()
.WithHandler<DefinitionHandler>()
.OnInitialize((server, request, ct) =>
{
var workspaceManager = server.GetRequiredService<WorkspaceManager>();
if (request.RootPath != null)
{
workspaceManager.Init(request.RootPath);
}
return Task.CompletedTask;
})
);
await server.WaitForExit;