You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to create a simple LSP server. I looked at https://github.com/OmniSharp/csharp-language-server-protocol/tree/master/sample/SampleServer. The example works alright, I'm able to communicate with the server from neovim.
I tried to create something myself, however, I wanted to use the Microsoft.Extensions.DependencyInjection to manage dependencies of my app, including the ILanguageServer. Here's a simple Program.cs I created:
Log.Logger=newLoggerConfiguration().Enrich.FromLogContext().WriteTo.File(AppDomain.CurrentDomain.BaseDirectory+"log.txt",rollingInterval:RollingInterval.Day).MinimumLevel.Verbose().CreateLogger();Log.Logger.Information("STARTING");IObserver<WorkDoneProgressReport>workDone=null!;varserviceCollection=newServiceCollection();serviceCollection.AddLogging(logging =>logging.ClearProviders().AddSerilog(Log.Logger).AddLanguageProtocolLogging().SetMinimumLevel(LogLevel.Debug)).AddLanguageServer(options =>options.WithInput(Console.OpenStandardInput()).WithOutput(Console.OpenStandardOutput()).OnInitialize(async(server,request,token)=>{varlogger=server.Services.GetRequiredService<ILogger<Program>>();logger.LogInformation("INITIALIZING");varmanager=server.WorkDoneManager.For(request,newWorkDoneProgressBegin{Title="Server is starting...",Percentage=10,});workDone=manager;awaitTask.Delay(2000).ConfigureAwait(false);manager.OnNext(newWorkDoneProgressReport{Percentage=20,Message="loading in progress"});}).OnStarted(async(languageServer,token)=>{usingvarmanager=awaitlanguageServer.WorkDoneManager.Create(newWorkDoneProgressBegin{Title="Doing some work..."}).ConfigureAwait(false);manager.OnNext(newWorkDoneProgressReport{Message="doing things..."});manager.OnNext(newWorkDoneProgressReport{Message="doing things... 1234"});manager.OnNext(newWorkDoneProgressReport{Message="doing things... 56789"});varlogger=languageServer.Services.GetRequiredService<ILogger<Program>>();logger.LogInformation("STARTED");}));varprovider=serviceCollection.BuildServiceProvider();varserver=provider.GetRequiredService<ILanguageServer>();awaitserver.Initialize(CancellationToken.None);// I tried with or without thisawaitserver.WaitForExit;
I never get to the "INITIALIZING" part, it's like the server doesn't even react to initialization request. The example is very similar to what the official sample provided. Could someone point out what I'm doing wrong?
The text was updated successfully, but these errors were encountered:
I wanted to create a simple LSP server. I looked at https://github.com/OmniSharp/csharp-language-server-protocol/tree/master/sample/SampleServer. The example works alright, I'm able to communicate with the server from neovim.
I tried to create something myself, however, I wanted to use the Microsoft.Extensions.DependencyInjection to manage dependencies of my app, including the
ILanguageServer
. Here's a simpleProgram.cs
I created:I never get to the "INITIALIZING" part, it's like the server doesn't even react to initialization request. The example is very similar to what the official sample provided. Could someone point out what I'm doing wrong?
The text was updated successfully, but these errors were encountered: