I've been using Neovim with clangd for C and 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):
However, when I include windows.h in a C++ file and run clangd, it gives me an error saying that the file is not found:
clangd --enable-config --check=path/to/main.cpp
I[17:59:03.566] Debian clangd version 16.0.6 (19)
I[17:59:03.566] Features: linux+grpc
I[17:59:03.566] PID: 1039827
I[17:59:03.566] Working directory: /home/panda
I[17:59:03.566] argv[0]: clangd
I[17:59:03.566] argv[1]: --enable-config
I[17:59:03.566] argv[2]: --check=path/to/main.cpp
I[17:59:03.566] Entering check mode (no LSP server)
I[17:59:03.566] Testing on source file /home/panda/path/to/main.cpp
E[17:59:03.566] config error at /home/panda/.config/clangd/config.yaml:24:0: Config should be a dictionary
I[17:59:03.566] Loading compilation database...
I[17:59:03.567] Failed to find compilation database for /home/panda/path/to/main.cpp
I[17:59:03.567] Generic fallback command is: /usr/lib/llvm-16/bin/clang -resource-dir=/usr/lib/llvm-16/lib/clang/16 -- /home/panda/path/to/main.cpp
I[17:59:03.567] Parsing command...
I[17:59:03.568] internal (cc1) args are: -cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/panda/path/to -resource-dir /usr/lib/llvm-16/lib/clang/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/x86_64-linux-gnu/c++/13 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/backward -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir=/home/panda/path/to -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -no-round-trip-args -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c++ /home/panda/path/to/main.cpp
I[17:59:03.568] Building preamble...
I[17:59:03.811] Indexing headers...
I[17:59:03.879] Built preamble of size 3577908 for file /home/panda/path/to/main.cpp version null in 0.31 seconds
E[17:59:03.879] [pp_file_not_found] Line 2: 'windows.h' file not found
I[17:59:03.879] Building AST...
I[17:59:03.884] Indexing AST...
I[17:59:03.885] Building inlay hints
I[17:59:03.885] Building semantic highlighting
I[17:59:03.885] Testing features at each token (may be slow in large files)
I[17:59:03.887] All checks completed, 1 errors
Now, I encountered an issue with the new config. It's throwing an error message here:
E[17:59:03.566] config error at /home/panda/.config/clangd/config.yaml:24:0: Config should be a dictionary
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+grpc\nI[19:22:24.429] PID: 1238686\nI[19:22:24.429] Working directory: /home/panda/path/to\nI[19:22:24.429] argv[0]: /home/panda/.local/share/nvim/mason/bin/clangd\nI[19:22:24.429] Starting LSP over stdin/stdout\nI[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 ms\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.431] <-- initialized\nI[19:22:24.432] <-- textDocument/didOpen\nE[19:22:24.432] config error at /home/panda/.config/clangd/config.yaml:24:0: Config should be a dictionary\nI[19:22:24.432] --> textDocument/publishDiagnostics\nI[19:22:24.432] Failed to find compilation database for /home/panda/path/to/main.cpp\nI[19:22:24.432] ASTWorker building file /home/panda/path/to/main.cpp version 0 with command clangd fallback\n[/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.cpp\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.678] Built preamble of size 3580972 for file /home/panda/path/to/main.cpp version 0 in 0.25 seconds\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.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.cpp\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] <-- 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 directory\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.685] --> textDocument/publishDiagnostics\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.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 ms\n"
[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 filtered\n"
[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/didSave\n"
[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 0\n"
[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.cpp\n"
[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 fallback\n[/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.cpp\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.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 ms\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.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 ms\n"
[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 ms\n"
Do you think this problem is related to my new config? If so, how can I configure clangd to use Mingw compilers for both C and C++?
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.
Hey there,
I've been using Neovim with clangd for C and 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 fileconfig.yaml
to use MinGW compilers without any problem for C files, it seems like clangd can't findwindows.h
when processing C++ files.These is my old
config.yaml
(was working well with c):Here's my new
config.yaml
:However, when I include
windows.h
in a C++ file and run clangd, it gives me an error saying that the file is not found:Now, I encountered an issue with the new config. It's throwing an error message here:
These is neovim LSP log if it's can help.
Do you think this problem is related to my new config? If so, how can I configure clangd to use Mingw compilers for both C and C++? 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.
Thanks!