Skip to content

Language server doesn't work with Visual Studio LSP client #282

@racz16

Description

@racz16

Installed products

  • Visual Studio: Community 2022 (17.5.5)

Description

I would like to use a Node-based language server with a Visual Studio LSP client. I'm trying to use the Visual Studio and VS Code samples since this should be the easiest way to start, but it doesn't work.

Steps to recreate

  1. Download the VS Code extension samples
  2. Build the server of the lsp-sample
  3. Download the Visual Studio Extensibility Samples
  4. Change the ActivateAsync function in the LanguageServerProtocol sample to run the server
public async Task<Connection> ActivateAsync(CancellationToken token)
{
    Process process = new Process
    {
        StartInfo = new ProcessStartInfo
        {
            FileName = "node",
            Arguments = "server.js --stdio",
            RedirectStandardInput = true,
            RedirectStandardOutput = true,
            RedirectStandardError = true,
            UseShellExecute = false,
            CreateNoWindow = true
        }
    };

    if (process.Start())
    {
        return new Connection(process.StandardOutput.BaseStream, process.StandardInput.BaseStream);
    }

    return null;
}
  1. Build the LanguageServerProtocol sample
  2. Run the extension, open the TestFiles folder, and open one of the files

Current behavior

When I open the file, I get the following error:

ConnectionLostException: The JSON-RPC connection with the remote party was lost before the request could complete.

If I set the CreateNoWindow to false I can see opening the terminal, but it closes immediately.

Expected behavior

When I press ctrl+space in the file, I should see the code completion items from the server.

Metadata

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