1
0
Fork 0

make keys mapable. Fix #58

This commit is contained in:
Andrey Orst 2019-05-13 21:34:46 +03:00
parent fcb86e9bed
commit 8382d908d0
11 changed files with 55 additions and 35 deletions

View file

@ -109,6 +109,17 @@ is being used to create new windows.
**fzf.kak** features a lot of settings via options that can be altered to change
how **fzf.kak** behaves.
### Mappings
You can define what keys to use in `fzf` window via these options:
- `fzf_window_map` - mapping to perform an action in new window,
- `fzf_vertical_map` - mapping to perform an action in new vertical split
(Tmux),
- `fzf_horizontal_map` - mapping to perform an action in new horizontal split.
These options should be set to work with fzf `--expect` parameter, so check out
fzf documentation on this.
### File command
You can configure what command to use to search for files, and it's arguments.
Supported tools are [GNU Find][12], [The Silver Searcher][13], [ripgrep][14],

View file

@ -66,6 +66,15 @@ declare-option -docstring "height of preview window.
Default value: 60%%" \
str fzf_preview_height '60%'
declare-option -docstring "mapping to execute action in new window" \
str fzf_window_map 'ctrl-w'
declare-option -docstring "mapping to execute action in new vertical split" \
str fzf_vertical_map 'ctrl-v'
declare-option -docstring "mapping to execute action in new horizontal split" \
str fzf_horizontal_map 'ctrl-s'
define-command -docstring "Enter fzf-mode.
fzf-mode contains mnemonic key bindings for every fzf.kak command
@ -211,10 +220,10 @@ fzf -params .. %{ evaluate-commands %sh{
(
while read -r line; do
case ${line} in
ctrl-w) wincmd="fzf-window" ;;
ctrl-s) wincmd="fzf-vertical" ;;
ctrl-v) wincmd="fzf-horizontal" ;;
*) item=${line} ;;
${kak_opt_fzf_window_map}) wincmd="fzf-window" ;;
${kak_opt_fzf_vertical_map}) wincmd="fzf-vertical" ;;
${kak_opt_fzf_horizontal_map}) wincmd="fzf-horizontal" ;;
*) item=${line} ;;
esac
if [ -n "${item}" ]; then
printf "%s\n" "evaluate-commands -client ${kak_client} ${wincmd} %{${kakoune_cmd} %{${item}}}"

View file

@ -30,8 +30,8 @@ define-command -hidden fzf-bzr %{ evaluate-commands %sh{
bzr*)
cmd=$kak_opt_fzf_bzr_command ;;
esac
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags} -post-action %{cd $current_path}"
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect $kak_opt_fzf_window_map $additional_flags} -post-action %{cd $current_path}"
}}
§

View file

@ -30,8 +30,8 @@ define-command -override -hidden fzf-git %{ evaluate-commands %sh{
git*)
cmd=$kak_opt_fzf_git_command ;;
esac
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags} -post-action %{cd $current_path}"
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect $kak_opt_fzf_window_map $additional_flags} -post-action %{cd $current_path}"
}}
§

View file

@ -30,8 +30,8 @@ define-command -hidden fzf-hg %{ evaluate-commands %sh{
hg*)
cmd=$kak_opt_fzf_hg_command ;;
esac
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags} -post-action %{cd $current_path}"
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect $kak_opt_fzf_window_map $additional_flags} -post-action %{cd $current_path}"
}}
§

View file

@ -29,8 +29,8 @@ define-command -hidden fzf-svn %{ evaluate-commands %sh{
svn*)
cmd=$kak_opt_fzf_svn_command ;;
esac
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags} -post-action %{cd $current_path}"
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect $kak_opt_fzf_window_map $additional_flags} -post-action %{cd $current_path}"
}}
§

View file

@ -22,14 +22,14 @@ define-command -hidden fzf-buffer %{ evaluate-commands %sh{
message="Set buffer to edit in current client.
<ret>: switch to selected buffer.
<c-w>: open buffer in new window"
$kak_opt_fzf_window_map: open buffer in new window"
[ ! -z "${kak_client_env_TMUX}" ] && tmux_keybindings="
<c-s>: open buffer in horizontal split
<c-v>: open buffer in vertical split"
$kak_opt_fzf_horizontal_map: open buffer in horizontal split
$kak_opt_fzf_vertical_map: open buffer in vertical split"
printf "%s\n" "info -title 'fzf buffer' '$message$tmux_keybindings'"
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
printf "%s\n" "fzf -kak-cmd %{buffer} -items-cmd %{(cat $buffers; rm $buffers)} -fzf-args %{--expect ctrl-w $additional_flags}"
printf "%s\n" "fzf -kak-cmd %{buffer} -items-cmd %{(cat $buffers; rm $buffers)} -fzf-args %{--expect $kak_opt_fzf_window_map $additional_flags}"
}}
§

