Using a New Neovim Plugin Manager

Switching to lazy.nvim to Manage Neovim Packages

Posted on:

I may be the last person to have heard the news, but Packer has been unmaintained since August 2023. I only now found this out when something went wrong with a PackerSync and I went to look at the documentation. I wish there was a better way to find out something in your config is unmaintained, archived, or deprecated besides waiting for something to fail, but I digress. Packer's GitHub recommends using lazy.nvim and so, without doing any other research, that's what I've gone with.

Switching to lazy.nvim was fairly straightforward. The code for boot-strapping lazy.nvim can be found on the project's readme. Then, I needed to convert the packer.startup function that initializes the plugins to the table that's required by lazy.nvim.


return packer.startup(function(use)
-- My plugins here
use "wbthomason/packer.nvim"
use "nvim-lua/popup.nvim"


local plugins = {

There were a few minor changes in syntax as well. For example, calling a plugin and changing its name in Packer uses

{ "plugin", as = "name" }

where lazy.nvim uses

{ "plugin", name = "name" },

or calling a command when a plugin is loaded with something like tree-sitter in Packer would be

use { "nvim-treesitter/nvim-treesitter", run = ":TSUpdate", }

where lazy.nvim is

{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },

Not too bad and it appears most plugins have documentation for how they want to be called using lazy.nvim anyway.

Running checkhealth lazy as advised by the lazy.nvim readme showed I still had some Packer files that needed to be removed. Once that was done and Neovim was restarted, all of my plugins reinstalled using lazy.nvim and I was good to go, super simple.

I really like the Mason inspired interface lazy.nvim uses. I feel like with its lazy loading feature, my Neovim start time is just a slight bit faster, which is great too. The one thing I'm going to miss is this little bit of code I had in my plugin config:

vim.cmd [[
augroup packer_user_config
autocmd BufWritePost plugins.lua source <afile> | PackerSync
augroup end

This autocommand would source the plugins.lua file after any changes were made to it and run a PackerSync. That made it so anytime I added or removed a plugin to or from the list, it would make Packer deal with those changes automatically when saved. I easily modified this to work with lazy.nvim but, it complains that sourcing the plugins file isn't supported in lazy.nvim when ran. I found a feature request of someone trying to do the same thing and it appears that the developer of lazy.nvim isn't interested in implementing it 🙁. Otherwise, a very positive experience. 9/10, would lazy.nvim again.

If you'd like to see the diff of my plugins.lua, you can find it here. Happy Neoviming!

Tagged with:

More posts: