VimPlugin: YouCompleteMe

From wikinotes

YouCompleteMe is an autocompletion engine for vim. It work as you type, and it leverages other autocomplete engines as it works. This means you don't have to choose between jedi-vim/youcompleteme, it uses it on the backend along with other suitable autocompletion engines for other languages.

NOTE:

YouCompleteMe required a recompilation every update. It was slow. I moved to a LSP completer

Documentation

github https://github.com/ycm-core/YouCompleteMe

Install

YouCompleteMe HAS A COMPILED COMPONENT. Installing with vundle is not enough, you'll need to either compile the other half from source, or install a package for it.

sudo pacman -S libclang cmake python2-dev

cd ~/.vim/vundle/YouCompleteMe
./install.py \
    --clang-completer \
    --java-completer

Languages

Python

Python support is built on top of jedi.

prerequisites

Whichever interpreter is being used for YouCompleteMe's YCM server must have the pacakge jedi installed. Unless you specify a different interpreter, this will be vim's default python interpreter

find vim python interpreter

:py import sys;print(sys.version_info)
:py import sys;print(sys.executable)

install jedi

pip install jedi   # for vim's default python version

NOTE Packages are on the $PYTHONPATH that vim is executed within.

install.py args


No install.py flags are required.

set project interpreter (optional)


If using virtualenvs (or vim's default python version is not desired), you can inform youcompleteme which python interpreter to use by droping a .ycm_extra_conf.py file at the root of your project (or anywhere above it).

def Settings(**kwargs):
    return {
        'interpreter_path': '/usr/bin/python3'
    }

NOTE:

For suggestions in from X import Y style imports, use Ctrl+Space. (tab would add a tab)

C/C++ (clang)

Out of the box, you should be able to auto-complete using generic identifier based completion, but it can be made much more powerful if you use native semantic code completion.

prerequisites

pacman -S clang
pacaur -S bear

install.py args

cd ~/.vim/bundle/YouCompleteMe
python3 install.py --clang-completer

compiling project


For accurate suggestions specific to your project, you'll need to generate a compile_commands.json.

Various build systems can do this (like cmake), but bear seems to be build-system agnostic.

Simply run <bear> before your build system command.

bear make
bear cmake
# etc..

You can incorporate this directly into your makefile so that it is handled behind the scenes.

CC = bear clang++ -std=c++14   # add 'bear' before compiler
# ...

bin/main: 
    $(CC) $(CFLAGS) # ...

Java

Java support is experimental.


prerequisites


Your project must be setup using either maven or gradle for semantic completion.

sudo pacman -S maven

eclimm/syntastic must be disabled for java.

let g:syntastic_java_checkers = []
let g:EclimFileTypeValidate = 0

install.py args


cd ~/.vim/bundle/YouCompleteMe/
install.py --java-completer

project setup

I have only tested maven, but the presence of pom.xml seems to be sufficient.

For Additional/Latest notes, see https://github.com/Valloric/YouCompleteMe#java-semantic-completion