Skip to content

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

Open
@cdhanna

Description

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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions