Skip to content

Commit

Permalink
docs(luacats): allow table of plugins in load
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Aug 21, 2024
1 parent 7f1527c commit ed49bbe
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lua/lz/n/handler/cmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ end
---@param cmd string
local function load(cmd)
vim.api.nvim_del_user_command(cmd)
loader.load(vim.tbl_values(pending[cmd]))
loader.load(pending[cmd])
end

---@param cmd string
Expand Down
4 changes: 2 additions & 2 deletions lua/lz/n/handler/colorscheme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ local loader = require("lz.n.loader")
---@class lz.n.ColorschemeHandler: lz.n.Handler
---@field augroup? integer

---@type table<string, table<string, lz.n.Plugin[]>>
local pending = {}

---@type lz.n.ColorschemeHandler
local M = {
---@type table<string, table<string, lz.n.Plugin[]>>
augroup = nil,
spec_field = "colorscheme",
}
Expand All @@ -32,7 +32,7 @@ local function on_colorscheme(name)
-- already loaded
return
end
loader.load(vim.tbl_values(plugins))
loader.load(plugins)
end

local function init()
Expand Down
2 changes: 1 addition & 1 deletion lua/lz/n/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ end
--- (loading the first one it finds).
--- Once a plugin has been loaded, it will be removed from all handlers (via `del`).
--- As a result, calling `trigger_load` with a plugin name is idempotent.
---@param plugins string | lz.n.Plugin | string[] | lz.n.Plugin[]
---@param plugins string | lz.n.Plugin | string[] | lz.n.Plugin[] | table<unknown, lz.n.Plugin>
M.trigger_load = function(plugins)
require("lz.n.loader").load(plugins, M.lookup)
end
Expand Down
4 changes: 2 additions & 2 deletions lua/lz/n/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ local function hook(hook_key, plugin)
end
end

---@param plugins string | lz.n.Plugin | string[] | lz.n.Plugin[]
---@param plugins string | lz.n.Plugin | string[] | lz.n.Plugin[] | table<unknown, lz.n.Plugin>
---@param lookup? fun(name: string): lz.n.Plugin?
function M.load(plugins, lookup)
plugins = (type(plugins) == "string" or plugins.name) and { plugins } or plugins
---@cast plugins (string|lz.n.Plugin)[]
---@cast plugins (string|lz.n.Plugin)[] | table<unknown, lz.n.Plugin>
for _, plugin in pairs(plugins) do
-- NOTE: do not make this loop into vim.iter
-- https://github.com/nvim-neorocks/lz.n/pull/21
Expand Down

0 comments on commit ed49bbe

Please sign in to comment.