Why I use Lazy to manage Nvim plugins
Lazy is easy and convenient, even if you don't really need Lazy loading
Do you need a base Neovim configuration to use as a starting point for configuration? Or as a guide to how to accomplish configuration tasks in Lua that you’re used to doing in Vimscript? I’ve just published an example Neovim configuration up on Github. It’s extremely minimal right now — I plan to build it up over the course of writing this newsletter as I cover various plugins and aspects of Neovim — but I wanted to share it now because the basic structure might be useful as a guide, especially if you have an existing complicated configuration that you’re either trying to understand and take control of, or update from Vim.
One decision I made here that might be a little bit surprising is that I’m not using an older package manager like Packer or Plug. Instead, I use Lazy, just like I do for my personal configuration. I’ve included it here because if you’re using Neovim I think you should probably use it, too.
(This is slightly less weird of a choice than it was six months ago. It appears that, while Packer is still maintained, the community that uses it is shifting towards Lazy.)
Lazy’s name is a little bit misleading. Its named for its headline feature — lazy loading — and I’ve seen a lot of folks, including myself, assume that they don’t need it because they just don’t have that many plugins.
I use it instead mostly for one specific feature: It automatically installs new plugins on startup. I don’t have to run an extra install command.
It does this without constantly updating my plugins, because it has a lockfile. When it installs a new plugin it stores the version in this file and then only uses that version until I tell it to update.
The other thing I like about Lazy is that it takes its configuration as a table. Entries in the table can be just the plugin name as a string, if you don’t have any configuration for the plugin, or they can be tables, if the plugin takes configuration. This is mostly an aesthetic preference but I expect this to make it easier to manage generating and managing multiple sets of plugins.
The main downside I’m aware of with Lazy is that it takes over plugin management entirely away from Neovim, which means its possible that using Lazy will cause weird problems. I haven’t run into anything like this myself yet, and its less and less likely to be an issue as the project gets older and more widely used.
Note that you don’t even need a package manager to run plugins in Neovim. It’s purely a configuration convenience. if you want an extremely standard experience you can download plugins directly into your config directory.
Anyway— while you’ll definitely get the most out of Lazy if you have lots of plugins, if the question of “what plugin manager to use?” is blocking you from switching to Lua configuration, my advice is “just use Lazy.” It’s pretty straightforward even if you don’t have enough plugins to make its fancy loading features relevant.