vim-clap
vim-clap copied to clipboard
Show history when input is empty
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.
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.
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 is input history available yet as a feature? <c-n>
/ <c-p>
does not currently seem to do this
Still unimplemented, not a priority for me. PR welcome.
I miss this feature in vim-clap, would be great to have it
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.
That's great news @liuchengxu. Will try out that branch today 💪
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](https://user-images.githubusercontent.com/849640/151179546-0d5a7c04-267c-4a4b-91ac-a2040be71e12.png)
I tried filer and grep. I have vim 8.2.4200 and tried it on mac.
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.
@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 :(.
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.
Oh, I pull again, thanks. Maybe I have to switch to NewoVim too :(
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](https://user-images.githubusercontent.com/849640/151191061-a50ca6ef-33c8-436a-a36c-78ccc14aca86.png)
I guess why it shows the command like this is because files
searches stuff after each keypress.
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.
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.
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.
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.
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 Another commit pushed, please try again. Seems to work on my machine this time.
Yep, it seems to be working fine now!
Checked it on my NeoVim (I use Arch btw), works as expected.
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.