0

I am using YCM to work on a pretty large C project. I generate multiple executables/static libraries hence have multiple makefiles and so multiple compilation databases (generated using BEAR) for different parts of my project (Structure of the project in the image). My problem is that YCM seems to pick a single compilation database for all the files in my vim session based on the directory where I open vim. So for example if I were to edit my server.c and util.c from mainserver/MainServer AND open vim in the same directory, YCM would load their corresponding compilation database and everything works great... BUT if I were to start editing my arrayList.c from misc/ArrayList in the same vim session then it would still use the compilation database from mainserver/MainServer instead of from misc/ArrayList .

My question is how do I get YCM to load a separate compilation database for every file based on its location instead of having YCM load a compilation database depending on where I initially opened vim.

My not very practical solution was to have a single compilation database in the root of my project and generate it by having a shell script find every makefile in my project and then have BEAR generate the compilation databases and append them all at the root of my project...I am hoping there is a better option than that....

Thanks a lot for any help

enter image description here

  • Well, the whole point of YCM and similar plug-ins is that you have project-wide information for completion. After all, you're using ArrayList code in your MainServer, right? And so, don't you want to be able to complete methods of ArrayList in your MainServer? To do so, you need YCM to get the full context. That's why you want that to be project-wide and not per subdirectory. – filbranden Sep 7 at 13:34
  • Another advice is that you probably want to have a single Makefile (or, more accurately, a single make invocation), so that you can properly handle dependencies (touching ArrayList header file to change signature of a method or class means MainServer may need to be rebuilt, or touching ArrayList implementation means you'll need to relink.) You can keep per-directory files that you include, but have a main file at the top that defines how everything is built. That way you also only use BEAR once, from the top level, and that includes everything. – filbranden Sep 7 at 13:36
0

Here is the github issue I started, we have found a solution to this nasty problem https://github.com/ycm-core/YouCompleteMe/issues/3483 In short, switch to clangd completer

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.