vim-clap icon indicating copy to clipboard operation
vim-clap copied to clipboard

Show history when input is empty

Open arashm opened this issue 4 years ago • 21 comments

Describe the solution you'd like When doing :Clap files or :Clap grep, many times I find myself wanna do the same search as the one I already did to select a different result, for that I need to type the whole input again. It could be cool if Clap could show a list of 10 previous searches when the input is empty, and we could just select it from the list.

arashm avatar Jan 13 '20 18:01 arashm

Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.97. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

issue-label-bot[bot] avatar Jan 13 '20 18:01 issue-label-bot[bot]

My original plan is to use <C-N>/<C-P> for navigating the input history, that could make people type the same search easier.

liuchengxu avatar Jan 14 '20 01:01 liuchengxu

@liuchengxu is input history available yet as a feature? <c-n> / <c-p> does not currently seem to do this

svermeulen avatar May 16 '20 05:05 svermeulen

Still unimplemented, not a priority for me. PR welcome.

liuchengxu avatar May 16 '20 06:05 liuchengxu

I miss this feature in vim-clap, would be great to have it

haskelcurry avatar Jul 23 '21 06:07 haskelcurry

Sorry for taking so long on this issue, for the simplicity, a new provider can be added for such a purpose. Could you try this branch https://github.com/liuchengxu/vim-clap/tree/input-history-provider? @arashm @svermeulen @mtuzinskiy It's not complete, but we're starting somewhere anyway. Now you can invoke :Clap input_history to show the last 20 queries, and rerun the last normal(anyone but not input_history and providers provider) provider with that query. The future work could be make a decision if we want to show this history whenever the input is empty for any providers or just the input_history provider.

liuchengxu avatar Jan 22 '22 04:01 liuchengxu

That's great news @liuchengxu. Will try out that branch today 💪

arashm avatar Jan 26 '22 11:01 arashm

I recompiled the rust stuff, but I still get an empty window no matter what. Other providers I use, seems to be fine.

Screenshot 2022-01-26 at 14 16 41

I tried filer and grep. I have vim 8.2.4200 and tried it on mac.

arashm avatar Jan 26 '22 14:01 arashm

The input history provider does not require the Rust binary. The idea is to record each input in this provider and use these history inputs as the source and it's not yet persistent, you need to call other providers with queries first and then call the input history provider to resume some query against the last provider.

The whole design is not settled. I'm happy to have some feedback on the UX.

liuchengxu avatar Jan 26 '22 14:01 liuchengxu

@arashm I have pushed a new commit to fix the vim issue you just ran into, please pull the latest commit of that branch and try again. I didn't test Vim, only tested against NeoVim :(.

liuchengxu avatar Jan 26 '22 15:01 liuchengxu

https://user-images.githubusercontent.com/849640/151187393-2135cd8b-1ae4-445e-adfb-53635c611e0c.mov

What am I missing? I did a grep and files.

In terms of UX, I find it easier if I see history of each provider, when I invoke that provider. For example, if I do a Clap files! now, I just see some random files at the beginning, before I start typing, preferably if this could be replaced with the history of previous files I open with files would be much easier. Same for grep2. Having another provider to invoke to get the history is a bit tedious.

arashm avatar Jan 26 '22 15:01 arashm

Oh, I pull again, thanks. Maybe I have to switch to NewoVim too :(

arashm avatar Jan 26 '22 15:01 arashm

Somehow worked now. But I say it's sorted reversed. It doesn't show anything more than the first 10.

Screenshot 2022-01-26 at 15 14 46

I guess why it shows the command like this is because files searches stuff after each keypress.

arashm avatar Jan 26 '22 15:01 arashm

https://github.com/liuchengxu/vim-clap/blob/input-history-provider/autoload/clap/provider/input_history.vim#L8 the history size is limited right now, you can change it to a larger number temporarily. I just pushed another commit to reverse the order.

Basically, the history records the input whenever the query changes, but it does not mean the searching job will be started accordingly since we might use the debounce strategy for the performance reason.

liuchengxu avatar Jan 26 '22 15:01 liuchengxu

before I start typing, preferably if this could be replaced with the history of previous files I open with files would be much easier.

I don't quite follow. Can you make an example about what kind of files you'd like to show when the input is empty?

Having another provider to invoke to get the history is a bit tedious.

I agree, but this is the easiest way to do it, haven't seen any other way to achieve a smooth experience with such trivial changes.

liuchengxu avatar Jan 26 '22 15:01 liuchengxu

The sort is fixed. I have a combination like this in my config for grep:

nmap <silent> <leader>gg :Clap grep2 ++query=<cword><CR>

Invoking grep like this, won't show anything in the history, only if I manually type in grep window, it will appear in the history.

arashm avatar Jan 26 '22 15:01 arashm

Invoking grep like this, won't show anything in the history, only if I manually type in grep window, it will appear in the history.

Pushed a new commit, should be fixed now.

liuchengxu avatar Jan 26 '22 15:01 liuchengxu

Now the first time I invoke grep2 like that, it adds an entry to history as "files: something I queried with grep", and then any other invocation after that, won't add anything to the history.

arashm avatar Jan 26 '22 16:01 arashm

@arashm Another commit pushed, please try again. Seems to work on my machine this time.

liuchengxu avatar Jan 26 '22 16:01 liuchengxu

Yep, it seems to be working fine now!

arashm avatar Jan 26 '22 16:01 arashm

Checked it on my NeoVim (I use Arch btw), works as expected.

haskelcurry avatar Jan 26 '22 18:01 haskelcurry

Using <C-N>/<C-P> for navigating the input history as described in https://github.com/liuchengxu/vim-clap/issues/235#issuecomment-573955407 has been implemented in #903, feel free to try it, you need to compile the binary on your own for now.

liuchengxu avatar Jan 09 '23 08:01 liuchengxu