Skip to content

Commit

Permalink
fix(trigger_load): preserve order of non-lists
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Aug 28, 2024
1 parent dac14fb commit 74f5954
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lua/lz/n/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,15 @@ end
---@overload fun(plugins: lz.n.Plugin | string[] | lz.n.Plugin[] | table<unknown, lz.n.Plugin>)
---@overload fun(plugins: string | string[], lookup: fun(name: string): lz.n.Plugin?): string[]
function M.load(plugins, lookup)
local iterator = vim.islist(plugins) and ipairs or pairs
plugins = (type(plugins) == "string" or plugins.name) and { plugins } or plugins
---@cast plugins (string|lz.n.Plugin)[] | table<unknown, lz.n.Plugin>
if not vim.islist(plugins) then
-- This ensures we can use ipairs to preserve ordering of lists
plugins = vim.tbl_values(plugins)
end
---@cast plugins (string|lz.n.Plugin)[]
---@type string[]
local skipped = {}
for _, plugin in iterator(plugins) do
for _, plugin in ipairs(plugins) do
local loadable = true
-- NOTE: do not make this loop into vim.iter
-- https://github.com/nvim-neorocks/lz.n/pull/21
Expand Down

0 comments on commit 74f5954

Please sign in to comment.