telescope.nvim icon indicating copy to clipboard operation
telescope.nvim copied to clipboard

action: select_preview; sorter: preserve_order; picker: git_commits git_grep

Open antoinemadec opened this issue 2 years ago • 5 comments

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

  • reorders the entries when filtering them
  • does not allow to open the preview/commit
  • is lacking critical info such as the SHA/author/msg

git_live_grep and git_grep_string are missing from the builtin functions

Describe the solution you'd like telescope.sorters should include a preserve_order so the list filtering do not reorder the entries. This is useful for chronological lists (e.g.: git commits). See: sorters.lua

telescope.actions should include select_preview_* so the previews can be open. This is useful for previews generated by a command line (e.g.: git commits). See: actions.lua

git_commits should:

  • use telescope.sorters.preserve_order
  • use telescope.actions.select_preview_*
  • add more info in the previews (SHA/author/msg) or give the option to override the command used to generate the preview. See: previews.lua

git_live_grep and git_grep_string could be implemented. See: git_browse.lua

Describe alternatives you've considered Create an extension. See: telescope-git-browse.nvim

I understand that what should be in the builtin functions is open to debate. However, I think preserve_order and select_preview_* could benefit everyone. Thanks for the great plugin :heart:

antoinemadec avatar May 29 '22 16:05 antoinemadec

telescope.sorters should include a preserve_order so the list filtering do not reorder the entries. This is useful for chronological lists (e.g.: git commits). See: sorters.lua

There's two variants here. The opts.tiebreak (which doesn't do what you want I understand from comment of your PR) and what comes to mind is https://github.com/nvim-telescope/telescope.nvim/pull/1168#issuecomment-986001845 as a potential interface for something like that similar to your solution. So yeah, we want this, but ideally a bit more generically :)

I hope to have more time in July to get back to something like that. It would be relatively straightforward I hope.

telescope.actions should include select_preview_* so the previews can be open. This is useful for previews generated by a command line (e.g.: git commits).

I personally think that's cool (some use cases come to mind) and should be relatively straightforward, would you be happy to do a PR for that? :) happy to guide to provide references to what to look at. (As a side note, one thing to keep in mind here the actual selection and preview in many cases coincide :)

git_live_grep and git_grep_string could be implemented.

This should be doable via hooking into the vanilla variants which I understand does already work to a large degree? git cwd detection could be a util that is passed to opts.cwd? Anything else that we could have in core here to facilitate that?

fdschmidt93 avatar May 30 '22 19:05 fdschmidt93

Re select_preview_*. I've wrote an interface for octo.nvim a long time ago that doesn't clean up the last_preview_bufnr so you can just open that one

https://github.com/pwntester/octo.nvim/blob/5517cbdf302be2abc4ac43e5b8b2a812d0222bbb/lua/octo/pickers/telescope/provider.lua#L77-L93

See keep_last_buf under :help telescope.previewers.new_buffer_previewer

Conni2461 avatar May 31 '22 06:05 Conni2461

@Conni2461 does your code work when multiple telescope instances are running ? Do you think it could be pushed in telescope ?

On my end, my code does a copy/paste which might not be ideal, but should work with multiple telescope opened at the same time. https://github.com/antoinemadec/telescope-git-browse.nvim/blob/4b67681014898e1d67138e2bf396d82c92ffe2a8/lua/telescope/_extensions/git_browse/actions.lua#L22-L38

antoinemadec avatar Jun 01 '22 12:06 antoinemadec

multiple telescope instances are running

What are multiple telescope instances? If you are in an telescope instance and try to open a new one, we close the previous one

Do you think it could be pushed in telescope ?

Dont know, usually opening previewers will not work as expected. E.g. file previewers, thats also the reason why you can't focus the previewer. It works great for a specific usecase like octo, where he created really specific buffer content, with custom highlighting, to review prs for example. So to reduce code duplication he asked me if we could not clean up the last previewer.

Conni2461 avatar Jun 01 '22 13:06 Conni2461

OK, let me know if you want me to create a PR for something in particular, I'd be happy to help.

antoinemadec avatar Jun 01 '22 14:06 antoinemadec