From 3974a6cbe38f7958c2e4f41c6f0d9a6c001a723d Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 1 Jan 2023 20:31:27 +0100 Subject: [PATCH] refactor(help): replace non-word characters by - for readme filenames --- lua/lazy/help.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/lazy/help.lua b/lua/lazy/help.lua index f9e6637..2239b9a 100644 --- a/lua/lazy/help.lua +++ b/lua/lazy/help.lua @@ -7,16 +7,19 @@ function M.index(plugin) if Config.options.readme.skip_if_doc_exists and vim.loop.fs_stat(plugin.dir .. "/doc") then return {} end + + ---@param file string local files = vim.tbl_flatten(vim.tbl_map(function(file) return vim.fn.expand(plugin.dir .. "/" .. file, false, true) end, Config.options.readme.files)) + ---@type table local tags = {} for _, file in ipairs(files) do file = Util.norm(file) if vim.loop.fs_stat(file) then local rel_file = file:sub(#plugin.dir + 1) - local tag_filename = string.gsub(plugin.name .. vim.fn.fnamemodify(rel_file, ":h:gs?/?-?"), "-$", "") + local tag_filename = plugin.name .. vim.fn.fnamemodify(rel_file, ":h"):gsub("%W+", "-"):gsub("^%-$", "") local lines = vim.split(Util.read_file(file), "\n") for _, line in ipairs(lines) do local title = line:match("^#+%s*(.*)")