clangd / coc-clangd

clangd extension for coc.nvim
Apache License 2.0
757 stars 34 forks source link

Env include path not working in header files #674

Closed meclondrej closed 3 months ago

meclondrej commented 3 months ago

I installed coc-clangd with :CocInstall coc-clangd. I set my include path into C_INCLUDE_PATH, colon separated. When i open a .c file, i can see my includes in the autocomplete, causing no issues, however when i open a .h file, the default include path is used, with no paths from C_INCLUDE_PATH available.

Logs

I[11:52:12.428] clangd version 18.1.3 (https://github.com/llvm/llvm-project c13b7485b87909fcf739f62cfa382b55407433c0)
I[11:52:12.428] Features: linux+grpc
I[11:52:12.428] PID: 17672
I[11:52:12.428] Working directory: /home/ondre/avr/avr-syncdata
I[11:52:12.428] argv[0]: ../../.config/coc/extensions/coc-clangd-data/install/18.1.3/clangd_18.1.3/bin/clangd
I[11:52:12.428] Starting LSP over stdin/stdout
I[11:52:12.443] <-- initialize(0)
I[11:52:12.444] --> reply:initialize(0) 1 ms
I[11:52:12.449] <-- initialized
I[11:52:12.455] <-- textDocument/didOpen
I[11:52:12.456] Failed to find compilation database for /home/ondre/avr/avr-syncdata/include/syncdata.h
I[11:52:12.456] ASTWorker building file /home/ondre/avr/avr-syncdata/include/syncdata.h version 1 with command clangd fallback
[/home/ondre/avr/avr-syncdata/include]
/usr/bin/clang -xobjective-c++-header -resource-dir=/home/ondre/.config/coc/extensions/coc-clangd-data/install/18.1.3/clangd_18.1.3/lib/clang/18 -- /home/ondre/avr/avr-syncdata/include/syncdata.h
I[11:52:12.457] --> textDocument/clangd.fileStatus
I[11:52:12.469] Built preamble of size 226184 for file /home/ondre/avr/avr-syncdata/include/syncdata.h version 1 in 0.01 seconds
I[11:52:12.470] --> workspace/semanticTokens/refresh(0)
I[11:52:12.472] <-- reply(0)
I[11:52:12.472] Indexing c++17 standard library in the context of /home/ondre/avr/avr-syncdata/include/syncdata.h
I[11:52:12.494] --> textDocument/publishDiagnostics
I[11:52:12.494] --> textDocument/clangd.fileStatus
I[11:52:12.652] <-- textDocument/documentLink(1)
I[11:52:12.654] --> reply:textDocument/documentLink(1) 1 ms
I[11:52:12.655] --> textDocument/clangd.fileStatus
I[11:52:14.735] Indexed c++17 standard library (incomplete due to errors): 14125 symbols, 1807 filtered

System information Clangd version (from the log, or clangd --version): 18.1.3 clangd extension version (from :CocInfo): output does not show clangd extension version Operating system: Arch Linux

fannheyward commented 3 months ago

Failed to find compilation database for /home/ondre/avr/avr-syncdata/include/syncdata.h

You need to setup compile_commands.json for your project, to make clangd can understand your code. https://clangd.llvm.org/installation#project-setup