zeux / qgrep

Fast regular expression grep for source code with incremental index updates
MIT License
332 stars 43 forks source link

consider the second argument of qgrep#open in vimscript to be the input #11

Closed rivten closed 4 years ago

rivten commented 4 years ago

I was looking for some vim command to automatically search with qgrep for the word under the cursor. This was a pain to do with normal! and execute, so I looked if it was possible to pass the command QgrepSearch some arguments. I'm still a noob in vimscript but didn't see a lot of use from the qgrep#open arguments, excepts from the first one which was the mode.

So I simply added a way to check if another second argument was provided, and if it is, consider it as the default first input.

With that change, it now because way easier to make vimscript command for qgrep. For example (tested on my side) :

:execute "QgrepSearch" expand("<cword>")

launches qgrep with, as default input, the current word under the cursor. And you can go way crazier with that :)

I'm also a noob in PR, so tell me if there's something I could do better.

zeux commented 4 years ago

This looks good, thanks!