I’ve been using Neovim with clangd for C, and I’m encountering an issue with my configuration when working with C++ files that include windows.h
. While I’ve set up my configuration file config.yaml
to use MinGW compilers without any problem for C files, it seems like clangd can’t find windows.h
when processing C++ files.
These is my old config.yaml
(was working well with c):
CompileFlags:
Compiler: x86_64-w64-mingw32-gcc
Add: ["-I../headers", "-I$INCLUDE_PATH"]
But now i want to work with c++, so
Here’s my new config.yaml
:
If:
PathMatch: .*.c .*.h
CompileFlags:
Compiler: x86_64-w64-mingw32-gcc
Add: ["-I../headers", "-I$INCLUDE_PATH"]
---
If:
PathMatch: .*.cpp .*.hpp
CompileFlags:
Compiler: x86_64-w64-mingw32-g++
Add: ["-I../headers", "-I$INCLUDE_PATH"]
---
And these happens:
Even though the it compiles without any issues.
These is neovim LSP log if it’s can help.
[START][2024-05-01 19:22:24] LSP logging initiated
[ERROR][2024-05-01 19:22:24] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:24.429] clangd version 17.0.3 (https://github.com/llvm/llvm-project 888437e1b60011b8a375dd30928ec925b448da57)nI[19:22:24.429] Features: linux+grpcnI[19:22:24.429] PID: 1238686nI[19:22:24.429] Working directory: /home/panda/path/tonI[19:22:24.429] argv[0]: /home/panda/.local/share/nvim/mason/bin/clangdnI[19:22:24.429] Starting LSP over stdin/stdoutnI[19:22:24.429] <-- initialize(1)n"
[ERROR][2024-05-01 19:22:24] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:24.430] --> reply:initialize(1) 0 msn"
[ERROR][2024-05-01 19:22:24] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:24.431] <-- initializednI[19:22:24.432] <-- textDocument/didOpennE[19:22:24.432] config error at /home/panda/.config/clangd/config.yaml:24:0: Config should be a dictionarynI[19:22:24.432] --> textDocument/publishDiagnosticsnI[19:22:24.432] Failed to find compilation database for /home/panda/path/to/main.cppnI[19:22:24.432] ASTWorker building file /home/panda/path/to/main.cpp version 0 with command clangd fallbackn[/home/panda/path/to]n/usr/lib/llvm-16/bin/clang -resource-dir=/home/panda/.local/share/nvim/mason/packages/clangd/clangd_17.0.3/lib/clang/17 -- /home/panda/path/to/main.cppn"
[ERROR][2024-05-01 19:22:24] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:24.678] Built preamble of size 3580972 for file /home/panda/path/to/main.cpp version 0 in 0.25 secondsn"
[ERROR][2024-05-01 19:22:24] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:24.678] --> workspace/semanticTokens/refresh(0)n"
[ERROR][2024-05-01 19:22:24] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:24.679] Indexing c++17 standard library in the context of /home/panda/path/to/main.cppn"
[ERROR][2024-05-01 19:22:24] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:24.679] <-- reply(0)n"
[ERROR][2024-05-01 19:22:24] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "E[19:22:24.685] IncludeCleaner: Failed to get an entry for resolved path : No such file or directoryn"
[ERROR][2024-05-01 19:22:24] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:24.685] --> textDocument/publishDiagnosticsn"
[ERROR][2024-05-01 19:22:24] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:24.689] <-- textDocument/signatureHelp(2)n"
[ERROR][2024-05-01 19:22:24] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:24.691] --> reply:textDocument/signatureHelp(2) 2 msn"
[ERROR][2024-05-01 19:22:25] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:25.962] Indexed c++17 standard library (incomplete due to errors): 13604 symbols, 1918 filteredn"
[ERROR][2024-05-01 19:22:26] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:26.750] <-- textDocument/didSaven"
[ERROR][2024-05-01 19:22:26] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:26.750] File version went from 0 to 0n"
[ERROR][2024-05-01 19:22:26] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:26.800] Failed to find compilation database for /home/panda/path/to/main.cppn"
[ERROR][2024-05-01 19:22:26] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:26.800] ASTWorker building file /home/panda/path/to/main.cpp version 0 with command clangd fallbackn[/home/panda/path/to]n/usr/lib/llvm-16/bin/clang -resource-dir=/home/panda/.local/share/nvim/mason/packages/clangd/clangd_17.0.3/lib/clang/17 -- /home/panda/path/to/main.cppn"
[ERROR][2024-05-01 19:22:27] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:27.008] <-- textDocument/signatureHelp(3)n"
[ERROR][2024-05-01 19:22:27] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:27.016] --> reply:textDocument/signatureHelp(3) 7 msn"
[ERROR][2024-05-01 19:22:34] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:34.880] <-- textDocument/signatureHelp(4)n"
[ERROR][2024-05-01 19:22:34] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:34.888] --> reply:textDocument/signatureHelp(4) 7 msn"
[ERROR][2024-05-01 19:22:35] .../vim/lsp/rpc.lua:734 "rpc" "/home/panda/.local/share/nvim/mason/bin/clangd" "stderr" "I[19:22:35.437] <-- shutdown(5)nI[19:22:35.437] --> reply:shutdown(5) 0 msn"
Is this problem related to my new config? If so, how can I configure clangd to use Mingw compilers for both C and C++?
Thanks!
I’ve tried adjusting the paths and configurations, but haven’t had any luck so far. Any suggestions on how to resolve this would be greatly appreciated.