visual-studio-code - 如何连接我用 C++ 实现的语言服务器
问题描述
我假设协议使用标准输入/标准输出作为通道
但是当我开始 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 作为连接方式?
解决方案
好的,这就解决了。
因为我没有打开任何文件夹,所以客户端没有调用“活动”。
然后我使用这里的答案 [https://github.com/microsoft/vscode-languageserver-node/issues/662] 连接到 TCP
推荐阅读
- typescript - 打字稿:省略“导出”关键字似乎会使界面变得全局?
- javascript - 监控 Angular 组件生命周期钩子
- npm - 设置 Nexus npm:在仪表板上上传 tar 文件时出现空指针异常
- python - Python 在一个窗口中播放两个视频
- c++ - cairo_show_text 内存泄漏
- vba - 在向多个可能的内部域之外发送消息之前发出警告?
- javascript - 意外的令牌/在 JSON 中的位置
- python - 具有可变批量大小的矩阵向量批量乘法
- c - 进入函数范围但不在函数调用时指针参数为 NULL
- java - 我无法在 intellij 中配置 jdk 10,错误消息是“在 C:/program files/java/jdk 中找不到 JDK 类”