I can see in vim how we can:
But I want to:
- Call function only when the plugin is
required
I can see in vim how we can:
But I want to:
required
This is pretty much standard sequence of steps.
opt
subtreepackadd
when requiredpackadd
executed for the first time.Initialization works the same way as with regular plugins
- with regular plugins I will have some code in my ./plugin
folder (not my ./pack/start/*
folder(s)... this ./plugin
code will run unequivocally on startup. However, if I only wanted to run that code when I packadd matchit
or something like that... then how do I do THAT. What is the mechanism of step 3? A plugin will have it's own ``./pack/opt/bundle/some_plugin/plugin/init.lua` folder to initialize itself. But I want to do additional work in my ./plugin/additional_config_for_some_plugin.lua
file
Commented
Jul 26, 2023 at 20:44
/start
but still needs too many setup function call(s) then you have to admit it's a dumb piece of code and you'd better to drop it.
k-takata/minpac
, for example.
functions that require the plugin code
instead of opt
to delay loading a plugin. My use case is that I'm using copilot.nvim
and I don't wanna load it until I manually load it. I'm sure I can trivially figure out what specific config delays loading of the plugin and also write a small command that lets me load it later. It's just stupid that I can't use the perfectly fine packadd
command to do this. Maybe I'll just make a command that runs setup and THEN calls packadd
. Exactly as u said
Commented
Jul 27, 2023 at 21:45
I'm starting to set up my environment now and 10 months after your question I'm having the same problem.
The packadd
documentation says that the directory should follow the structure pack/*/opt/{name}/plugin/**/*.{vim,lua}
Well, the runtime sorts the directories by putting last the ones that start with after
(in a nutshell, that's it), so what I did was add my scripts in after/pack/*/opt/{name}/plugin/**/*.{vim,lua}
. With this, when I run the packadd {name}
command, my settings are executed after the original settings of the script I loaded.
Well, it may not be so flexible and maybe difficult to manage, but it was as close as I could get.
packadd
) is loaded. But I cannot find the Autocmd to run after apackadd
. Maybe there is an autocmd after arequire
was my next thought.require
is Lua semantics. You'd have to change its behavior somehow.