natecraddock/telescope-zf-native.nvim

Ability to enhance sorting (e.g. MRU/recent files first in results)

Closed this issue · 5 comments

Hi, I love your sorter! Finally something which prioritizes the proper parts in paths.

But I would like to merge three pickers which I often use and I hate that I need THREE of them separately:

  • oldfiles (because I want to browse recent files but it doesn't show already opened buffers so I need the next one in the list)
  • buffers (so I can browse in opened buffers but if I don't have the demanded file open or it's not in old_files then I would like to search in all files and that is the last one in this list)
  • find_files

I think that if I can prioritize recently used buffers/files in the sorted result then I don't have to switch between pickers.

Is that already possible with your sorter or not? :) Or if you can point me to the right direction where I should investigate of how to do it..

Hi, I love your sorter! Finally something which prioritizes the proper parts in paths.

Thank you for the kind words! Glad to hear it works well for you

I think that if I can prioritize recently used buffers/files in the sorted result then I don't have to switch between pickers.

Hmm.. I'll have to think more about this. My first thought is that you will likely need to build a new picker that combines oldfiles, buffers, and find_files into a single source. But it is possible you could get a 90% solution by only modifying this plugin.

I would start with the scoring_function https://github.com/natecraddock/telescope-zf-native.nvim/blob/master/lua/telescope/_extensions/zf-native.lua#L23 and then modify the rank based on recently used status. For example, you could definitely add a local table somewhere in that file to keep track of recently opened files. If the line is in the table, you could update the rank to prioritize it.

Smaller ranks are better by the way.

The downside with updating only the sorter is you wouldn't get the combined list of files to work with.

Maybe things have changed, but last I looked, it wasn't possible to use zf and frecency together: #6

@chrisgrieser, I considered that option, but it seems a bit too intricate. 😄 And as @natecraddock mentioned, the plugin isn't highly customizable, and zf is not supported.

I would prefer a simpler approach:

  1. Arrange MRU (Most Recently Used) files, including closed ones, with currently opened files at the top, followed by recently used but not opened ones.
  2. Display the rest of the files only when narrowing the list with specific/non-empty search string.

I believe searching should prioritize recent files, reducing the risk of unexpected candidates. Ideally, this should be agnostic to the sorting method, allowing users to employ their preferred sorter. However, delving into Telescope requires more time, as I lack experience in tweaking it. At first glance, the code doesn't appear very elegant, lacking reusability in many aspects. For instance, I'd like to reuse results in Telescope's built-in pickers, but they are confined within finders, making modifications challenging (basically copy/paste parts of the code into my own).

I stumbled upon another plugin, https://github.com/danielfalk/smart-open.nvim, but it also doesn't utilize zf. So, here I am, contemplating my first Neovim plugin. 😅 However, I'm prioritizing my paid work, so I'll tackle this when time permits.

Thank you both for your time!

I'm going to close this. Feel free to comment if you think this is something I should look into more!