Skip to content

LSP Server not working in Visual Studio #132

@gep13

Description

@gep13

I have been setting up an LSP implementation for Chocolatey nuspec files in VSCode, and this has been working well. I am now trying to take the same Language Server implementation and run it in Visual Studio. When I try this, I get the following error returned:

image

The code that I am using the initialise the client within Visual Studio is the following:

    [ContentType("nuspec")]
    [Export(typeof(ILanguageClient))]
    public class ChocolateyLanguageClient : ILanguageClient
    {
        public string Name => "Chocolatey Language Server Client";

        public IEnumerable<string> ConfigurationSections => null;

        public object InitializationOptions => null;

        public IEnumerable<string> FilesToWatch => null;

        public event AsyncEventHandler<EventArgs> StartAsync;
        public event AsyncEventHandler<EventArgs> StopAsync;

        public async Task<Connection> ActivateAsync(CancellationToken token)
        {
            await Task.Yield();

            var info = new ProcessStartInfo();
            info.FileName = "dotnet";
            info.Arguments = "C:\\github_local\\gep13\\chocolatey-vs\\lib\\ChocolateyLanguageServer\\Chocolatey.Language.Server.dll";
            info.RedirectStandardInput = true;
            info.RedirectStandardOutput = true;
            info.UseShellExecute = false;
            info.CreateNoWindow = true;

            Process process = new Process();
            process.StartInfo = info;

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

            return null;
        }

        public async Task OnLoadedAsync()
        {
            await StartAsync?.InvokeAsync(this, EventArgs.Empty);
        }

        public Task OnServerInitializedAsync()
        {
            return Task.CompletedTask;
        }

        public Task OnServerInitializeFailedAsync(Exception e)
        {
            return Task.CompletedTask;
        }
    }

Is there additional configuration that needs to be provided, or is this a bug that needs to be addressed. Let me know if you need any further information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions