Closed themightyoarfish closed 4 months ago
Very clear bug report!
But unfortunately, the file not found
issue is clangd's work. coc.nvim + coc-clangd is LSP client, what it did:
The clangd server reports file not found
issue, published to client, and client displayed it.
Ping @sam-mccall @HighCommander4 for the help
I found that removing this block from my neovim config fixed the issue
lua <<EOF
require("lspconfig").clangd.setup({
on_attach = function()
vim.call('LspAttached')
end
})
EOF
I don't remember where i copied this from and don't know what the purpose is, but maybe this helps someone else.
Actually this is part of config to set up keymappings, which now of course no longer work
call dein#add('neovim/nvim-lspconfig')
function! LspAttached() abort
" LSP actions
nnoremap <buffer> K <cmd>lua vim.lsp.buf.hover()<cr>
nnoremap <buffer> gd <cmd>lua vim.lsp.buf.definition()<cr>
nnoremap <buffer> gD <cmd>lua vim.lsp.buf.declaration()<cr>
nnoremap <buffer> gi <cmd>lua vim.lsp.buf.implementation()<cr>
nnoremap <buffer> go <cmd>lua vim.lsp.buf.type_definition()<cr>
nnoremap <buffer> gr <cmd>lua vim.lsp.buf.references()<cr>
" conflicts with compile shortcut
" nnoremap <buffer> <C-k> <cmd>lua vim.lsp.buf.signature_help()<cr>
nnoremap <buffer> <leader><C-r> <cmd>lua vim.lsp.buf.rename()<cr>
nnoremap <buffer> <leader><C-n> <cmd>lua vim.lsp.buf.code_action()<cr>
xnoremap <buffer> <F4> <cmd>lua vim.lsp.buf.range_code_action()<cr>
" Diagnostics
nnoremap <buffer> gl <cmd>lua vim.diagnostic.open_float()<cr>
nnoremap <buffer> [d <cmd>lua vim.diagnostic.goto_prev()<cr>
nnoremap <buffer> ]d <cmd>lua vim.diagnostic.goto_next()<cr>
endfunction
lua <<EOF
require("lspconfig").clangd.setup({
on_attach = function()
vim.call('LspAttached')
end
})
EOF
sigh.
You're mixed using coc.nvim and nvim's builtin LSP client, you shouldn't use them at same time.
@sam-mccall @HighCommander4 you can ignore this, sorry to boring you.
I don't know if this is a clangd problem or what, and I also cannot really provide a minimally reproducible example, because the problem does not appear when removing everything unrelated from the project.
Context: Cmake with compilation database, neovim v0.10.0-dev-1484+g0774d0cfe and coc.nvim version 0.0.82-e3f91b5e 2023-10-19 15:01:32 +0800.
The cmake setup includes some third party dependencies added via
find_package()
, nothing special here. Now when I open my header file, it includes these third-party headers, and clangd saysWhen checking clangd log, I can see that the compiler command seems to get correctly created by using the corresponding cpp file
Note that
/Users/rasmus/Documents/Projects/foobar/deps/include
is the exact include path needed to find the third party headers, just as I include them in my hpp file. So the include path is correctly set up, but still I get "file not found".Is this a clangd issue or a coc-clangd issue? What should I do to debug this? I could not reproduce the problem by copying the cmake project structure without any other content. I also tried not having the dependencies installed in the project root, also did not help. I'm royally confused at this point.
Logs
System information Clangd version (from the log, or
clangd --version
):clangd extension version (from
:CocInfo
):Operating system:
MacOS
Coc config: