microsoft / vscode-languageserver-node

Language server protocol implementation for VSCode. This allows implementing language services in JS/TS running on node.js
MIT License
1.48k stars 325 forks source link

TransportKind.ipc: Impossible to specify the PIPE path to startup the LanguageClient #1570

Closed denis-shienkov closed 1 month ago

denis-shienkov commented 1 month ago

Hi all.

I'm trying to write the VSCode extension with the LanguageClient support. My LSP server already started, and provides the ready pipe path in a form like: '\\.\pipe\qbs-lsp-1884' .

My extension code looks like this:

    private startupLanguageClient(lspSocket: string) {
        const serverOptions: ServerOptions = {
            run: { module: lspSocket, transport: TransportKind.ipc },
            debug: { module: lspSocket, transport: TransportKind.ipc }
        };

        const clientOptions: LanguageClientOptions = {
            documentSelector: [{ language: 'qbs' }]
        };

        this.languageClient = new LanguageClient('Qbs', serverOptions, clientOptions);
        this.languageClient
            .start()
            .then(async () => {
                console.info('Qbs language client started on pipe: ' + lspSocket);
            })
            .catch((reason) => {
                void vscode.window.showErrorMessage('Cannot start Qbs language server: ' + reason);
                console.error('Unable to start Qbs language client on pipe: ' + lspSocket);
            });
    }

So, I have not ideas where in the ServerOptions it is possible to specify the path to the pipe? Is it possible at all?

Because I got the error that the server can't be started:

Cannot start Qbs language server: Error: Pending response rejected since connection got disposed

UPD: I see the comments about the ServerOptions in the LanguageClient sources:

...
If the language server is implemented in a different
 * program language the server simply needs to create a connection to the
 * passed pipe name or port number.
...

but it is unclear this "simply needs to create a connection to the passed pipe name or port number" where to pass?

denis-shienkov commented 1 month ago

Also, I looked the similar issue: https://github.com/microsoft/vscode-languageserver-node/issues/1333

And tried this options:

        const serverOptions: ServerOptions = {
            run: {
                command: '',
                transport: TransportKind.pipe,
                args: ['--pipe ' + lspSocket]
            },
            debug: {
                command: '',
                transport: TransportKind.pipe,
                args: ['--pipe ' + lspSocket]
            }
        };

then I go the following error:

Unable to start Qbs language client on pipe: \\.\pipe\qbs-lsp-3328, Error: Unsupported server configuration {
    "run": {
        "command": "",
        "transport": 2,
        "args": [
            "--pipe \\\\.\\pipe\\qbs-lsp-3328"
        ]
    },
    "debug": {
        "command": "",
        "transport": 2,
        "args": [
            "--pipe \\\\.\\pipe\\qbs-lsp-3328"
        ]
    }
}

Can someone help me please?

denis-shienkov commented 1 month ago

Seems to be worked, need to create a wrapper around the TransportsMessages, see the similar issue: https://github.com/microsoft/vscode-languageserver-node/issues/1333

Also, the real use-case code can be looked here (as an example): https://github.com/denis-shienkov/vscode-qbs/blob/master/src/qbslanguageclient.ts