1
0
Fork 0
fzf.kak/rc/modules/fzf-search.kak

21 lines
900 B
Plaintext
Raw Normal View History

2021-03-19 18:00:49 +00:00
# Author: Andrey Listopadov
# Module for searching inside current buffer with fzf for fzf.kak
# https://github.com/andreyorst/fzf.kak
2018-11-11 10:41:15 +00:00
2021-03-19 18:00:49 +00:00
hook global ModuleLoaded fzf %{
map global fzf -docstring "search in buffer" 's' '<esc>: require-module fzf-search; fzf-buffer-search<ret>'
}
2019-05-09 15:12:06 +00:00
2021-03-19 18:00:49 +00:00
provide-module fzf-search %§
2018-11-11 10:41:15 +00:00
define-command -hidden fzf-buffer-search %{ evaluate-commands %sh{
title="fzf buffer search"
message="Search buffer with fzf, and jump to result location"
2018-11-22 12:36:11 +00:00
printf "%s\n" "info -title '$title' '$message'"
2021-03-20 19:44:19 +00:00
buffer_content="$(mktemp "${TMPDIR:-/tmp}"/fzf-buff-"${kak_buffile##*/}".XXXXXX)"
2018-11-22 12:36:11 +00:00
printf "%s\n" "execute-keys -draft %{%<a-|>cat<space>><space>$buffer_content<ret>;}"
printf "%s\n" "fzf -kak-cmd %{execute-keys} -items-cmd %{(nl -b a -n ln $buffer_content; rm $buffer_content)} -fzf-args %{--reverse} -filter %{cut -f 1} -post-action %{execute-keys gx}"
2018-11-11 10:41:15 +00:00
}}
2019-05-09 15:12:06 +00:00
§