Setting Up a Plugin Manager
To get started adding plugins to your Neovim configuration, you will need a plugin manager.
Why Do I Need a Plugin Manager?
Think of a plugin manager a bit like a package manager for your desktop system.
It saves you the trouble of having to dig through GitHub repositories, manually download the code for the plugin you want, make sure the scripts are in the correct place for Neovim to use, and periodically check for any new updates.
Now imagine doing this for tens or hundreds of plugins.
This is what a plugin manager will do for you auto-magically. 🪄
Installing a Plugin Manager
The current defacto plugin manager in the Neovim ecosystem is lazy.nvim.
To configure lazy, add the following code to your init.lua
file or inside a file in your lua/
directory, e.g. plugins-setup.lua
.
Breaking Down The Code
Here’s a step-by-step breakdown of what this code does.
-
Creates a path to the Neovim data directory:
-
Checks whether that path exists (i.e. checks whether or not you already have lazy installed)
-
If not, clones the repo (in other words installs lazy)
-
Adds lazy to Neovim’s runtimepath
Directly after this code, the plugin manager is bootstrapped and now needs to be setup with the following line of code:
Remember that require
is a Lua thing, not a Neovim thing. While the first code snippet installs the plugin manager, this one runs it.
Congratulations!
You now have your very own Neovim plugin manager setup. Now it’s time to install some plugins.