[mini.pick] Shorten file picker paths #1873
Replies: 1 comment 2 replies
-
Thanks for sharing! I personally find it really confusing and very hard to quickly identify files when parent directories are this short. Only recently I found it more or less bearable in shell prompt for current working directory, but only because it is something I manually adjust and it doesn't change that often. Here is a more compact version of showing short parent directories: local parent_dir_pattern = vim.fn.has('win32') == 1 and '([^\\/]+)([\\/])' or '([^/]+)(/)'
local shorten_dirname = function(name, path_sep)
local first = vim.fn.strcharpart(name, 0, 1)
first = first == '.' and vim.fn.strcharpart(name, 0, 2) or first
return first .. path_sep
end
local make_short_path = function(path) return path:gsub(parent_dir_pattern, shorten_dirname) end
local show_short_files = function(buf_id, items_to_show, query)
local short_items_to_show = vim.tbl_map(make_short_path, items_to_show)
MiniPick.default_show(buf_id, short_items_to_show, query)
end
MiniPick.registry.files = function() MiniPick.builtin.files({}, { source = { show = show_short_files } }) end Some important differences:
Although using
So to overcome both of these issues, full custom But the real solution to the problem of navigating too wide matches is the horizontal scroll. By default it is |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I started working on a huge codebase recently, and whenever I used the builtin files picker for mini.pick the entries would overflow the window. So I made a show function that shortens each file's path.
Code:
Maybe would be nice to only shorten the entries that overflow the window somehow.
Beta Was this translation helpful? Give feedback.
All reactions