From bdadf2c52ce53c09e200537650fffb80e34a01b3 Mon Sep 17 00:00:00 2001 From: andreyorst Date: Thu, 3 Jan 2019 20:00:59 +0300 Subject: [PATCH 1/3] use tmux-terminal commands instead of old tmux-new comands --- rc/fzf.kak | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rc/fzf.kak b/rc/fzf.kak index 4a45d50..7362789 100644 --- a/rc/fzf.kak +++ b/rc/fzf.kak @@ -159,19 +159,23 @@ fzf -params 2..4 %{ evaluate-commands %sh{ read action case $action in ctrl-w) - [ -n "$kak_client_env_TMUX" ] && wincmd="tmux-new-window" || wincmd="x11-new" ;; + [ -n "$kak_client_env_TMUX" ] && wincmd="tmux-terminal-window" || wincmd="x11-terminal" ;; ctrl-s) - wincmd="tmux-new-vertical" ;; + wincmd="tmux-terminal-vertical" ;; ctrl-v) - wincmd="tmux-new-horizontal" ;; + wincmd="tmux-terminal-horizontal" ;; *) if [ -n "$action" ]; then printf "%s\n" "evaluate-commands -client $kak_client '$command' '$action'" | kak -p $kak_session [ -n "$extra_action" ] && printf "%s\n" "evaluate-commands -client $kak_client $extra_action" | kak -p $kak_session fi ;; esac + if [ -n "$wincmd" ]; then + wincmd="%{$wincmd kak -c $kak_session -e " + closer="}" + fi kakoune_command() { - printf "%s\n" "evaluate-commands -client $kak_client $wincmd $command %{$1}" + printf "%s\n" "evaluate-commands -client $kak_client $wincmd %{$command %{$1}}$closer" [ -n "$extra_action" ] && printf "%s\n" "evaluate-commands -client $kak_client $extra_action" } while read item; do From 0ce2af0de4116962ca9019c28190a19b46f3c571 Mon Sep 17 00:00:00 2001 From: andreyorst Date: Thu, 3 Jan 2019 20:40:19 +0300 Subject: [PATCH 2/3] add proper wrappers to handle both old and new variants of creating splits --- rc/fzf.kak | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/rc/fzf.kak b/rc/fzf.kak index 7362789..a151a84 100644 --- a/rc/fzf.kak +++ b/rc/fzf.kak @@ -63,6 +63,38 @@ Best used with mapping like: " \ fzf-mode %{ try %{ evaluate-commands 'enter-user-mode fzf' } } +define-command -hidden fzf-vertical -params 2 %{ + try %{ + tmux-terminal-vertical kak -c %val{session} -e "%arg{1} %arg{2}" + } catch %{ + tmux-new-vertical "%arg{1} %arg{2}" + } +} + +define-command -hidden fzf-horizontal -params 2 %{ + try %{ + tmux-terminal-horizontal kak -c %val{session} -e "%arg{1} %arg{2}" + } catch %{ + tmux-new-horizontal "%arg{1} %arg{2}" + } +} + +define-command -hidden fzf-window -params 2 %{ + try %sh{ + if [ -n "$kak_client_env_TMUX" ]; then + printf "%s\n" 'tmux-terminal-window kak -c %val{session} -e "%arg{1} %arg{2}"' + else + printf "%s\n" 'x11-erminal kak -c %val{session} -e "%arg{1} %arg{2}"' + fi + } catch %sh{ + if [ -n "$kak_client_env_TMUX" ]; then + printf "%s\n" 'tmux-new-window "%arg{1} %arg{2}"' + else + printf "%s\n" 'x11-new "%arg{1} %arg{2}"' + fi + } +} + define-command -hidden -docstring \ "fzf [ ]: generic fzf command. This command can be used to create new fzf wrappers for various Kakoune or external @@ -159,23 +191,19 @@ fzf -params 2..4 %{ evaluate-commands %sh{ read action case $action in ctrl-w) - [ -n "$kak_client_env_TMUX" ] && wincmd="tmux-terminal-window" || wincmd="x11-terminal" ;; + wincmd="fzf-window" ;; ctrl-s) - wincmd="tmux-terminal-vertical" ;; + wincmd="fzf-vertical" ;; ctrl-v) - wincmd="tmux-terminal-horizontal" ;; + wincmd="fzf-horizontal" ;; *) if [ -n "$action" ]; then printf "%s\n" "evaluate-commands -client $kak_client '$command' '$action'" | kak -p $kak_session [ -n "$extra_action" ] && printf "%s\n" "evaluate-commands -client $kak_client $extra_action" | kak -p $kak_session fi ;; esac - if [ -n "$wincmd" ]; then - wincmd="%{$wincmd kak -c $kak_session -e " - closer="}" - fi kakoune_command() { - printf "%s\n" "evaluate-commands -client $kak_client $wincmd %{$command %{$1}}$closer" + printf "%s\n" "evaluate-commands -client $kak_client $wincmd $command %{$1}" [ -n "$extra_action" ] && printf "%s\n" "evaluate-commands -client $kak_client $extra_action" } while read item; do From 23c402d8a25c9a3f72b512e7b325d5c42936aa90 Mon Sep 17 00:00:00 2001 From: andreyorst Date: Thu, 3 Jan 2019 21:06:15 +0300 Subject: [PATCH 3/3] fix typo --- rc/fzf.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/fzf.kak b/rc/fzf.kak index a151a84..a25ee9c 100644 --- a/rc/fzf.kak +++ b/rc/fzf.kak @@ -84,7 +84,7 @@ define-command -hidden fzf-window -params 2 %{ if [ -n "$kak_client_env_TMUX" ]; then printf "%s\n" 'tmux-terminal-window kak -c %val{session} -e "%arg{1} %arg{2}"' else - printf "%s\n" 'x11-erminal kak -c %val{session} -e "%arg{1} %arg{2}"' + printf "%s\n" 'x11-terminal kak -c %val{session} -e "%arg{1} %arg{2}"' fi } catch %sh{ if [ -n "$kak_client_env_TMUX" ]; then