telescope.nvim
telescope.nvim copied to clipboard
Improve oldfiles
Is your feature request related to a problem? Please describe.
When i open oldfiles i see
For example i want select second file and type
d
But i lose my file in this case, because recently files sorting doesn't work
Describe the solution you'd like Show always 100 recently files for example sorted by last usage time. When i type in prompt, i FILTER this list and save previous order.
latest master now can do
require("telescope.builtin").oldfiles {
tiebreak = function(current_entry, existing_entry, _)
return current_entry.index < existing_entry.index
end
}
which should resolve your issue, we just need to integrate it better. better defaults and all, so i'd prefer if we keep that issue open
Yes, it works! Thank you! But it wasn't documented.
tiebreak is documented (help telescope.tiebreak
), the actual function is not, its more a configuration option.
i am currently thinking about doing a tiebreak abstraction where tiebreak can either be a custom function of a identifier to a already provided function, like index
. so then people can do tiebreak = "index"
to achieve that, and that will then be better documented.
but i havent decided anything yet so, until then i would like to keep that issue open :)
Nice! Just for documentation sake: I'm using this keybinding in my NvChad setup to find my most recently opened files in current working directory, ordered by most recent opened time, and also when filtering. That last part was so solved by @Conni2461's suggestion. Thanks :).
~/.nvchad/lua/custom/mappings.lua
telescope = {
plugin = true,
n = {
["<leader>fp"] = {
function()
require("telescope.builtin").oldfiles({
cwd_only = true,
tiebreak = function(current_entry, existing_entry, _)
-- This ensures that when you are filtering, it's also sorted by last opened time.
-- https://github.com/nvim-telescope/telescope.nvim/issues/2539#issuecomment-1562510095
return current_entry.index < existing_entry.index
end,
})
end,
"Find recent files in CWD",
},
},
},