What's the best way to manage my vim plugins?

I have two machines on which I’d like to share my entire Vim configuration. So, I create a git repo in the top-level .vim directory and add my .vimrc, among other things. Then I clone a plugin into .vim/bundle, e.g.

$ cd bundle 
$ git clone https://github.com/nelstrom/vim-textobj-rubyblock
$ ls vim-textobj-rubyblock/ | wc -l
  18

So far so good – everything works fine. Then I commit and push my top-level repo, go to my second machine, and clone the whole thing – and now none of the sub-repositories actually get pulled down with the project (though their top-level folders do):

$ ls
  vim-textobj-rubyblock
$ ls -la vim-textobj-rubyblock
  drwxr-xr-x   2 rct  staff   68 Feb 26 21:14 ./
  drwxr-xr-x  25 rct  staff  850 Feb 26 21:14 ../

So, what to do? Some options:

  1. the dread git submodule
  2. git subtree
  3. delete the .git from each plugin I clone
  4. some gitignore hack?

I’ve tried both subtree and submodule and ran into a bunch of (different) errors. Before I sort them out, I’d like to be sure I’m not missing something easier here. My only requirement is that I want things to easily clone/pull on each of my machines so I can, say, add a plugin on one and quickly update my configuration on the other; a nice-to-have is the ability to quickly update a sub-repo to the latest version. I do not necessarily need the ability to push the sub-repo back upstream, at least for now.

How do Thoughtbot folks manage their 3rd-party Vim plugins so the configuration is available on multiple machines?

The thoughtbot dotfiles use Vundle, but there is a proposal to switch over to vim-plug.

Very interesting. I didn’t know vundle was defunct.

Vundle’s main author has moved away from it for the time being, but other’s have picked up the torch and are actively maintaining it. I personally use Vundle, but would likely use vim-plug were I to start over today. The feature set is a bit nicer (parallel installs and lazy loading, specifically).

I would strongly recommend against using git submodules. I’ve done it in the past and it was a mess. One of the few features of git that feels half baked. Instead, I would just git ignore the ~/.vim/bundle/ directory and let any of Vundle, vim-plug, etc manage it.

2 Likes

What are the advantages of Vundle/Vim-Plug over Pathogen?

Hey @crispincornett

Both Vundle & Vim-plug allow you to define the plugins you want to use in your vimrc, and then install via provided commands in Vim. This has the benefit that you can track the plugins in git in a very lightweight way. See the thoughtbot dotfiles vimrc.bundles file for an example. I really value having this list in git.

Pathogen expects you to take care of downloading the plugins into the ~/.vim/bundle/ directory manually.

Vim-plug has some additional enhancements around parallel installations as well as lazy loading plugins. Both sound great, and the author Junegunn Choi is extremely talented and prolific in the Vim plugin world, but I’ve yet to find it compelling enough to move away from Vundle. You can see a longer discussion in the thoughtbot dotfiles about moving to vim-plug

Perfect, thanks @christoomey.

I started with Pathogen (since Tim Pope recommended it), but have really liked Vundle.

I also experimented with VimPlug in the meantime, and it is crazy fast, but not didn’t notice much else different (though that’s not saying much :slight_smile: ).

Appreciate the response.

I did the same as a number of folks apparently have done: started with Pathogen then switched to Vundle which I like and am still using. Used to be you could count on a vim plugin having instructions for installing with either of those. But the plugin manager world has gotten pretty crowded all of a sudden: see this site, for example.

What bugs me a little is that now, some plugins recommend use of another, new plugin manager, such as honza/vim-snippets, and don’t give you the “usual” documentation. I discovered this when I went to update to the latest snippets engine by garbas because the msanders version has gone stale. There it’s recommended that you use the Vim Addon Manager (VAM) by Marc Weber which I had never heard of. Of course, this is not much of a problem as coding the Vundle Plugin commands is dead simple. But it speaks to a little more “fragmentation” in the Vim eco-system than I’ve seen in the past. Probably not a bad thing as the “good stuff” should rise to the surface over time and we’ll get better solutions.

By way of example, the new snippets engine by garbas is much improved over the original version. You can have multiple definitions that start with the same letters and you get a little popup showing you the other options which you can select. For example, if you type sec{Tab} in an HTML document, you see:

which is now quite similar to the code-completion found in common IDEs. You just arrow up/down and then press {Enter} to select the option you want. Or if I just press {Tab} again, I get a basic HTML section. Sweet!