I have problems using YCM plugged for C-family languages. Here are what I have done:
- project layout
-- build
-- src
-- source file dir0
-- include
main.cpp
-- source file dir1
-- include
-- dir1.h
-- dir1.cpp
- generate compile database running command on windows in directory build as below.
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..\src\ -G "MinGW Makefiles"
copy compile_commands.json to directory src.
I also generate configure file to src/.ycm_extra_conf.py with contents as below.
flags = [
'-x',
'c++',
'-I',
'dir1/include',
]
def Settings(**kwargs):
return {'flags': flags}
I compiled both clangd and libclang during installation. Since clangd is default selected by YCM, I switch clangd and libclang by manipulating vimrc setting ycm_use_clangd.
After doing all these above, The completion and syntax checking seem not working at all.
#include "dir1.h" ==> diagnosed as header file not FOUND
And those functions and variables defined in dir1.h are diagnosed as undefined.