mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-06-28 19:34:15 +00:00
feat: allow specifying module to require for plugin configs
This commit is contained in:
parent
dac844ed61
commit
184a778f8f
3 changed files with 6 additions and 2 deletions
|
@ -92,7 +92,7 @@ require("lazy").setup({
|
||||||
| **dependencies** | `LazySpec[]` | A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. |
|
| **dependencies** | `LazySpec[]` | A list of plugin names or plugin specs that should be loaded when the plugin loads. Dependencies are always lazy-loaded unless specified otherwise. When specifying a name, make sure the plugin spec has been defined somewhere else. |
|
||||||
| **init** | `fun(LazyPlugin)` | `init` functions are always executed during startup |
|
| **init** | `fun(LazyPlugin)` | `init` functions are always executed during startup |
|
||||||
| **opts** | `table` or `fun(LazyPlugin, opts:table)` | `opts` should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the `Plugin.config()` function. Setting this value will imply `Plugin.config()` |
|
| **opts** | `table` or `fun(LazyPlugin, opts:table)` | `opts` should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the `Plugin.config()` function. Setting this value will imply `Plugin.config()` |
|
||||||
| **config** | `fun(LazyPlugin, opts:table)` or `true` | `config` is executed when the plugin loads. The default implementation will automatically run `require(MAIN).setup(opts)`. Lazy uses several heuristics to determine the plugin's `MAIN` module automatically based on the plugin's **name**. See also `opts`. To use the default implementation without `opts` set `config` to `true`. |
|
| **config** | `fun(LazyPlugin, opts:table)` or `string` or `true` | `config` is executed when the plugin loads. The default implementation will automatically run `require(MAIN).setup(opts)`. Lazy uses several heuristics to determine the plugin's `MAIN` module automatically based on the plugin's **name**. See also `opts`. To use the default implementation without `opts` set `config` to `true`. To require a Lua module, set `config` to the module's path. |
|
||||||
| **main** | `string?` | You can specify the `main` module to use for `config()` and `opts()`, in case it can not be determined automatically. See `config()` |
|
| **main** | `string?` | You can specify the `main` module to use for `config()` and `opts()`, in case it can not be determined automatically. See `config()` |
|
||||||
| **build** | `fun(LazyPlugin)` or `string` or a list of build commands | `build` is executed when a plugin is installed or updated. Before running `build`, a plugin is first loaded. If it's a string it will be ran as a shell command. When prefixed with `:` it is a Neovim command. You can also specify a list to executed multiple build commands. Some plugins provide their own `build.lua` which is automatically used by lazy. So no need to specify a build step for those plugins. |
|
| **build** | `fun(LazyPlugin)` or `string` or a list of build commands | `build` is executed when a plugin is installed or updated. Before running `build`, a plugin is first loaded. If it's a string it will be ran as a shell command. When prefixed with `:` it is a Neovim command. You can also specify a list to executed multiple build commands. Some plugins provide their own `build.lua` which is automatically used by lazy. So no need to specify a build step for those plugins. |
|
||||||
| **branch** | `string?` | Branch of the repository |
|
| **branch** | `string?` | Branch of the repository |
|
||||||
|
|
|
@ -347,6 +347,10 @@ function M.config(plugin)
|
||||||
local opts = Plugin.values(plugin, "opts", false)
|
local opts = Plugin.values(plugin, "opts", false)
|
||||||
plugin.config(plugin, opts)
|
plugin.config(plugin, opts)
|
||||||
end
|
end
|
||||||
|
elseif type(plugin.config) == "string" then
|
||||||
|
fn = function()
|
||||||
|
require(plugin.config)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
local main = M.get_main(plugin)
|
local main = M.get_main(plugin)
|
||||||
if main then
|
if main then
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
---@class LazyPluginHooks
|
---@class LazyPluginHooks
|
||||||
---@field init? fun(self:LazyPlugin) Will always be run
|
---@field init? fun(self:LazyPlugin) Will always be run
|
||||||
---@field deactivate? fun(self:LazyPlugin) Unload/Stop a plugin
|
---@field deactivate? fun(self:LazyPlugin) Unload/Stop a plugin
|
||||||
---@field config? fun(self:LazyPlugin, opts:table)|true Will be executed when loading the plugin
|
---@field config? fun(self:LazyPlugin, opts:table)|string|true Will be executed when loading the plugin
|
||||||
---@field build? string|fun(self:LazyPlugin)|(string|fun(self:LazyPlugin))[]
|
---@field build? string|fun(self:LazyPlugin)|(string|fun(self:LazyPlugin))[]
|
||||||
---@field opts? PluginOpts
|
---@field opts? PluginOpts
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue