nvim-telescope/telescope.nvim

select by key/select_default on one entry

jam1015 opened this issue · 0 comments

This is more of a TODO for myself because I want to implement these when I have time, but if someone gets to it before me, or has already figured this out, all the better.

Is your feature request related to a problem? Please describe.

I use hop.nvim to navigate around my view of the current buffer. It is convenient because I can go :HopWord<cr> and press no more than two characters to be on any word I can currently see in the buffer being edited. I have it mapped to <leader>ww. I really like how smooth this is. No need to press , no more than two characters to jump anywhere. I want the same smoothness when switching buffers.

Describe the solution you'd like
I want to implement similar capability in a picker with the default telescope buffer picker as a starting point.

requirements:

  1. If more buffers are open than can be displayed immediately in the picker when it comes up, fall back to the to the default :Telescope buffers command.

  2. display the buffers by order of buffer number.

  3. next to the buffer number/name display the key that will actually be used for filtering. for buffers 1-9 this will be the same as the buffer number. for buffer 10 this would be 0. for buffers numbered higher than 10 use an alphabetic key, with as many letters as necessary to ensure uniqueness.

Prefixes in the key should be kept unique . For example if there are 37 buffers open, the keys might be

1 2 3 4 5 6 7 8 9 0 aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu vv ww xx yy zz za

The alphabetic keys have to be two long because of the 37th buffer; if they were one long, the prefixes wouldn't be unique.

Another detail to consider for smoothness might be favoring home row keys instead of going in alphabetical order.

  1. only filter based on these keys, not the buffer number itself and not the buffer name.

  2. when the picker has filtered down to one buffer, automatically trigger actions.select_default.

The result will be that, for for a reasonably sized Neovim window, you can select a buffer with no more than two keystrokes, and possibly three for an unusually huge Neovim window, possibly three characters, and without having to press <cr>

Yes this only saves a few keystrokes, but it would make switching buffers extra smooth; feeling extra smooth is why Neovim is fun. It does lend itself to sessions where the user is editing fewer buffers.

In Neovim with no plugins the similar workflow is :ls and then :b[buffernumber].

Describe alternatives you've considered

When I get a chance I will read up on the developer info for Telescope and try to implement this (if someone doesn't do this before me). If I can't figure out how to implement this based on the Telescope platform I (or someone else) can implement this as a standalone plugin.