diff --git a/lua/lazy/docs.lua b/lua/lazy/docs.lua index 08a4b71..d274a57 100644 --- a/lua/lazy/docs.lua +++ b/lua/lazy/docs.lua @@ -36,7 +36,7 @@ function M.save(contents) if not readme:find(pattern) then error("tag " .. tag .. " not found") end - if tag == "commands" or tag == "colors" then + if tag == "commands" or tag == "colors" or tag == "plugins" then readme = readme:gsub(pattern, "%1\n\n" .. content .. "\n\n%2") else readme = readme:gsub(pattern, "%1\n\n```lua\n" .. content .. "\n```\n\n%2") @@ -135,6 +135,15 @@ function M.update() vim.cmd.checktime() end -M.update() +function M.plugins() + local Config = require("lazy.core.config") + local lines = { "## Plugins", "" } + Util.foreach(Config.plugins, function(name, plugin) + if plugin.url then + lines[#lines + 1] = "- [" .. name .. "](" .. plugin.url:gsub("%.git$", "") .. ")" + end + end) + M.save({ plugins = table.concat(lines, "\n") }) +end return M diff --git a/lua/lazy/util.lua b/lua/lazy/util.lua index 938ede4..d24794f 100644 --- a/lua/lazy/util.lua +++ b/lua/lazy/util.lua @@ -209,7 +209,9 @@ end function M.foreach(t, fn) ---@type string[] local keys = vim.tbl_keys(t) - pcall(table.sort, keys) + pcall(table.sort, keys, function(a, b) + return a:lower() < b:lower() + end) for _, key in ipairs(keys) do fn(key, t[key]) end