View file

@ -815,17 +815,17 @@ define-command -hidden fzf-tag -params ..2 %{ evaluate-commands %sh{
message="Jump to a symbol''s definition
<ret>: open tag in new buffer
<c-w>: open tag in new terminal"
$kak_opt_fzf_window_map: open tag in new terminal"
[ -n "${kak_client_env_TMUX}" ] && tmux_keybindings="
<c-s>: open tag in horizontal split
<c-v>: open tag in vertical split"
$kak_opt_fzf_horizontal_map: open tag in horizontal split
$kak_opt_fzf_vertical_map: open tag in vertical split"
printf "%s\n" "info -title 'fzf tag' '$message$tmux_keybindings'"
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
printf "%s\n" "set-option -add window ctagsfiles %{$path/$kak_opt_fzf_tag_file_name}"
printf "%s\n" "fzf -kak-cmd %{ctags-search} -items-cmd %{$cmd | awk '!a[\$0]++'} -fzf-args %{--expect ctrl-w $additional_flags}"
printf "%s\n" "fzf -kak-cmd %{ctags-search} -items-cmd %{$cmd | awk '!a[\$0]++'} -fzf-args %{--expect $kak_opt_fzf_window_map $additional_flags}"
}}
§

View file

@ -53,14 +53,14 @@ define-command -hidden fzf-file %{ evaluate-commands %sh{
cmd="$cmd 2>/dev/null"
message="Open single or multiple files.
<ret>: open file in new buffer.
<c-w>: open file in new terminal"
$kak_opt_fzf_window_map: open file in new terminal"
[ ! -z "${kak_client_env_TMUX}" ] && tmux_keybindings="
<c-s>: open file in horizontal split
<c-v>: open file in vertical split"
$kak_opt_fzf_horizontal_map: open file in horizontal split
$kak_opt_fzf_vertical_map: open file in vertical split"
printf "%s\n" "info -title 'fzf file' '$message$tmux_keybindings'"
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s"
printf "%s\n" "fzf -preview -kak-cmd %{edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags}"
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
printf "%s\n" "fzf -preview -kak-cmd %{edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect $kak_opt_fzf_window_map $additional_flags}"
}}
§

View file

@ -47,11 +47,11 @@ bzr status"
vcs=$(printf "%s\n" "$cmd" | awk '{print $1}')
title="fzf $vcs"
[ ! -z "${kak_client_env_TMUX}" ] && additional_keybindings="
<c-s>: open file in horizontal split
<c-v>: open file in vertical split"
$kak_opt_fzf_horizontal_map: open file in horizontal split
$kak_opt_fzf_vertical_map: open file in vertical split"
message="Open single or multiple files from git tree.
<ret>: open file in new buffer.
<c-w>: open file in new terminal $additional_keybindings"
$kak_opt_fzf_window_map: open file in new terminal $additional_keybindings"
printf "%s\n" "info -title %{$title} %{$message}"
printf "%s\n" "fzf-$vcs"
exit

View file

@ -33,14 +33,14 @@ define-command -hidden fzf-sk-grep %{ evaluate-commands %sh{
title="skim interactive grep"
message="Interactively grep pattern from current directory
<ret>: open search result in new buffer.
<c-w>: open search result in new terminal"
$kak_opt_fzf_window_map: open search result in new terminal"
[ ! -z "${kak_client_env_TMUX}" ] && tmux_keybindings="
<c-s>: open search result in horizontal split
<c-v>: open search result in vertical split"
$kak_opt_fzf_horizontal_map: open search result in horizontal split
$kak_opt_fzf_vertical_map: open search result in vertical split"
printf "%s\n" "info -title '${title}' '${message}${tmux_keybindings}'"
[ ! -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 -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}}"
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
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 $kak_opt_fzf_window_map $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 %{