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 =new LoggerConfiguration().Enrich.FromLogContext().WriteTo.File(AppDomain.CurrentDomain.BaseDirectory +"log.txt", rollingInterval: RollingInterval.Day).MinimumLevel.Verbose().CreateLogger();
Log.Logger.Information("STARTING");IObserver<WorkDoneProgressReport>workDone=null!;varserviceCollection=new ServiceCollection();
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,new WorkDoneProgressBegin{Title="Server is starting...",Percentage=10,});workDone=manager;await Task.Delay(2000).ConfigureAwait(false); manager.OnNext(new WorkDoneProgressReport{Percentage=20,Message="loading in progress"});}).OnStarted(async(languageServer,token)=>{usingvarmanager=await languageServer.WorkDoneManager.Create(new WorkDoneProgressBegin {Title="Doing some work..."}).ConfigureAwait(false); manager.OnNext(new WorkDoneProgressReport {Message="doing things..."}); manager.OnNext(new WorkDoneProgressReport {Message="doing things... 1234"}); manager.OnNext(new WorkDoneProgressReport {Message="doing things... 56789"});varlogger= languageServer.Services.GetRequiredService<ILogger<Program>>(); logger.LogInformation("STARTED");}));varprovider= serviceCollection.BuildServiceProvider();varserver= provider.GetRequiredService<ILanguageServer>();await server.Initialize(CancellationToken.None);// I tried with or without thisawait server.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: