1

Right now I am using Pathogen to manage bundles in my ~/.vim folder.

I also have my public dotfiles repo which has all my configs, including my entire .vim folder. I don't use symlinks to do this, because it has been a nightmare doing it that way. Whenever I want to update my dotfiles repo I just copy and paste the whole .vim folder periodically.

I used to download all repos manually from GitHub and update them that way, but I just redid everything using git clone so that I can update all my local vim bundles easily.

The problem now though is that I can't commit these repos... I suppose I can do something with submodules but I don't know the logistics of that.

Is there a way I can make pathogen just re-download all the repos if I just give it some git paths? That would be ideal, so that whenever someone uses my dotfiles they just download the fresh versions with one command, kind of like how npm works.

What are my other options to solve this?

My goals are:

  1. I can easily update my own bundles with a recursive git pull or some other easy command
  2. I can commit this so that other people using my dotfiles can run that same command
  3. I don't want to use symlinks

Thanks!

Edit: This might be a wack idea, but what if I just create a vim function which pulls the repos, and I place that command right in my .vimrc. This command would pull the repos, that way I can install/update all in the same command.

From there, I would just decide 'what' bundles go in my .vim folder by modifying that one list. I imagine some plugin out there does this already?

  • Re: your last bit, I believe thats exactly what Vundle does (dont know, never tried). Managing submodules with pathogen is exactly what I do (and can write you an answer on it later). – D. Ben Knoble Jan 22 '18 at 8:09
  • Using git submodules is the normal way of doing this, and it isn't as logistically difficult as you seem to imply. The VimCasts episode should explain everything you need to know. As @DavidBenKnoble points out, what you'd be doing in the idea in your edit is implementing an adhoc plugin manager. There are already a range existing plugin managers you could use if you'd like this functionality. – Rich Jan 22 '18 at 11:17
  • oh nice... thanks so much. ok, if one of yall want to put that as an answer ill mark it (about submodules) – Tallboy Jan 22 '18 at 20:56
4

Using git submodules is a common way of doing this. The VimCasts episode is a great explanation, but the basic commands are as below:

Adding a new plugin

cd ~/.vim
git submodule add http://github.com/<username>/<pluginname>.git bundle/<pluginname>
git add .
git commit

Updating a plugin

Git submodules are also repositories in their own right:

cd ~/.vim/bundle/<pluginname>
git pull

Installing/updating plugins on another machine

cd ~/.vim
git pull
git submodule update --init

Note that this workflow is not specific to Pathogen: it works fine using Vim 8's packages feature and file paths.

An alternative to all the above is to delegate installation/upkeep of your plugins to a Plugin Manager. Vim has plenty of options if that's the path you choose to take.

2

I have tried the submodule approach and ... I ended up switching to vim-plug. This is essentially what Vundle, vim-plug etc. do: you provide a list of plugins (or repositories), and Vundle/vim-plug provides you functions or commands to install/update them all.

My current setup is like this: things in ~ in one repo, with a submodule or two for zsh plugins and ~/.vim. So now my initialization looks like this:

git clone --recursive https://.../home.git
cp -r home/. ~ && rm -rf home
vim -c PlugUpdate

Not a one liner, but not particularly complicated either.

The main reason why I switched to vim-plug was updating the plugins. Updating submodules is an annoyance. This is especially complicated by plugins like YouCompleteMe which themselves include submodules, so you don't want to blindly pull in the latest of everything in every submodule (and so you should be cautious with using recursive updates). I think this can be done safely by adding submodules tracking a branch, but I'd rather not learn Git that much unless I need to.

But all told, using vim-plug is far easier than messing around with submodules. Note that, unlike Vundle, the vim-plug script is directly added to .vim/autoload, just like with pathogen, so if you have the .vim directory, you can just run the PlugInstall vim command.


vim-plug also sweetened the deal with conditional installation of plugins - since I didn't want all my plugins everywhere. It doesn't make sense to install, say, vim-go on a server which would never have golang installed.

  • I marked the answer correct because it was directly related to my question, but FWIW I actually switched to vim-plug yesterday and I'm so glad I did. I'll never look back at vundle or pathogen again. – Tallboy Jan 23 '18 at 17:29
  • I did give you an upvote though :D – Tallboy Jan 23 '18 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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