lazy-like-loader.nvim
Lazy-like-loader is a plugin-loading plugin utilizing the builtin vim.pack
package manager, but incorporating a module-per-plugin loading paradigm like
lazy.nvim (see the way lazy does it
here).
Lazy-like-loader uses similar (not identical) idiomatic "plugin spec"
conventions to lazy's plugin spec, making it
convenient for those moving from lazy to vim.pack or other plugin management
solutions (e.g. adding plugins via a separate package manager like Nix).
The loader can also be used to hierarchical loading via the dependents and
dependencies options in the plugin spec, and arbitrary functions can be setup
to run after loading via loadFn.
The entire loader is hyper-minimal at only ~70 lines of lua.
Usage
Install the plugin using vim.pack (or another package manager if you'd like),
then initialize it like so:
require("lazy-like-loader").setup {
package = "tjk.plugins",
}
The package option is required. It will point to the package containing all
your plugin modules. In this case: ~/.config/nvim/lua/tjk/plugins (or
wherever your nvim home is).
Plugin modules can then be defined using the plugin spec, for example:
-- autoclose.lua
return {
"autoclose",
"https://github.com/m4xshen/autoclose.nvim",
setup = {
options = { pair_spaces = true },
},
}
If the plugin cannot be loaded, then source will be passed to vim.pack.add
by default which will prompt the user to optionally install the plugin.
This behavior can be disabled by setting packAddMissing = false in setup.
More examples can be found as part of my neovim config here
Plugin spec
| Property | Type | Description |
|---|---|---|
| [1] or moduleName | string |
plugin name loaded via require(moduleName) |
| [2] or source | string? |
plugin source, added via vim.pack.add { source } |
| dependencies | plugin[]? |
table of plugins loaded before the initial plugin. same spec is used recursively |
| dependents | plugin[]? |
table of plugins loaded after the initial plugin. same spec is used recursively |
| enabled | boolean? |
whether to attempt to initialize the plugin the loader |
| loadFn | fun()? |
runs after plugin and dependencies are successfully loaded, but before dependents |
| setup | table or boolean? |
table passed to setup function. if unset or false then setup will not be ran. if true then opts is set to {}. otherwise opts is set to the value of setup |
