packer.nvim
packer.nvim copied to clipboard
Suppress "config" until the plugin is installed
Describe the feature
If config is called while a plugin specified by packer is not yet installed, it usually results in a "module not found" error because the plugin is required inside. I understand that calling PackerInstall or PackerSync will resolve this. However, I often encounter this error when I start neovim for the first time with init.vim from my dotfiles repository in a brand new environment, or when I copy and paste some plugin configuration (often written as a template in the README, etc.) and it irritates me. Is it possible to prevent config functions from being called for plugins that are not yet installed?
It could be a callback that would be called once all the plugins are installed (just like how the config
callback is for individual plugins).
I think this error should only happen when you PackerCompile
without a PackerInstall
first
so you should just do that
I think this error should only happen when you PackerCompile without a PackerInstall first so you should just do that
Yeah, I could do that. Although what I'm looking to achieve is keeping the sequence that config files are required and not getting errors on a fresh install.
As a workaround, I make packer_bootstrap
from the README a global variable (rather than local
) and wrap my config parameters in this mess:
use {
'lewis6991/gitsigns.nvim',
requires = 'nvim-lua/plenary.nvim',
config = function() if not packer_bootstrap then
require('gitsigns').setup()
end end
}
This at least allows a fresh startup to complete installing everything, without attempting to run the configure hooks.