i just installed YouCompleteMe for Vim through vundle. It works, but it shows only the words contained in the current file. I want to use it to develop c++ programs, how can i configure it to show autocompletion from c++ headers file in /usr/include for example? Thanks a lot.
-
2You need to build and install clang for semantic completion. Did you follow the installation process detailed in YCM readme? – romainl Apr 28 '13 at 16:09
-
Yes, I follow the instructions but i only get local autocompletion. In order i have installed YCM as a vundle bundle and I executed the install script located in the YCM directory. Is there some kind of configuration that I missed? – mastergap Apr 29 '13 at 11:02
-
9Did you do `./install.sh --clang-completer` or `./install.sh`? – romainl Apr 29 '13 at 11:29
-
I missed the --clang-completer option. Thanks a lot. Put an answer maybe, this way I can mark it as a correct solution. – mastergap May 06 '13 at 07:36
-
@mastergap You can answer you own question. – Dilawar Jul 01 '13 at 08:14
5 Answers
You need to navigate to ~/.vim/bundles/YouCompleteMe
and run the installation script with --clang-completer
, so do ./install.sh --clang-completer
. After it finishes you should have support for C like languages.
You may also need to place let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'
in your ~/.vimrc
.

- 861
- 2
- 14
- 30
-
10for new version of ycm it changed to : `let g:ycm_global_ycm_extra_conf = ".vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py" ` – Iman Mirzadeh Feb 18 '15 at 23:53
-
5for me it seems totally weired and unintuitive to define this config. Why do I need to set this config to a hidden file deep down in the plugin folder? For me this just feels wrong. – Arne Apr 01 '15 at 12:51
-
1
I have installed with pathogen. I tried the above instructions with ./install.sh --clang-complete. After this, it did not work, and I indeed had to add the path. But it was different than in another reply here, namely
let g:ycm_global_ycm_extra_conf = '.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
so there is an extra "third_party/ycmd" in the path.

- 126
- 1
- 3
While the suggestions here might work in the beginning, I am not sure it's the proper way to go. According to YCM developer, whenever you start a project, you need a new .ycm_extra_conf.py file
From https://valloric.github.io/YouCompleteMe/#ubuntu-linux-x64-super-quick-installation
YCM looks for a .ycm_extra_conf.py file in the directory of the opened file or in any directory above it in the hierarchy (recursively); when the file is found, it is loaded (only once!) as a Python module. YCM calls a FlagsForFile method in that module which should provide it with the information necessary to compile the current file. You can also provide a path to a global .ycm_extra_conf.py file, which will be used as a fallback. To prevent the execution of malicious code from a file you didn't write YCM will ask you once per .ycm_extra_conf.py if it is safe to load. This can be disabled and you can white-/blacklist files. See the Options section for more details.
While you might only need to modify the compile flags from the vanilla .ycm_extra_conf.py, I feel it is advisable to create a new file for every project you start.

- 148
- 2
- 6
-
1
-
The edit queue is full, so putting the updated link here https://github.com/ycm-core/YouCompleteMe#option-2-provide-the-flags-manually – ljden Jun 23 '20 at 05:55
Everything that the folks here have said is correct. I just want to add that as of 2017, the "install.sh" script is deprecated. Now, you have to use the install.py script instead by typing
./install.py --clang-completer
Also, in your .vimrc file, instead of ".vim/bundle/blahblahblah", you'll need to add a "~/" in front of the address by adding:
let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py"
to your .vimrc file, to give it an absolute path from the Home directory so that Vim can find the ".ycm_extra_conf.py" file. Otherwise, you might experience some funny behavior.

- 124
- 1
- 5
I just wanted to add if you don't want to manually define a config file there is this neat little repository that will auto generate it. https://github.com/rdnetto/YCM-Generator

- 43
- 6
-
Don't write comments as answers. Invest some time in the site and you will gain sufficient [privileges](//stackoverflow.com/privileges) to comment and vote on questions and answers. – RaminS Feb 16 '19 at 00:22