fix(loader): runtime files are now sourced alphabetically per directory

This commit is contained in:
Folke Lemaitre 2022-12-17 13:03:34 +01:00
parent eeb06a5a50
commit 5c0c381b56
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 12 additions and 5 deletions

View File

@ -166,17 +166,24 @@ end
---@param ... string ---@param ... string
function M.source_runtime(...) function M.source_runtime(...)
local dir = table.concat({ ... }, "/") local dir = table.concat({ ... }, "/")
---@type string[]
local files = {}
Util.walk(dir, function(path, name, t) Util.walk(dir, function(path, name, t)
local ext = name:sub(-3) local ext = name:sub(-3)
name = name:sub(1, -5) name = name:sub(1, -5)
if t == "file" and (ext == "lua" or ext == "vim") and not M.disabled_rtp_plugins[name] then if t == "file" and (ext == "lua" or ext == "vim") and not M.disabled_rtp_plugins[name] then
files[#files + 1] = path
end
end)
-- plugin files are sourced alphabetically per directory
table.sort(files)
for _, path in ipairs(files) do
Util.track({ runtime = path }) Util.track({ runtime = path })
Util.try(function() Util.try(function()
vim.cmd("silent source " .. path) vim.cmd("silent source " .. path)
end, "Failed to source `" .. path .. "`") end, "Failed to source `" .. path .. "`")
Util.track() Util.track()
end end
end)
end end
-- This loader is added as the very last one. -- This loader is added as the very last one.