我使用 Ubuntu 24.10,并且刚刚安装了 helix 文本编辑器(helix 24.7 (079f5442))。我是编辑新手,正在寻找出路。我已从
here复制并安装了
languages.toml
的 cpp 的整个 lsp。但我没有成功安装DAP and the Formatter
。
hakiza@VBox:~/cpp/ppp/ch02$ helix --health cpp
Configured language servers:
✓ clangd: /usr/bin/clangd
Configured debug adapter: lldb-dap
Binary for debug adapter: 'lldb-dap' not found in $PATH
Configured formatter: None
Highlight queries: ✓
Textobject queries: ✓
Indent queries: ✓
当我尝试编写一些 ccp 代码时,我可以看到自动完成功能不起作用。当我打开现有的 cpp 文件时,我在窗口左下角看到“语言服务器已退出”消息。
当cpp版本为c++20时,如何进一步使helix适用于cpp环境?
这是我的 languages.toml 文件的内容:
[[language]]
name = "cpp"
scope = "source.cpp"
injection-regex = "cpp"
file-types = ["cc", "hh", "c++", "cpp", "hpp", "h", "ipp", "tpp", "cxx", "hxx", "ixx", "txx", "ino", "C", "H", "cu", "cuh", "cppm", "h++", "ii", "inl", { glob = ".hpp.in" }, { glob = ".h.in" }]
comment-token = "//"
block-comment-tokens = { start = "/*", end = "*/" }
language-servers = [ "clangd" ]
indent = { tab-width = 2, unit = " " }
[language.debugger]
name = "lldb-dap"
transport = "stdio"
command = "lldb-dap"
[[language.debugger.templates]]
name = "binary"
request = "launch"
completion = [ { name = "binary", completion = "filename" } ]
args = { console = "internalConsole", program = "{0}" }
[[language.debugger.templates]]
name = "attach"
request = "attach"
completion = [ "pid" ]
args = { console = "internalConsole", pid = "{0}" }
[[language.debugger.templates]]
name = "gdbserver attach"
request = "attach"
completion = [ { name = "lldb connect url", default = "connect://localhost:3333" }, { name = "file", completion = "filename" }, "pid" ]
args = { console = "internalConsole", attachCommands = [ "platform select remote-gdb-server", "platform connect {0}", "file {1}", "attach {2}" ] }
[[grammar]]
name = "cpp"
source = { git = "https://github.com/tree-sitter/tree-sitter-cpp", rev = "670404d7c689be1c868a46f919ba2a3912f2b7ef" }
我认为
clangd
命令没有类似“--std=c++20”标志的东西。 (如果有这样的标志,你可以使用 helix config add args 来做到这一点)
因此,需要一个单独的文件来提供
clangd
编译信息。
如果正在使用
clangd
,则生成 compile_commands.json,clangd 会看到它是否在“我认为这是更理想的,因为你可能有其他项目需要不同版本的 C++ 甚至不同的工具链支持。
cmake
来构建:如何使用CMAKE_EXPORT_COMPILE_COMMANDS?cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=true -Bbuild
make
来构建:https://github.com/rizsotto/Bearbear -- make
clangd
配置项目的配置路径:“
每用户全局配置:“~/.config/clangd/config.yaml”
CompileFlags:
Add: [-std=c++20]