mini.nvim and loading setups on different events for the same package #92
Replies: 1 comment 2 replies
{
"mini.nvim",
event = "VimEnter",
after = function()
local starter = require("mini.starter")
...
end,
},
{
"mini.nvim2", -- literally anything other than "mini.nvim"
event = "BufReadPost",
load = function(name)
vim.cmd.packadd("mini.nvim") -- fix the load function so that it doesnt try to packadd(name)
end,
after = function()
require("mini.move").setup()
require("mini.surround").setup()
require("mini.cursorword").setup()
end,
},The name is basically the only thing the core logic of lze actually needs to know about, and is what is used to store the spec in state. So the names have to be different. The default load function is just vim.cmd.packadd, and it is given the name. So, if the name does not correspond to the actual plugin folder name anymore, the load function used for that spec also needs to change. Most other fields are dealt with by handlers, which store the value and call require('lze').trigger_load("specname") when told to, which will load the contents of the spec. They will continue working whatever the name is, as long as it is a unique name (which is why it refuses duplicate names) But yes, totally possible, and we don't shame premature optimization around here, this is a lazy loading plugin, that is what it is for 😄 (although there are times when it is unnecessary. This one makes some sense though) |
Uh oh!
There was an error while loading. Please reload this page.
What should I do in a situation like with mini.nvim packaging multiple plugins in a single plugin? Might be a non-issue but in this case I want my dashboard (mini.starter) to run its setup first, and then the buffer editing specific plugins when I'll need them:
{ "mini.nvim", event = "VimEnter", after = function() local starter = require("mini.starter") ... end, }, { "mini.nvim", event = "BufReadPost", after = function() require("mini.move").setup() require("mini.surround").setup() require("mini.cursorword").setup() end, },And I get "attempted to add mini.nvim twice"
All reactions