Repository navigation
Contributing guidelines
Module(s)mini.test QuestionI've installed mini.test on its own, and due to the plugin not having a plugin/mini.test/test.lua (or similar) directory, it does not trigger a SourcePost event. Any idea how I would fix this? |
Replies: 3 comments 9 replies
|
That's expected, and there's nothing to fix in mini.test. Quick check with a Lua-only plugin next to one that has a
vim.cmd.packadd("mini.test")
require("mini.test").setup()If you install it with vim.pack.add({ "https://github.com/nvim-mini/mini.test" }, {
load = function(p)
vim.cmd.packadd(p.spec.name)
require("mini.test").setup()
end,
})See |
|
I'm not sure if the second part of your reply is useful for my problem, but I'll elaborate on what I mean and why I need it. Apologies if I misunderstood. An example of what I'm talking about is executing a setup on -- Plugin foo is 'on-demand' and won't be loaded until :packadd
vim.pack.add({"repo/for/foo.nvim"}, {
load = function() end
})
-- Load setups on :packadd
vim.api.nvim_create_autocmd("SourcePost", {
group = config_augroup,
callback = function(ev)
local pluginname = vim.fs.basename(ev.file)
if pluginname == 'foo.lua' and not package.loaded['foo'] then
require("foo").setup()
end
end
})Is my above example similar to what you were referring to? I hope I explained it well enough. This method works for plugins who have |
The answer to this particular question is "The fix depends on what you try to achieve. This behavior is expected, precisely because of what you described". There is no need in 'plugin/mini-test.lua' in standalone repo, since they are all designed to be merely a copy of 'mini.nvim' parts with all their suggested workflows.
Depends on what you mean by "to be loaded". Usually the problem here is wanting to delay sourcing My personal preference and recommendation is to not do If you want to completely avoid increasing 'runtimepath' completely, then doing two steps ( Finally, the solution for 'mini.test' specific case:
Hope this helps. |
Got it, you want it on demand, not loaded at startup. Then there's no event to hook, unfortunately.
:packadd mini.testonly adds the directory toruntimepath, and since the plugin has noplugin/file nothing is sourced, soSourcePostnever fires for it. I also checkedSourcePreandOptionSetonruntimepath: neither fires on:packaddeither.What works is doing the
:packaddyourself through a small command, so you still decide when it loads and the setup runs right after: