2

I'm configuring a vim environment with YCM.

I'm using the Vundle to manage the vim plugins and here is my .vimrc:

set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

Plugin 'Valloric/YouCompleteMe'
Plugin 'rdnetto/YCM-Generator'

call vundle#end()

filetype plugin indent on

However, after executing "PluginInstall in my vim, I find that YCM is not loaded.

Then Google tells me that I need to add set rtp+=~/.vim/bundle/YouCompleteMe into my .vimrc.

Well, it works but as the Vundle is a plugin manager, can't it load the plugin YCM automatically?

My colleague used another plugin manager: pathogen, I'm not sure but it seems that calling the function pathogen#infect() may load YCM automatically? So pathogen is better than Vundle?

3
  • 1
    There’s not one better than another (though I happen to like vim8’s packages most myself). After running PluginInstall, I would be shocked if YCM was automatically loaded. Have you tried opening a fresh instance of vim after running the install? What does “not loaded” mean (i.e., how do you know)? Does YCM require extra compilation steps (I think so), and have your or Vundle done them?
    – D. Ben Knoble
    Mar 24, 2020 at 13:16
  • @D.BenKnoble After :PluginInstall, I have compiled YCM and reopened a new vim. How do I know? Well, all of YCM commands, such as :YCMCompleter, are not working, just like they don't exist. But if I added set rtp+=~/.vim/bundle/YouCompleteMe into the ~/.vimrc. it would work.
    – Yves
    Mar 25, 2020 at 1:21
  • One of the primary functions of a plugin manager is to configure 'rtp' so what you found on google isn't applicable. Have you read this? github.com/ycm-core/YouCompleteMe/wiki/Full-Installation-Guide And are you intentionally using a fork? I thought official branch was ycm-core/YouCompleteMe
    – B Layer
    Mar 25, 2020 at 10:42

1 Answer 1

2

It seems to me that the issue you're having is that your plug-in manager is correctly loading the YouCompleteMe plug-in, however it's not working right after being installed by the plug-in manager because the external steps required by YouCompleteMe are not completed yet.

So I'm going to go ahead and strongly recommend you switch from Vundle to vim-plug as a plug-in manager. Not only it's much improved from Vundle (it's faster, more efficient, easier to set up), it also supports post-update hooks that can be used to automate execution of external steps needed to complete installation/update of plugins such as YouCompleteMe.

It might be useful to cover how the plugin managers in this particular family fit together. Pathogen can be considered as the "grandfather" of plugin managers, it was instrumental to define what a plugin layout looks like and to establish updating 'runtimepath' to list all plugins there. (Some other plugin managers worked by merging files from all plugins into a single tree.) Pathogen only covers that part, it doesn't cover installing or updating plugins.

Vundle came along, embracing the Pathogen model, introducing configuration through vimrc commands (Bundle, Vundle or Plugin) and adding special commands to install, update and otherwise manage the plugins.

vim-plug builds on the Vundle model but uses modern Vim features to speed up operations and make them parallel. It also simplified setup (just download a single file, no need to be ultra careful with filetype commands) and introduced new features, such as post-update hooks. vim-plug is very similar to Vundle, so it should be quite familiar to Vundle users. The command syntax is different (Plug vs. Plugin, PlugInstall vs. PluginInstall, etc.) but for the most part there's a 1:1 correspondence between them.

The vim-plug wiki has a tip on migrating from other plugin managers which covers Vundle specifically.

The README file mentions YouCompleteMe specifically under post-update hooks, since that's about the canonical example of that (though fzf also comes to mind):

There are some plugins that require extra steps after installation or update. In that case, use do option to describe the task to be performed.

Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }

If you need more control, you can pass a reference to a Vim function that takes a single argument.

function! BuildYCM(info)
  [...]
endfunction

Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }

Both forms of post-update hook are executed inside the directory of the plugin and only run when the repository has changed, but you can force it to run unconditionally with the bang-versions of the commands: PlugInstall! and PlugUpdate!.

I believe this should get you covered. In any case (regardless of YouCompleteMe), I really recommend you migrate from Vundle to vim-plug for all the other advantages. But it should nicely cover the YouCompleteMe set up from start to finish.

3
  • Somewhat off-topic, so I'll leave a comment rather than include this in the answer... But I also strongly recommend coc.nvim as a much superior choice over YouCompleteMe. (It also works on Vim 8, doesn't necessarily need NeoVim to work.) coc.nvim is much superior in how it works and in the completions it offers. Its setup procedure is simpler (well, it also uses an external command, but its quick start is helpful enough to recommend using vim-plug and already has a line ready for copy & paste to fully set it up.)
    – filbranden
    Mar 25, 2020 at 16:43
  • 1
    coc.nvim never worked for me (win10), vim-lsp on the other hand works just fine
    – Maxim Kim
    Mar 25, 2020 at 17:26
  • 1
    Great. You are totally right. I executed ./install.py --all to compile YCM, it failed on compiling the C# part. I only need the C++ part of YCM so I ignore this error.
    – Yves
    Mar 27, 2020 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.