Moving to native vim plugin management
Tags: vim, git
Published: 2019-05-18 16:01:27

---
title: Moving to native vim plugin management
published: true
description: With the help of git submodules, here’s how I’ve started managing my plugins without a plugin manager.
tags: vim, git
cover_image: https://thepracticaldev.s3.amazonaws.com/i/n6110ssst4p8pv3dkd2a.jpg
---

I want to start with a disclaimer:
Using a plugin manager is 100% easier, I chose to change my workflow this way because I had certain learnings I wanted to get out of it:
- More minimal configuration/less reliance on plugins in general (by introducing friction for installing plugins, it will make me reconsider if I really need to install it.)
- Better vim runtime knowledge by removing the magic that my plugin manager was doing behind the scenes.
- Better git knowledge (I had never used submodules before!)

If you are looking for a good vim plugin manager that isn’t trying to do too much for you, I highly recommend [vim-plug](https://github.com/junegunn/vim-plug) which has never let me down in the almost 2 years of using it. (If anything, this article is about me letting it down.😞 

With that out of the way let’s talk about the process!

How I went about moving over my plugins were to follow these steps:
- Remove the Plug command from my .vimrc and uninstall with `:PlugClean` command
- Essentially apply the knowledge from [this gist](https://gist.github.com/manasthakur/d4dc9a610884c60d944a4dd97f0b3560) to my own setup.
-  I already have version controlled my dotfiles [with a bare github repo](https://harfangk.github.io/2016/09/18/manage-dotfiles-with-a-git-bare-repository.html) so I skipped right to [Installing plugins](https://gist.github.com/manasthakur/d4dc9a610884c60d944a4dd97f0b3560#installing-plugins) by running

`dotfiles submodule init` 

to first initialize my dotfiles repo to use submodules, and then for each of the plugins I wanted to install:

`dotfiles submodule add https://github.com/some-username/some-plugin.git pack/plugins/start/some-plugin`

Other than that, the instructions in the gist apply. To help maintain this long term, I plan on aliasing some of the commands for updating and removing plugins. I’ve already aliased the updating command:
`alias update_plugins=‘dotfiles submodule foreach git pull origin master’`

When it came to migrating over these changes to my other laptop after the changes had been pushed up things went smoothly! I pulled the repo and then needed to initialize submodules for that repo:
`dotfiles submodule update --init --recursive`

I like this new setup so far (keep in mind I haven’t had to delete a plugin yet) and other than the initial migration process taking a while it’s been a seamless adjustment and I enjoy the granularity of cloning some plugins for one computer into `.vim/pack/plugins/start/` that I don’t want to actually commit to my dotfiles repo without explicitly having to gitignore it.

What I’d like to do next with this set up is play around with the optional loading of plugins! That’s the biggest thing I’m missing from using a manager right now. All in all this was a lengthy but worth it process in terms of getting the learning I wanted to out of it.

The gists I referenced to do this are embedded below, they’re a great resource and I highly recommend them:
- [Managing plugins in Vim: The basics](https://gist.github.com/manasthakur/ab4cf8d32a28ea38271ac0d07373bb53)
- [Using git-submodules to version-control Vim plugins](https://gist.github.com/manasthakur/d4dc9a610884c60d944a4dd97f0b3560)

Thank you to [Manas Thakur](https://github.com/manasthakur) for these resources!