Assuming you have a recent version of vim (8.1 should do) this is a lot easier now.
- If you don't already have Vundle:
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim - Add the following section to ~/.vimrc. The vundle section may already be there in which case you just add the Plugin line for Valloric/YouCompleteMe.
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
call vundle#end() - Clone YouCompleteMe.
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe - Update YouCompleteMe.
cd ~/.vim/bundle/YouCompleteMe && git submodule update --init --recursive - Install the clang completer. This works but a better way may be to configure clangd.
./install.py --clang-completer - Add a file .ycm_extra_conf.py to some ancestor directory of your C++ projects.
def Settings( **kwargs ):
return {
'flags': [ '-x', 'c++', '-Wall', '-Wextra', '-Werror' ],
}
There are other ways of doing the above that can give you more flexibility in your own sandbox. You can check them here: https://github.com/ycm-core/YouCompleteMe#general-semantic-completion
Read more!