From ed49bbeb3d4f1f4a9ec47fee594c748035287241 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Thu, 22 Aug 2024 00:18:43 +0200 Subject: [PATCH] docs(luacats): allow table of plugins in load --- lua/lz/n/handler/cmd.lua | 2 +- lua/lz/n/handler/colorscheme.lua | 4 ++-- lua/lz/n/init.lua | 2 +- lua/lz/n/loader.lua | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lua/lz/n/handler/cmd.lua b/lua/lz/n/handler/cmd.lua index 038c7c6..f4de88c 100644 --- a/lua/lz/n/handler/cmd.lua +++ b/lua/lz/n/handler/cmd.lua @@ -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 diff --git a/lua/lz/n/handler/colorscheme.lua b/lua/lz/n/handler/colorscheme.lua index 182295a..8aa2c08 100644 --- a/lua/lz/n/handler/colorscheme.lua +++ b/lua/lz/n/handler/colorscheme.lua @@ -3,11 +3,11 @@ local loader = require("lz.n.loader") ---@class lz.n.ColorschemeHandler: lz.n.Handler ---@field augroup? integer +---@type table> local pending = {} ---@type lz.n.ColorschemeHandler local M = { - ---@type table> augroup = nil, spec_field = "colorscheme", } @@ -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() diff --git a/lua/lz/n/init.lua b/lua/lz/n/init.lua index 8e5afd9..e0111b7 100644 --- a/lua/lz/n/init.lua +++ b/lua/lz/n/init.lua @@ -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 M.trigger_load = function(plugins) require("lz.n.loader").load(plugins, M.lookup) end diff --git a/lua/lz/n/loader.lua b/lua/lz/n/loader.lua index fcb41eb..b16fe97 100644 --- a/lua/lz/n/loader.lua +++ b/lua/lz/n/loader.lua @@ -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 ---@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 for _, plugin in pairs(plugins) do -- NOTE: do not make this loop into vim.iter -- https://github.com/nvim-neorocks/lz.n/pull/21