Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sample project does not connect over stdio channel in vscode #1176

Open
cdhanna opened this issue Jan 18, 2024 · 0 comments
Open

sample project does not connect over stdio channel in vscode #1176

cdhanna opened this issue Jan 18, 2024 · 0 comments

Comments

@cdhanna
Copy link

cdhanna commented Jan 18, 2024

This library looks like an incredible project, so first off, thank you!

I was trying to get up and running with a vs-code extension client for the server, and following the sample project in this repo, I was having a devil of a time.
I got it working by changing vs-code to use the TransporkKind.pipe instead of stdio.

In the Program.cs, I did something like this,

public static class Program
{
    public static async Task Main(string[] args)
    {
        var pipeAddr = "";
        foreach (var t in args)
        {
            if (!t.StartsWith("--pipe=")) continue;
            
            pipeAddr = t.Substring("--pipe=".Length);
            break;
        }
        
        Log.Logger = new LoggerConfiguration()
            .Enrich.FromLogContext()
            .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day)
            .MinimumLevel.Verbose()
            .CreateLogger();
        
        var pipeClient = new NamedPipeClientStream(pipeAddr);
        await pipeClient.ConnectAsync();
        
        Log.Logger.Information("connected.");

       // the LanguageServer.From( .... goes here

And then when creating the input/output for the language server, doing this,

  .WithInput(pipeClient.UsePipeReader())
  .WithOutput(pipeClient.UsePipeWriter())

If I used stdio and the listed sample code to get the input/output streams from Console, then I would get errors from vscode about Content-Length not being supplied on the messages.

I mostly wanted to leave this here as a trace in case anyone else found it useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant