andreyorst / fzf.kak

FZF for Kakoune
MIT License
143 stars 33 forks source link

Populate *grep* buffer when selecting multiple candidates in `fzf-sk-grep` #44

Closed alexherbo2 closed 5 years ago

alexherbo2 commented 5 years ago

How to grep file contents and get the file, line and column in results. And also the preview.

andreyorst commented 5 years ago

Sorry, not sure what you mean by "grep file contents". There are currently two commands, one is sk-grep that is bound to g in fzf-mode and provides interactive grep over current directory recursive, and fzf-search, which is bound to s in fzf-mode and allows you to narrow through contents of current buffer but it is not grep, it is pure fzf filtering.

sk-grep is only available if skim is installed in your system.

andreyorst commented 5 years ago

Ah, maybe I get it.

Well, I've designed sk-grep to be simple and work like fzf-search does. We can make it use preview feature, and display line numbers, but it will require tweaking the implementation. It's not configurable right now.

alexherbo2 commented 5 years ago

It’s more about skim than fzf.kak, but the grep command is evaluated after each key-press? How about the performance.

Finally, I thought it might be interesting for sk-grep to work with multiple selections, by populating the grep buffer, so search results are reusable with grep-next-match and grep-previous-match.

andreyorst commented 5 years ago

the grep command is evaluated after each key-press? How about the performance.

There is no other way to get new results, as all currently existing tools work this way. If there ever will be incremental grep program, it would be better in terms of performance, of course.

I thought it might be interesting for sk-grep to work with multiple selections, by populating the grep buffer, so search results are reusable with grep-next-match and grep-previous-match.

There are two points here:

  1. It meant to be used as incremental search tool, for basic grep usage Kakoune provides useful command already.
  2. I'm not sure if it will be possible to pass default text to fzf or skim without something like tmux send-keys, and fzf.kak supports X11 windows too, so I don't see a way to perform this.
alexherbo2 commented 5 years ago

I was referring to the composability of both when selecting multiple elements with Tab and Shift + Tab from fzf: jump to the first match and populate the grep buffer, so that grep-next-match and grep-previous-match can cycle through the results.

It’s the same idea than doing a search with /, then be able to jump to the next occurrence with n and previous with Alt + n.

andreyorst commented 5 years ago

Hm, that's interesting idea. I'll implement this