[mini.pick] Is it possible to get the file name at the start? #1082
-
Hi, I was wondering if it is possible to get the file names first and have the directories come after for Pick files? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This should be possible by overriding As I think showing matched characters is really important and having file name first makes it at least very complex, I don't think this will be made built-in or showed here in full capability. Here is an example of how the backbone can look like: local show_filename_first = function(buf_id, item_arr, query)
local lines = {}
for i, item in ipairs(item_arr) do
local directory, basename = vim.fs.dirname(item), vim.fs.basename(item)
lines[i] = string.format('%s (%s)', basename, directory)
end
vim.api.nvim_buf_set_lines(buf_id, 0, -1, false, lines)
end
MiniPick.registry.files_2 = function() MiniPick.builtin.files({}, { source = { show = show_filename_first } }) end You can then use it with |
Beta Was this translation helpful? Give feedback.
This should be possible by overriding
source.show()
for picker you want this behavior (presumably,builtin.files
).However, I think it will be a tough challenge to do while preserving all features of
default_show()
. Primarily, adding icons and current/match/marked highlighting.As I think showing matched characters is really important and having file name first makes it at least very complex, I don't think this will be made built-in or showed here in full capability. Here is an example of how the backbone can look like: