mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
feat(picker.format): filename_only
option
This commit is contained in:
parent
b86d90e3e9
commit
0396bdfc3e
2 changed files with 6 additions and 1 deletions
|
@ -74,7 +74,7 @@ local M = {}
|
|||
---@field format? string|snacks.picker.format|string format function or preset
|
||||
---@field finder? string|snacks.picker.finder|snacks.picker.finder.multi finder function or preset
|
||||
---@field preview? snacks.picker.preview|string preview function or preset
|
||||
---@field matcher? snacks.picker.matcher.Config matcher config
|
||||
---@field matcher? snacks.picker.matcher.Config|{} matcher config
|
||||
---@field sort? snacks.picker.sort|snacks.picker.sort.Config sort function or config
|
||||
---@field transform? string|snacks.picker.transform transform/filter function
|
||||
--- UI
|
||||
|
@ -134,6 +134,7 @@ local defaults = {
|
|||
file = {
|
||||
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
|
||||
},
|
||||
selected = {
|
||||
show_always = false, -- only show the selected column when there are multiple selections
|
||||
|
|
|
@ -42,6 +42,10 @@ function M.filename(item, picker)
|
|||
end
|
||||
|
||||
local dir, file = path:match("^(.*)/(.+)$")
|
||||
if picker.opts.formatters.file.filename_only then
|
||||
dir = nil
|
||||
path = vim.fn.fnamemodify(path, ":t")
|
||||
end
|
||||
if file and dir then
|
||||
if picker.opts.formatters.file.filename_first then
|
||||
ret[#ret + 1] = { file, "SnacksPickerFile", field = "file" }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue