Skip to content

Commit

Permalink
fix(help): sort tags files for readmes so tags work properly. Fixes #67
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 21, 2022
1 parent eab449b commit 2fd78fb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lua/lazy/help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function M.index(plugin)
if Config.options.readme.skip_if_doc_exists and vim.loop.fs_stat(plugin.dir .. "/doc") then
return {}
end
---@type {file:string, tag:string, line:string}[]
---@type table<string,{file:string, tag:string, line:string}>
local tags = {}
for _, file in ipairs(Config.options.readme.files) do
file = plugin.dir .. "/" .. file
Expand All @@ -18,7 +18,7 @@ function M.index(plugin)
if title then
local tag = plugin.name .. "-" .. title:lower():gsub("%W+", "-")
tag = tag:gsub("%-+", "-"):gsub("%-$", "")
table.insert(tags, { tag = tag, line = line, file = plugin.name .. ".md" })
tags[tag] = { tag = tag, line = line, file = plugin.name .. ".md" }
end
end
table.insert(lines, [[<!-- vim: set ft=markdown: -->]])
Expand All @@ -40,12 +40,14 @@ function M.update()
---@type {file:string, tag:string, line:string}[]
local tags = {}
for _, plugin in pairs(Config.plugins) do
vim.list_extend(tags, M.index(plugin))
for key, tag in pairs(M.index(plugin)) do
tags[key] = tag
end
end
local lines = { [[!_TAG_FILE_ENCODING utf-8 //]] }
for _, tag in ipairs(tags) do
Util.foreach(tags, function(_, tag)
table.insert(lines, ("%s\t%s\t/%s"):format(tag.tag, tag.file, tag.line))
end
end)
Util.write_file(docs .. "/tags", table.concat(lines, "\n"))
end

Expand Down

0 comments on commit 2fd78fb

Please sign in to comment.