handmade.network » Forums » YouCompleteMe - Vim Completion Engine
marcc
Marc Costa
19 posts
#11772 YouCompleteMe - Vim Completion Engine
1 month ago

I found the information in this page: vimcasts.org very useful for some advanced usage scenarions. I haven't read the book, so I can't comment on that.
KaanAlpar
3 posts
#11773 YouCompleteMe - Vim Completion Engine
1 month ago

It's pretty laggy though if you try to backspace a letter
Chen96
Chen
18 posts
#11836 YouCompleteMe - Vim Completion Engine
3 weeks, 3 days ago

YCM is a pretty sweet engine, but how am I going to configure it if I'm doing unity build (the way handmade hero builds)? It seems to me that it treats every .cpp file as a separate compilation unit so it just breaks when I try to do unity build.

Alex
mmozeiko
Mārtiņš Možeiko
1317 posts
1 project
#11837 YouCompleteMe - Vim Completion Engine
3 weeks, 3 days ago

Don't name them with .cpp extension? Maybe "file.impl.h" or just "file.inl" so it will treat them as headers.
timothy.wright
Timothy Wright
72 posts
1 project
#11838 YouCompleteMe - Vim Completion Engine
3 weeks, 2 days ago

Chen96:
YCM is a pretty sweet engine, but how am I going to configure it if I'm doing unity build (the way handmade hero builds)? It seems to me that it treats every .cpp file as a separate compilation unit so it just breaks when I try to do unity build.


I have the same problem developing stb headers. When you are in the header, the #define IMPLEMENTATION isn't defined, so it doesn't parse this code.

It's a little janky, but I just make a define like this:

1
2
3
#if defined(STB_IMPLEMENTATION) || defined(YCM_DEV)
// code here
#endif


Then I just add a
'-DYCM_DEV',
to the .ycm_extra_conf.py

You can also do this same thing and just add whatever includes you need
so ycm will find them but the unity build won't.

1
2
3
4
5
#ifdef YCM_DEV
#include <stdio.h>
#include "thing.cpp"
// whatever else you need
#endif


It is kinda Janky but I haven't found a better way.
Chen96
Chen
18 posts
#11842 YouCompleteMe - Vim Completion Engine
3 weeks, 2 days ago Edited by Chen on May 5, 2017, 7:35 p.m. Reason: Needed to put more information

Oh yeah, didn't think about that! That's a pretty hacked way but it should work just fine. However if I include multiple ini files (treated as headers now) in a cpp file, wouldn't ycm ignore the fact that preceding files will be invisible to the later included ini files?

One question post on stackoverflow that's similar:

http://stackoverflow.com/question...438211/youcompleteme-header-files

In the example that is shown in the post, content that's in a.h is not visible to b.h, but in the cpp file a.h is included before b.h file is included. What's the workaround so that ycm will understand the entire content of a.h should be visible to b.h?

Alex
mmozeiko
Mārtiņš Možeiko
1317 posts
1 project
#11843 YouCompleteMe - Vim Completion Engine
3 weeks, 2 days ago

You should structure the included "cpp" files (.inl or whatever) in a way that they are independent. That means have them #include in the beginning other .h files they depend on.

If you just have .h files without any .cpp and are depending on this implicit dependency then there's nothing you can do...
Chen96
Chen
18 posts
#11844 YouCompleteMe - Vim Completion Engine
3 weeks, 2 days ago

I see. That was pretty helpful, thanks!

Alex