首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过终端使用clangd

通过终端使用clangd
EN

Stack Overflow用户
提问于 2022-02-22 11:32:16
回答 1查看 510关注 0票数 -2

我想用我的终端测试响声,但我不能提出要求。我已经阅读了LSP语言的文档,但我仍然不明白如何启动连接等等。

以下是开场白:

代码语言:javascript
复制
clangd is a language server that provides IDE-like features to editors.

It should be used via an editor plugin rather than invoked directly. For more information, see:
        https://clangd.llvm.org/
        https://microsoft.github.io/language-server-protocol/

clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment variable.

I[12:27:23.132] clangd version 13.0.0 (ssh://git@git.jetbrains.team/llvm/llvm-project.git f453b8779f319ecd0e7f6f2fdd5e78ec375aaa47 based on LLVM 1d42ba254fa3203f1ad5916ed414a84312f5bba9 revision)
I[12:27:23.135] PID: 7604
I[12:27:23.136] Working directory: C:\Users\Tal\AppData\Local\JetBrains\CLion 2021.1.3\bin\clang\win
I[12:27:23.137] argv[0]: C:\Users\Tal\AppData\Local\JetBrains\CLion 2021.1.3\bin\clang\win\clangd.exe
I[12:27:23.148] Starting LSP over stdin/stdout

在那之后,我就不能发信息了。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-22 12:16:01

您必须读取https://microsoft.github.io/language-server-protocol/specifications/specification-current/#headerPart并使用json协议向进程的stdin发送消息。例如:

代码语言:javascript
复制
send() { msg=$(jq -n "$@"); printf "%s\r\n" "Content-Length: ${#msg}" "" "$msg" | tee /dev/stderr; }
send '{ jsonrpc: "2.0", id: 1, method: "exit" }' | clangd

clangd is a language server that provides IDE-like features to editors.

It should be used via an editor plugin rather than invoked directly. For more information, see:
        https://clangd.llvm.org/
        https://microsoft.github.io/language-server-protocol/

clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment variable.

I[13:14:59.127] clangd version 13.0.1
I[13:14:59.127] Features: linux
I[13:14:59.127] PID: 94070
I[13:14:59.127] Working directory: /home/kamil
I[13:14:59.127] argv[0]: clangd
I[13:14:59.127] Starting LSP over stdin/stdout
Content-Length: 53

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "exit"
}
I[13:14:59.131] <-- exit(1)
E[13:14:59.131] Call exit before initialization.
I[13:14:59.131] --> reply:exit(1) 0 ms, error: -32002: server not initialized
Content-Length: 83

{"error":{"code":-32002,"message":"server not initialized"},"id":1,"jsonrpc":"2.0"}I[13:14:59.131] Warning: Missing Content-Length header, or zero-length message.
E[13:14:59.132] Transport error: Input/output error
I[13:14:59.132] LSP finished, exiting with status 1
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71220561

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档