Skip to content

Commit 2fd78fb

Browse files
committed
fix(help): sort tags files for readmes so tags work properly. Fixes #67
1 parent eab449b commit 2fd78fb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lua/lazy/help.lua

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function M.index(plugin)
77
if Config.options.readme.skip_if_doc_exists and vim.loop.fs_stat(plugin.dir .. "/doc") then
88
return {}
99
end
10-
---@type {file:string, tag:string, line:string}[]
10+
---@type table<string,{file:string, tag:string, line:string}>
1111
local tags = {}
1212
for _, file in ipairs(Config.options.readme.files) do
1313
file = plugin.dir .. "/" .. file
@@ -18,7 +18,7 @@ function M.index(plugin)
1818
if title then
1919
local tag = plugin.name .. "-" .. title:lower():gsub("%W+", "-")
2020
tag = tag:gsub("%-+", "-"):gsub("%-$", "")
21-
table.insert(tags, { tag = tag, line = line, file = plugin.name .. ".md" })
21+
tags[tag] = { tag = tag, line = line, file = plugin.name .. ".md" }
2222
end
2323
end
2424
table.insert(lines, [[<!-- vim: set ft=markdown: -->]])
@@ -40,12 +40,14 @@ function M.update()
4040
---@type {file:string, tag:string, line:string}[]
4141
local tags = {}
4242
for _, plugin in pairs(Config.plugins) do
43-
vim.list_extend(tags, M.index(plugin))
43+
for key, tag in pairs(M.index(plugin)) do
44+
tags[key] = tag
45+
end
4446
end
4547
local lines = { [[!_TAG_FILE_ENCODING utf-8 //]] }
46-
for _, tag in ipairs(tags) do
48+
Util.foreach(tags, function(_, tag)
4749
table.insert(lines, ("%s\t%s\t/%s"):format(tag.tag, tag.file, tag.line))
48-
end
50+
end)
4951
Util.write_file(docs .. "/tags", table.concat(lines, "\n"))
5052
end
5153

0 commit comments

Comments
 (0)