feat(picker): allow configuring file icon width. Closes #981

This commit is contained in:
Folke Lemaitre 2025-02-07 09:03:18 +01:00
parent 4362b1cbe0
commit 52c1086ecd
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 3 additions and 2 deletions

View file

@ -143,6 +143,7 @@ local defaults = {
filename_first = false, -- display filename before the file path
truncate = 40, -- truncate the file path to (roughly) this length
filename_only = false, -- only show the filename
icon_width = 2, -- width of the icon (in characters)
},
selected = {
show_always = false, -- only show the selected column when there are multiple selections

View file

@ -61,8 +61,8 @@ function M.filename(item, picker)
if item.dir and item.open then
icon = ""
end
local padded_icon = icon:sub(-1) == " " and icon or icon .. " "
ret[#ret + 1] = { padded_icon, hl, virtual = true }
icon = Snacks.picker.util.align(icon, picker.opts.formatters.file.icon_width or 2)
ret[#ret + 1] = { icon, hl, virtual = true }
end
local base_hl = item.dir and "SnacksPickerDirectory" or "SnacksPickerFile"