fix(health): skip dot dirs... Closes #1293

This commit is contained in:
Folke Lemaitre 2025-02-19 00:15:10 +01:00
parent e2258236a2
commit aaed4a9411
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -34,30 +34,32 @@ end
function M.get()
local ret = {} ---@type snacks.meta.Plugin[]
for file, t in vim.fs.dir(M.root, { depth = 1 }) do
local name = vim.fn.fnamemodify(file, ":t:r")
file = t == "directory" and ("%s/init.lua"):format(file) or file
file = M.root .. "/" .. file
local mod = name == "init" and setmetatable({ meta = { desc = "Snacks", hide = true } }, { __index = Snacks })
or Snacks[name] --[[@as snacks.meta.Plugin]]
assert(type(mod) == "table", ("`Snacks.%s` not found"):format(name))
assert(type(mod.meta) == "table", ("`Snacks.%s.meta` not found"):format(name))
assert(type(mod.meta.desc) == "string", ("`Snacks.%s.meta.desc` not found"):format(name))
if file:sub(1, 1) ~= "." then
local name = vim.fn.fnamemodify(file, ":t:r")
file = t == "directory" and ("%s/init.lua"):format(file) or file
file = M.root .. "/" .. file
local mod = name == "init" and setmetatable({ meta = { desc = "Snacks", hide = true } }, { __index = Snacks })
or Snacks[name] --[[@as snacks.meta.Plugin]]
assert(type(mod) == "table", ("`Snacks.%s` not found"):format(name))
assert(type(mod.meta) == "table", ("`Snacks.%s.meta` not found"):format(name))
assert(type(mod.meta.desc) == "string", ("`Snacks.%s.meta.desc` not found"):format(name))
for _, prop in ipairs({ "readme", "docs", "health", "types" }) do
if mod.meta[prop] == nil then
mod.meta[prop] = not mod.meta.hide
for _, prop in ipairs({ "readme", "docs", "health", "types" }) do
if mod.meta[prop] == nil then
mod.meta[prop] = not mod.meta.hide
end
end
end
ret[#ret + 1] = setmetatable({
name = name,
file = file,
}, {
__index = mod,
__tostring = function(self)
return "snacks." .. self.name
end,
})
ret[#ret + 1] = setmetatable({
name = name,
file = file,
}, {
__index = mod,
__tostring = function(self)
return "snacks." .. self.name
end,
})
end
end
table.sort(ret, function(a, b)
return a.name < b.name