commit
02b02b266e
3 changed files with 46 additions and 16 deletions
|
@ -194,6 +194,8 @@ these arguments:
|
||||||
|
|
||||||
- `-kak-cmd`: A Kakoune command that is applied to `fzf` resulting value, e.g.
|
- `-kak-cmd`: A Kakoune command that is applied to `fzf` resulting value, e.g.
|
||||||
`edit -existing`, `change-directory`, e.t.c.
|
`edit -existing`, `change-directory`, e.t.c.
|
||||||
|
- `-multiple-cmd`: A Kakoune command that is applied when multiple items
|
||||||
|
selected to every item but the first one.
|
||||||
- `-items-cmd`: A command that is used as a pipe to provide list of values to
|
- `-items-cmd`: A command that is used as a pipe to provide list of values to
|
||||||
`fzf`. For example, if we want to pass list of all files recursively in
|
`fzf`. For example, if we want to pass list of all files recursively in
|
||||||
current directory, we would use `-items-cmd %{find .}` which will be piped to
|
current directory, we would use `-items-cmd %{find .}` which will be piped to
|
||||||
|
|
|
@ -103,6 +103,7 @@ define-command -docstring \
|
||||||
|
|
||||||
Switches:
|
Switches:
|
||||||
-kak-cmd <command>: A Kakoune cmd that is applied to fzf resulting value
|
-kak-cmd <command>: A Kakoune cmd that is applied to fzf resulting value
|
||||||
|
-multiple-cmd <command>: A Kakoune cmd that is applied all multiple selected files but the first one
|
||||||
-items-cmd <items command>: A command that is used as a pipe to provide list of values to fzf
|
-items-cmd <items command>: A command that is used as a pipe to provide list of values to fzf
|
||||||
-fzf-impl <implementation>: Owerride fzf implementation variable
|
-fzf-impl <implementation>: Owerride fzf implementation variable
|
||||||
-fzf-args <args>: Additional flags for fzf program
|
-fzf-args <args>: Additional flags for fzf program
|
||||||
|
@ -112,6 +113,7 @@ Switches:
|
||||||
-post-action <commands>: Extra commands that are preformed after `-kak-cmd' command" \
|
-post-action <commands>: Extra commands that are preformed after `-kak-cmd' command" \
|
||||||
-shell-script-completion %{
|
-shell-script-completion %{
|
||||||
printf "%s\n" "-kak-cmd
|
printf "%s\n" "-kak-cmd
|
||||||
|
-multiple-cmd
|
||||||
-items-cmd
|
-items-cmd
|
||||||
-fzf-impl
|
-fzf-impl
|
||||||
-fzf-args
|
-fzf-args
|
||||||
|
@ -126,6 +128,7 @@ fzf -params .. %{ evaluate-commands %sh{
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-kak-cmd) shift; kakoune_cmd="$1" ;;
|
-kak-cmd) shift; kakoune_cmd="$1" ;;
|
||||||
|
-multiple-cmd) shift; multiple_cmd="$1" ;;
|
||||||
-items-cmd) shift; items_cmd="$1 |" ;;
|
-items-cmd) shift; items_cmd="$1 |" ;;
|
||||||
-fzf-impl) shift; fzf_impl="$1" ;;
|
-fzf-impl) shift; fzf_impl="$1" ;;
|
||||||
-fzf-args) shift; fzf_args="$1" ;;
|
-fzf-args) shift; fzf_args="$1" ;;
|
||||||
|
@ -136,6 +139,8 @@ fzf -params .. %{ evaluate-commands %sh{
|
||||||
esac; shift
|
esac; shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
[ -z "$multiple_cmd" ] && multiple_cmd="$kakoune_cmd"
|
||||||
|
|
||||||
if [ "${preview}" = "true" ]; then
|
if [ "${preview}" = "true" ]; then
|
||||||
# bake position option to define them at runtime
|
# bake position option to define them at runtime
|
||||||
if [ -n "${kak_client_env_TMUX}" ]; then
|
if [ -n "${kak_client_env_TMUX}" ]; then
|
||||||
|
@ -196,8 +201,12 @@ fzf -params .. %{ evaluate-commands %sh{
|
||||||
esac
|
esac
|
||||||
if [ -n "${item}" ]; then
|
if [ -n "${item}" ]; then
|
||||||
printf "%s\n" "evaluate-commands -client ${kak_client} ${wincmd} %{${kakoune_cmd} %{${item}}}"
|
printf "%s\n" "evaluate-commands -client ${kak_client} ${wincmd} %{${kakoune_cmd} %{${item}}}"
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
while read line; do
|
||||||
|
printf "%s\n" "evaluate-commands -client ${kak_client} ${wincmd} %{${multiple_cmd} %{${line}}}"
|
||||||
|
done
|
||||||
if [ -n "${post_action}" ]; then
|
if [ -n "${post_action}" ]; then
|
||||||
printf "%s\n" "evaluate-commands -client ${kak_client} %{${post_action}}"
|
printf "%s\n" "evaluate-commands -client ${kak_client} %{${post_action}}"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -15,6 +15,8 @@ Default value:
|
||||||
grep -RHn" \
|
grep -RHn" \
|
||||||
str fzf_sk_grep_command 'grep -RHn'
|
str fzf_sk_grep_command 'grep -RHn'
|
||||||
|
|
||||||
|
declare-option -hidden str fzf_sk_first_file ''
|
||||||
|
|
||||||
try %{ declare-user-mode fzf }
|
try %{ declare-user-mode fzf }
|
||||||
|
|
||||||
evaluate-commands %sh{
|
evaluate-commands %sh{
|
||||||
|
@ -38,14 +40,31 @@ define-command -hidden fzf-sk-grep %{ evaluate-commands %sh{
|
||||||
|
|
||||||
printf "%s\n" "info -title '${title}' '${message}${tmux_keybindings}'"
|
printf "%s\n" "info -title '${title}' '${message}${tmux_keybindings}'"
|
||||||
[ ! -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"
|
||||||
printf "%s\n" "fzf -kak-cmd %{fzf-sk-grep-handler} -fzf-impl %{sk -i -c '$kak_opt_fzf_sk_grep_command {}'} -fzf-args %{--expect ctrl-w $additional_flags}"
|
printf "%s\n" "fzf -kak-cmd %{fzf-sk-grep-handler} -fzf-impl %{sk -m -i -c '$kak_opt_fzf_sk_grep_command {}'} -fzf-args %{--expect ctrl-w $additional_flags} -multiple-cmd %{fzf-sk-populate-grep} -post-action %{buffer %opt{fzf_sk_first_file}}"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
define-command -hidden fzf-sk-grep-handler -params 1 %{ evaluate-commands %sh{
|
define-command -hidden fzf-sk-grep-handler -params 1 %{
|
||||||
|
evaluate-commands %sh{
|
||||||
printf "%s\n" "$1" | awk '{
|
printf "%s\n" "$1" | awk '{
|
||||||
file = $0; sub(/:.*/, "", file); gsub("&", "&&", file);
|
file = $0; sub(/:.*/, "", file); gsub("&", "&&", file);
|
||||||
line = $0; sub(/[^:]+:/, "", line); sub(/:.*/, "", line)
|
line = $0; sub(/[^:]+:/, "", line); sub(/:.*/, "", line)
|
||||||
print "edit -existing %&" file "&; execute-keys %&" line "gxvc&";
|
print "edit -existing %&" file "&; execute-keys %&" line "gxvc&"
|
||||||
|
print "set-option global fzf_sk_first_file %&" file "&"
|
||||||
}'
|
}'
|
||||||
}}
|
}
|
||||||
|
fzf-sk-populate-grep %arg{1}
|
||||||
|
}
|
||||||
|
|
||||||
|
define-command -hidden fzf-sk-populate-grep -params 1 %{
|
||||||
|
try %{
|
||||||
|
buffer *grep*
|
||||||
|
} catch %{
|
||||||
|
edit -scratch *grep*
|
||||||
|
set-option buffer filetype grep
|
||||||
|
}
|
||||||
|
evaluate-commands -buffer *grep* %{
|
||||||
|
set-register dquote %arg{1}
|
||||||
|
execute-keys gjPo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue