In Vim many things go into the same error list whereas Kakoune tends to use different buffers with filetype=grep
. This is nice because I can browse them independently.
However, when pressing my shortcut for grep-{next,previous}-match
I usually only care about the last accessed grep-like buffer. Here is the command I use:
declare-option -hidden str my_grep_buffer
hook -group my global WinDisplay \
\*(?:grep|find|make|references|diagnostics|implementations|symbols|cargo)\* %{
set-option global my_grep_buffer %val{bufname}
}
define-command -override my-grep-next-match \
-docstring 'Jump to the next match in a grep-like buffer' %{
evaluate-commands -try-client %opt{jumpclient} %{
buffer %opt{my_grep_buffer}
execute-keys "<a-l> /^[^:\n]+:\d+:<ret>"
grep-jump
}
try %{ evaluate-commands -client %opt{toolsclient} %{
buffer %opt{my_grep_buffer}
execute-keys gg %opt{grep_current_line}g
}}
}
define-command -override my-grep-previous-match \
-docstring 'Jump to the previous match in a grep-like buffer' %{
evaluate-commands -try-client %opt{jumpclient} %{
buffer %opt{my_grep_buffer}
execute-keys "g<a-h> <a-/>^[^:\n]+:\d+:<ret>"
grep-jump
}
try %{ evaluate-commands -client %opt{toolsclient} %{
buffer %opt{my_grep_buffer}
execute-keys gg %opt{grep_current_line}g
}}
}