mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 03:08:13 +00:00
feat(picker.help): add more color to help tags
This commit is contained in:
parent
caf20764f1
commit
5778234e39
2 changed files with 17 additions and 5 deletions
|
@ -281,7 +281,7 @@ function M.text(item, picker)
|
|||
if ft then
|
||||
Snacks.picker.highlight.format(item, item.text, ret, { lang = ft })
|
||||
else
|
||||
ret[#ret + 1] = { item.text }
|
||||
ret[#ret + 1] = { item.text, item.text_hl }
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
|
|
@ -42,15 +42,27 @@ function M.help(opts)
|
|||
for _, file in ipairs(tag_files[lang] or {}) do
|
||||
for line in io.lines(file) do
|
||||
local fields = vim.split(line, string.char(9), { plain = true })
|
||||
if not line:match("^!_TAG_") and #fields == 3 and not done[fields[1]] then
|
||||
done[fields[1]] = true
|
||||
local tag = fields[1]
|
||||
if not line:match("^!_TAG_") and #fields == 3 and not done[tag] then
|
||||
done[tag] = true
|
||||
---@type snacks.picker.finder.Item
|
||||
local item = {
|
||||
text = fields[1],
|
||||
tag = fields[1],
|
||||
text = tag,
|
||||
tag = tag,
|
||||
file = help_files[fields[2]],
|
||||
search = "/\\V" .. fields[3]:sub(2),
|
||||
}
|
||||
if tag:find("^[vbg]?:") or tag:find("^/") then
|
||||
item.ft = "vim"
|
||||
elseif tag:find("%(%)$") then
|
||||
item.ft = "lua"
|
||||
elseif tag:find("^'.*'$") then
|
||||
item.text_hl = "String"
|
||||
elseif tag:find("^E%d+$") then
|
||||
item.text_hl = "Error"
|
||||
elseif tag:find("^hl%-") then
|
||||
item.text_hl = tag:sub(4)
|
||||
end
|
||||
if item.file then
|
||||
cb(item)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue