You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Probably my issues come down to my limited understanding of packer. Help would be very appreciated.
config / setup keys
So in my current config, I wanted to try a structure that bundles the configuration of a plugin with its packer spec.
What I came up with was this: (simplified)
-- cmp.luaconfigs['nvim-cmp'] =function()
-- require'cmp'.setup etcend-- there are other cmp related plugins in here with their respective configs and packer specs-- p just trims the https://github.com/ of the string. Otherwise packer would try to reinstall the plugin every time, probably because it -- would compare the internal representation `hrsh7th/nvim-cmp` directly with the string of the github link and then conclude the -- internal spec isn't in the packer spec any longer, so uninstall, and the github link is new and not yet in the db, so fresh install.-- this is possibly a buglocalM=function(use)
use {
p'https://github.com/hrsh7th/nvim-cmp',
config=configs['nvim-cmp'],
-- ...
}
-- ...endreturnM
As you can see I pass down the use function to my config scripts and pass the result back up.
This works fine. However the part where I pass the function to the config key is problematic.
It appears this gets reexecuted every time I recompile (PackerCompile/Sync). Since I work with vim sessions, these reexecutions pile up over the lifetime of a session and eventually I end up with a bunch of duplicate cmp sources, like 3 times the buffer source, and my completion menu is flooded.
So it seems to me the config and setup key were not built for this purpose. What were they built for?
I saw a few dotfiles putting every config code in a separate file specific for the plugin and not utilize the use function for the config and setup keys. Eg. tjdevries. However I would like to pack the configuration and the packer spec together and also be capable of executing some before and some after the plugin is loaded (for lazy loading). Currently it seems to me, the only way to do this, is to create a bunch of autocmds.
lazy loading
I've struggled to model slightly complex relationships for lazyloading with packer. Example:
-- lsp.lualocalM=function(use)
use {
p'https://github.com/neovim/nvim-lspconfig',
requires= {
{ 'hrsh7th/cmp-nvim-lsp' },
{ p'https://github.com/williamboman/nvim-lsp-installer' },
{
p'https://gitlab.com/yorickpeterse/nvim-dd',
-- config = function() require('dd').setup { timeout = 1000, } end
},
{
p'https://github.com/j-hui/fidget.nvim',
config=function() require('fidget').setup {} end
},
{ p'https://github.com/b0o/SchemaStore.nvim' },
},
config=configs['nvim-lspconfig'],
-- g.lsp.fts contains a table (list) of filetypes, on which to load lsp stuffft=g.lsp.fts,
}
end
My expectation would have been that packer automatically lazy loads the plugins, specified in requires, upon checking PackerStatus this turns out be wrong, though. They are loaded immediately, only lspconfig is loaded lazily. (or PackerStatus is not working correctly).
To model this lazy loading chain, I'd have to use the plugins separately and give them all the ft key and list them all in after of lspconfig plugin. I tried this. And even then I got errors, because the loading order was not correct.
Misc
Also I gotta say the documentation in the readme is lacking when it comes to more in-depth use of some keys, eg. that you can specify event = 'autocmd pattern'. I only know this, because I saw it in other dotfiles.
In the packer github wiki a snippet uses the wants key. Is that key deprecated or not documented?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Probably my issues come down to my limited understanding of packer. Help would be very appreciated.
config / setup keys
So in my current config, I wanted to try a structure that bundles the configuration of a plugin with its packer spec.
What I came up with was this: (simplified)
As you can see I pass down the
use
function to my config scripts and pass the result back up.This works fine. However the part where I pass the function to the
config
key is problematic.It appears this gets reexecuted every time I recompile (
PackerCompile/Sync
). Since I work with vim sessions, these reexecutions pile up over the lifetime of a session and eventually I end up with a bunch of duplicate cmp sources, like 3 times the buffer source, and my completion menu is flooded.So it seems to me the
config
andsetup
key were not built for this purpose. What were they built for?I saw a few dotfiles putting every config code in a separate file specific for the plugin and not utilize the
use
function for theconfig
andsetup
keys. Eg. tjdevries. However I would like to pack the configuration and the packer spec together and also be capable of executing some before and some after the plugin is loaded (for lazy loading). Currently it seems to me, the only way to do this, is to create a bunch ofautocmds
.lazy loading
I've struggled to model slightly complex relationships for lazyloading with packer. Example:
My expectation would have been that packer automatically lazy loads the plugins, specified in
requires
, upon checkingPackerStatus
this turns out be wrong, though. They are loaded immediately, only lspconfig is loaded lazily. (orPackerStatus
is not working correctly).To model this lazy loading chain, I'd have to
use
the plugins separately and give them all theft
key and list them all inafter
of lspconfig plugin. I tried this. And even then I got errors, because the loading order was not correct.Misc
Also I gotta say the documentation in the readme is lacking when it comes to more in-depth use of some keys, eg. that you can specify
event = 'autocmd pattern'
. I only know this, because I saw it in other dotfiles.In the packer github wiki a snippet uses the
wants
key. Is that key deprecated or not documented?Beta Was this translation helpful? Give feedback.
All reactions