【问题标题】:How to connect my language server implemented by C++如何连接我用 C++ 实现的语言服务器
【发布时间】:2021-03-16 15:40:37
【问题描述】:

我假设协议使用标准输入/标准输出作为通道

但是当我启动 vscode 调试时,我的 exe 没有启动。 如何启动我的 exe?


我的配置:

{
        "type": "extensionHost",
        "request": "launch",
        "name": "Launch Client",
        // "runtimeExecutable": "${execPath}",
        "runtimeExecutable": "C:/vscode-ext/lsp_cpp_ravi/cmake-build-debug/lsp-aaa.exe",
        "args": ["--extensionDevelopmentPath=${workspaceRoot}"],
        "outFiles": ["${workspaceRoot}/client/out/**/*.js"],
        "preLaunchTask": {
            "type": "npm",
            "script": "watch"
        }
    },

这个配置是从lsp-sample复制过来的,我修改了runtimeexecutable字段


客户端代码:

export function activate(context: ExtensionContext) {
    // The server is implemented in node
    // let serverModule = context.asAbsolutePath(
    //  // path.join('server', 'out', 'server.js')
    //  path.join('C:\\vscode-ext\\lsp_cpp_ravi\\cmake-build-debug', 'lsp-ravi.exe')
    // );
    let serverModule = ''

    // The debug options for the server
    // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
    let debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };

    // If the extension is launched in debug mode then the debug server options are used
    // Otherwise the run options are used
    let serverOptions: ServerOptions = {
        run: { module: serverModule, transport: TransportKind.ipc },
        debug: {
            module: serverModule,
            transport: TransportKind.ipc,
            options: debugOptions
        }
    };

    // Options to control the language client
    let clientOptions: LanguageClientOptions = {
        // Register the server for plain text documents
        documentSelector: [{ scheme: 'file', language: 'plaintext' }],
        synchronize: {
            // Notify the server about file changes to '.clientrc files contained in the workspace
            fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
        }
    };

    // Create the language client and start the client.
    client = new LanguageClient(
        'languageServerExample',
        'Language Server Example',
        serverOptions,
        clientOptions
    );

    // Start the client. This will also launch the server
    client.start();
}

可以使用TCP作为连接方式吗?

【问题讨论】:

    标签: visual-studio-code vscode-extensions language-server-protocol


    【解决方案1】:

    好的,已经解决了。

    因为我没有打开任何文件夹,所以客户端没有调用“active”。

    然后我使用这里的答案[https://github.com/microsoft/vscode-languageserver-node/issues/662]连接到TCP

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-31
      • 2017-09-05
      • 1970-01-01
      • 1970-01-01
      • 2016-05-06
      • 1970-01-01
      相关资源
      最近更新 更多