VIM Plugin - YouCompleteMe

Book

YouCompleteMe is a fast, as-you-type, fuzzy-search code completion engine for Vim.

Install

Make sure you have Vim 7.4.1578+ with Python 2 or Python 3 support.

Use Git

1
2
3
4
5
6
:~$ sudo apt-get install build-essential cmake python-dev python3-dev
:~$ cd .vim/bundle
~/.vim/bundle:~$ git clone https://github.com/ycm-core/YouCompleteMe.git YouCompleteMe
~/.vim/bundle:~$ cd YouCompleteMe
~/.vim/bundle/YouCompleteMe:~$ git submodule update --init --recursive
~/.vim/bundle/YouCompleteMe:~$ python ./install.py

Use Vim Plugins - Vundle

  1. Add YouCompleteMe To .vimrc.
    1
    2
    3
    4
    5
    6
    7
    :~$ vim .vimrc
    ....
    call vundle#begin()
    ....
    Plugin 'ycm-core/YouCompleteMe'
    call vundle#end()
    ....
  2. Launch vim and run :PluginInstall

Problem

The ycmd server SHUT DOWN

When you open vim, see the mesage “The ycmd server SHUT DOWN (restart with :YcmRestartServer)”.

  1. remove YouCompleteMe
    1
    :~$ rm -r .vim/bundle/YouCompleteMe
  2. see Use Git, reinstall YouCompleteMe.

YouCompleteMe unavailable

When you open vim, see the message “YouCompleteMe unavailable: unable to load Python”.

Check vim does have python support

  • Method 1
    1
    2
    3
    :~$ vim --version | grep python
    +cryptv +linebreak -python +vreplace
    +cscope +lispindent -python3 +wildignore
    As you can see -python and -python3, VIM doesn’t support Python.
  • Method 2
    Launch vim and run :py pass to see whether supports Python2, and run :py3 pass to see whether supports Python3.

Method

  • install vim-gtk or vim-nox
    1
    2
    3
    4
    :~$ sudo apt-get install vim-nox
    :~$ vim --version | grep python
    +cryptv +linebreak -python +vreplace
    +cscope +lispindent +python3 +wildignore
  • Use neovim instead of vim.
    1
    2
    :~$ sudo apt-get remove vim vim-*
    :~$ sudo apt-get install neovim
  • Building Vim from source. See github

References: