diff --git a/README.md b/README.md index 8616cb6..0c4fe0c 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,12 @@ fzf` before configuring options. Same goes for `fzf_vcs` module. From now on I assume that you're using one of the methods listed above for all configurations below. +### Default query +**fzf.kak** by default will use main selection as default query for fzf, if the +selection more than 1 character long (because cursor is simply 1-char +selection). You can disable this behavior by setting `fzf_use_main_selection` to +`false`. + ### Windowing If you're using Tmux, you do not have to worry about windowing, since fzf.kak automatically creates all needed Tmux splits and panes for you. However in case diff --git a/rc/fzf.kak b/rc/fzf.kak index 6ec0229..338e6f6 100644 --- a/rc/fzf.kak +++ b/rc/fzf.kak @@ -89,6 +89,9 @@ declare-option -docstring 'command to use to create new window when not using tm Default value: terminal kak -c %val{session} -e "%arg{@}"' \ str fzf_terminal_command 'terminal kak -c %val{session} -e "%arg{@}"' +declare-option -docstring "use main selection as default query for fzf if the selection is longer than 1 char." \ +bool fzf_use_main_selection true + try %{ declare-user-mode fzf } define-command -hidden -docstring "wrapper command to create new vertical split" \ @@ -137,9 +140,9 @@ Switches: fzf -params .. %{ evaluate-commands %sh{ fzf_impl="${kak_opt_fzf_implementation}" - if [ $(printf "%s" "${kak_selection}" | wc -m) -gt 1 ]; then - default_query="-i -q ${kak_selection}" - fi + [ "${kak_opt_fzf_use_main_selection}" = "true" ] && \ + [ $(printf "%s" "${kak_selection}" | wc -m) -gt 1 ] && \ + default_query="-i -q ${kak_selection}" while [ $# -gt 0 ]; do case $1 in