C/C++ Source Code Completion With YouCompleteMe and Vim for Android and the Linux Kernel
A gif is worth a thousand words -
I’ve been using YCM for a while for C/C++ code completion in the Android source tree as well as the Linux kernel and it just works without any need to generate tags.
It also does syntax error checking on the fly with syntastic, which is an added bonus.
The basic idea is to rely on
.repo as a marker to set up the necessary header paths in
ycm_extra_conf.py for userspace and
Kbuild as a marker for the kernel
Here is my configuration for vim. The python part of the configuration below also works with emacs.
- Install vim > version 7.04 or the latest alpha version of neovim. This can be easily done with brew on OSX or linuxbrew on Linux.
- Install YCM for your OS with the clang completer. I’ve only tested Linux and OSX
- Configure YCM with the following options in your
1 2 3 4 5 6 7 8 9 10 11
Copy the contents of this gist into
~/ycm_extra_conf.pyand that should be it for userspace code!
To configure the kernel for code completion, copy the contents of this gist into
~/ycm_extra_conf_kernel.py. This may or may not work on all kernels, I’ve had varying levels of success depending on the level of clang support in that kernel version, It does seem to work fine with kernel 3.10.
UPDATE - Aug 25, 2015: Updated this post with links to the full config files and edited the ycm configs to avoid the need for sourcing the build environment.