Youcompleteme: Can I install YCM with vim-plug?

Created on 28 Oct 2015  路  11Comments  路  Source: ycm-core/YouCompleteMe

I'm new to vim and I'm trying to install YCM correctly. The README.md says:

Install YouCompleteMe with Vundle.

Am I forced to install YCM using Vundle or I can install it at least manually or using vim-plug? For example, I've found the blog post doing it this way:

$ cd ~/.vim/bundle
$ git clone https://github.com/Valloric/YouCompleteMe.git
$ cd YouCompleteMe
$ ./install.sh

Could you explain, please?

Most helpful comment

It helps to RTFM: the vim-plug README includes two examples uilizing post-update hooks for installation of YCM:

Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }

Or if you would like more precision:
```
function! BuildYCM(info)
" info is a dictionary with 3 fields
" - name: name of the plugin
" - status: 'installed', 'updated', or 'unchanged'
" - force: set on PlugInstall! or PlugUpdate!
if a:info.status == 'installed' || a:info.force
!./install.py
endif
endfunction

Plug 'Valloric/YouCompleteMe', { 'do': function('BuildYCM') }

All 11 comments

No, you are not forced to use Vundle but this is the recommended/supported way. If you want to use vim-plug, add this line to your .vimrc:

Plug 'Valloric/YouCompleteMe'

start Vim and run the command :PluginInstall. It will take some time to download YCM. When done, follow the rest of the instructions in the README.md.

I am closing this since it should answer your question.

Actually, by default VIM-PLUG configuration, I was never able to install YCM through VIM-PLUG, which is what I use, only update it through it.

YCM is too big, with many submodules (and submodules of submodules), so VIM-PLUG will try to clone it, the cloning process will timeout, and it will try to do it from zero again. This happens to me in high speed connections like 10M.

@junegunn tells you may increase g:plug_timeout to a large value: https://github.com/junegunn/vim-plug/issues/75#issuecomment-55514568

What I personally do is to clone YCM myself in the .vim/plugged directory and install it myself. I still let YCM listed as a VIM-PLUG plugin in my .vimrc since updates do work, just the initial clone that's too heavy.

When done, follow the rest of the instructions in the README.md.

@micbou under the "rest" you mean sections goes after Installation?

What I personally do is to clone YCM myself in the .vim/plugged directory and install it myself.

@oblitum, if I get you right, after cloning I will need to add Plug 'Valloric/YouCompleteMe' into .vimrc and run :PluginInstall?

But what about the installation flags like: --gocode-completer and --clang-completer? I'm a little bit confused)

@oblitum The parallel installer of vim-plug (ruby or python) times out only when the stdout of the process is not updated for the designated seconds (default 60). Which means even if the whole process takes much longer than 60 seconds to complete, if the process is constantly printing the progress to stdout (10%, 11%, ...) it should never time out.
Nevertheless, we still experience problems when installing YCM :(

A workaround is either to increase g:plug_timeout as described above or to install YCM exclusively with :PlugInstall YouCompleteMe not to use the parallel installer, thus no timeout. Also there's no timeout if you use neovim.

@micbou under the "rest" you mean sections goes after Installation?

No, just after the line Install YouCompleteMe with Vundle. in the Installation sections. And I made a typo, this is :PlugInstall not :PluginInstall.

Thank you, got it. Now things become clearer..

@timfayz for sake of information, what I meant was not to use :PlugInstall for YCM at any moment, but install it at the command line with the options you care for at the directory VIM-PLUG would clone it if it worked by default. In your .vimrc you leave the Plug command for YCM with the options you care for since :PlugUpdate from now on do work for YCM since it won't timeout in an update.

It helps to RTFM: the vim-plug README includes two examples uilizing post-update hooks for installation of YCM:

Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }

Or if you would like more precision:
```
function! BuildYCM(info)
" info is a dictionary with 3 fields
" - name: name of the plugin
" - status: 'installed', 'updated', or 'unchanged'
" - force: set on PlugInstall! or PlugUpdate!
if a:info.status == 'installed' || a:info.force
!./install.py
endif
endfunction

Plug 'Valloric/YouCompleteMe', { 'do': function('BuildYCM') }

A small update using terminal capability of vim 8.1 and for Visual Studio on Windows:

  1. Starting visual studio shell
  2. Launching install.py in it

    function! BuildYCM(info)
       " info is a dictionary with 3 fields
       " - name:   name of the plugin
       " - status: 'installed', 'updated', or 'unchanged'
       " - force:  set on PlugInstall! or PlugUpdate!
       if a:info.status == 'installed' || a:info.force
         let l:term = term_start('cmd /k c:\apps\MVS15\VC\Auxiliary\Build\vcvars64.bat')
         call term_sendkeys(l:term, "\<CR>set Path=C:\\workdir\\cmake-3.10.2-win64-x64\\bin;%Path%\<CR>")
         call term_sendkeys(l:term, "\<CR>python install.py --clang-completer\<CR>")
       endif
     endfunction
    

Where c:\apps\MVS15 is the path where Visual Studio is installed and C:\\workdir\\cmake-3.10.2-win64-x64 the path to cmake (but you can also add it to system path and remove that line, I use it because I need an older version of cmake for another project and that version is in my system path).

Adding a drive-by comment here as a Note to Self: @schlueter's answer worked fine for me. Specifically, the 'less precise' version. I will probably be back at some point to copy the 'more precise' version, but I'm really just having a play with YCM right now, not sure I want to install it 'for real' yet (lots of moving parts to that plugin...)

Here's what I did:
I added this line in my .vimrc
Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }

after installing it, I got error and what I did was
cd $HOME/.vim/plugged/YouCompleteMe and ran install.py myself. I ran python3 install.py --clang-completer --ts-completer

Was this page helpful?
0 / 5 - 0 ratings