Help understanding optional plugins? #378
-
|
I'm quite new to nix so I'm slowly picking through how and why some of this works, but following the example has gotten me a bit confused. I can understand how you'd want to use the optional categories for plugins that only apply to specific filetypes (markdown for example), but the example has the It looks to me like they always get loaded via local load_w_after = function(name)
vim.cmd.packadd(name)
vim.cmd.packadd(name .. '/after')
end
return {
{
"cmp-cmdline",
for_cat = "general.blink",
on_plugin = { "blink.cmp" },
load = load_w_after,
},
...How is this different than just using a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
It simply means that they are added to the rtp under Plugins in Plugins in If you call If you call
The default load function for each one is This lets you schedule the plugin and its related config to load at some later time from within your init.lua in an ergonomic fashion. So, in short, the reason some core things are in Also, there isnt really much need to lazy load completion, but I did just in case it ever is slow, as if it is slow, running it from init.lua could block first paint momentarily, and also to show how to do it. |
Beta Was this translation helpful? Give feedback.
optionalPluginscould also be calledlazyPluginsbut the nvim terminology they use in the manual is "optional"It simply means that they are added to the rtp under
pack/myNeovimPackages/opt/<name>rather thanpack/myNeovimPackages/start/<name>.Plugins in
startare loaded immediately on startup. If they have files in theirplugin/*directory they will be ran, ftplugin files will be taken care of, etc.Plugins in
optare not loaded immediately. You instead must callvim.cmd.packadd("<name>")to load themIf you call
vim.cmd.packaddduring your initialinit.lua's run, that plugin will be loaded just like it was instartIf you call
vim.cmd.packaddany time after that, it will load the thing…