Clangd无法解析STL Lib标题
当我配置Neovim LSP时,我遇到了一个问题。我的LSP客户端是NVIM-LSPConfig,Clangd是我的LSP服务器。 这是我的clangd设置参数
require('lspconfig')['clangd'].setup {
on_attach = on_attach,
flags = {
-- This will be the default in neovim 0.7+
debounce_text_changes = 150,
},
capabilities = capabilities,
cmd = {
'clangd',
'--background-index',
'--query-driver="/app/vbuild/RHEL7-x86_64/clang/latest/bin/clang, \
/app/vbuild/RHEL7-x86_64/clang/latest/bin/clang++, \
/app/vbuild/RHEL7-x86_64/gcc/latest/bin/gcc, \
/app/vbuild/RHEL7-x86_64/gcc/latest/bin/g++"',
'--clang-tidy',
'--all-scopes-completion',
'--cross-file-rename',
'--completion-style=detailed',
'--header-insertion-decorators',
'--header-insertion=iwyu',
'--pch-storage=memory',
'--enable-config',
'--log=verbose'
},
filetypes = {"c", "cpp", "objc", "objcpp"}
}
,我的G ++和clangd版本同时同时
g++ (GCC) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
clangd version 14.0.0
Features: linux
Platform: x86_64-unknown-linux-gnu
,我将以下路径添加到我的CPATH中,
setenv CPATH "/app/vbuild/RHEL7-x86_64/gcc/latest/include/c++/10.3.0:/app/vbuild/RHEL7-x86_64/glibc/2.33/include"
setenv CPATH "/app/vbuild/RHEL7-x86_64/clang/latest/include/clang-c:/app/vbuild/RHEL7-x86_64/clang/latest/include/llvm-c:$CPATH"
但我仍然在Neovim
似乎Clangd找不到相关的STL标题。但是我检查了$ cpath中的路径。它确实具有STL标题。有人知道如何解决这个问题吗? 谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果编译器为G ++,则Clangd需要G ++的驱动程序才能找到STD库。基本上,您需要在CMD表中取消调查
If the compiler is g++, clangd needs g++'s driver to find std library. Basically you need to uncomment the queries in cmd table
很难确定这是否是问题,而又不看到 clangd logs 问题是
的参数 - QUERY-DRIVER
是 REGEX ,它与compile_commands.json 。
我认为您所经过的逗号分隔列表不是有效的正则是。要匹配这四个可执行文件,您可能需要使用更宽松的正则义务,例如
/app/vbuild/rhel7-x86_64/*/lestest/bin/bin/code>
,或否则使用替代语法( clang | gcc)
等。It's hard to be sure if this is the problem without seeing clangd logs, but one potential issue is that the argument to
--query-driver
is a regex that's matched against the path of the compiler executable from the commands incompile_commands.json
.I don't think the comma-separated list of paths you are passing is a valid regex. To match those four executables, you may want to use a more permissive regex like
/app/vbuild/RHEL7-x86_64/*/latest/bin/*
, or otherwise use alternative syntax like(clang|gcc)
etc.检查clangd日志后。我认为这与
https://github.com/clangd/clangd/clangd/clangd/issues/1100
After check the clangd logs. I think It's the same issue as
https://github.com/clangd/clangd/issues/1100