mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
feat(picker): allow overriding default file/dir/dir_open icons. Closes #1199
This commit is contained in:
parent
66ad6f1d09
commit
41c4391b72
4 changed files with 19 additions and 8 deletions
|
@ -313,6 +313,9 @@ local defaults = {
|
|||
icons = {
|
||||
files = {
|
||||
enabled = true, -- show file icons
|
||||
dir = " ",
|
||||
dir_open = " ",
|
||||
file = " "
|
||||
},
|
||||
keymaps = {
|
||||
nowait = " "
|
||||
|
|
|
@ -57,9 +57,11 @@ function M.filename(item, picker)
|
|||
end
|
||||
|
||||
if picker.opts.icons.files.enabled ~= false then
|
||||
local icon, hl = Snacks.util.icon(name, cat)
|
||||
local icon, hl = Snacks.util.icon(name, cat, {
|
||||
fallback = picker.opts.icons.files,
|
||||
})
|
||||
if item.dir and item.open then
|
||||
icon = " "
|
||||
icon = picker.opts.icons.files.dir_open
|
||||
end
|
||||
icon = Snacks.picker.util.align(icon, picker.opts.formatters.file.icon_width or 2)
|
||||
ret[#ret + 1] = { icon, hl, virtual = true }
|
||||
|
|
|
@ -23,10 +23,13 @@ function M.directory(ctx)
|
|||
return a.file < b.file
|
||||
end)
|
||||
for i, item in ipairs(ls) do
|
||||
local cat = item.type == "directory" and "directory" or "file"
|
||||
local hl = item.type == "directory" and "Directory" or nil
|
||||
local is_dir = item.type == "directory"
|
||||
local cat = is_dir and "directory" or "file"
|
||||
local hl = is_dir and "Directory" or nil
|
||||
local path = item.file
|
||||
local icon, icon_hl = Snacks.util.icon(path, cat)
|
||||
local icon, icon_hl = Snacks.util.icon(path, cat, {
|
||||
fallback = ctx.picker.opts.icons.files,
|
||||
})
|
||||
local line = { { icon .. " ", icon_hl }, { path, hl } }
|
||||
vim.api.nvim_buf_set_extmark(ctx.buf, ns, i - 1, 0, {
|
||||
virt_text = line,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue