1
0
Fork 0

Merge pull request #11 from andreyorst/buffer-search

Buffer search
This commit is contained in:
Andrey Orst 2018-10-02 19:46:35 +03:00 committed by GitHub
commit 5caa0fcdc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -153,8 +153,7 @@ define-command -hidden fzf-tag %{
[ ! -z "${kak_client_env_TMUX}" ] && additional_keybindings=" [ ! -z "${kak_client_env_TMUX}" ] && additional_keybindings="
<c-s>: open tag in horizontal split <c-s>: open tag in horizontal split
<c-v>: open tag in vertical split" <c-v>: open tag in vertical split"
message="Jump to a symbol''s definition. message="Jump to a symbol''s definition.<ret>: open tag in new buffer.
<ret>: open tag in new buffer.
<c-w>: open tag in new window $additional_keybindings" <c-w>: open tag in new window $additional_keybindings"
echo "info -title '$title' '$message'" echo "info -title '$title' '$message'"
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s" [ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
@ -176,8 +175,16 @@ define-command -hidden fzf-buffer-search %{
title="fzf buffer search" title="fzf buffer search"
message="Search buffer with fzf, and jump to result location" message="Search buffer with fzf, and jump to result location"
echo "info -title '$title' '$message'" echo "info -title '$title' '$message'"
line=$kak_cursor_line
char=$(expr $kak_cursor_char_column - 1)
buffer_content=$(mktemp ${TMPDIR:-/tmp}/kak-curr-buff.XXXXXX)
echo "execute-keys %{%<a-|>cat<space>><space>$buffer_content<ret>;}"
echo "execute-keys $line g $char l"
echo "fzf \"execute-keys \$1 gx\" \"(nl -b a -n ln $buffer_content\" \"--reverse | cut -f 1)\""
(echo "fzf \"execute-keys \$1 gx\" \"(nl -b a -n ln $buffer_content\" \"--reverse | cut -f 1)\"") 1>&2
# sleep 2 is needed to because everything is done asynchronously, so file should not be deleted until it was read by fzf
echo "nop %sh{sleep 2; rm $buffer_content}"
} }
fzf "execute-keys $1 gx" "(nl -b a -n ln '%val{buffile}'" "--reverse | cut -f 1)"
} }
define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{ define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{