1

I have problems using YCM plugged for C-family languages. Here are what I have done:

  1. project layout
-- build
-- src
   -- source file dir0
      -- include
      main.cpp
   -- source file dir1
      -- include
         -- dir1.h
      -- dir1.cpp
  1. generate compile database running command on windows in directory build as below.
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..\src\ -G "MinGW Makefiles"
  1. copy compile_commands.json to directory src.

  2. 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.

  • I would advise to be more specific with the error you are getting, to make it easier for other people to understand your problem. Also as stated by their contact section I would suggest that you reference your question on their glitter chat, there you should find more people knowledgeable about this plugin who should be able to help your faster. – statox Mar 4 at 8:44
  • Thank you for your comment. I solved my problems using methods as below: 1. use compile_flags.txt instead of compile_commands.json and ycm_extra_config which are not supported on windows platform. 2. turn off the ALE plugin which may conflict with YCM. – Yukun Du Mar 5 at 1:23
  • It's great that you solved your problem! Could you please post an answer to your question explaining these steps (and accept the answer when you can) so that future users know that you found a solution and can try to use it too? – statox Mar 5 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.