diff --git a/README.md b/README.md index a463df1..73548ba 100644 --- a/README.md +++ b/README.md @@ -59,25 +59,6 @@ Key Bindings: For example Ctrl+T `bindkey '^T' toggle-fzf-tab` -### Custom completions - -There exists mechanism for overwriting completion action for particular command -[similar to fzf](https://github.com/junegunn/fzf/wiki/Examples-(completion)). -If function named `_fzf_complete_foo` is found, it will be used for handling completions -of `foo` command. - -If you also have [fzf's completions](https://github.com/junegunn/fzf#fuzzy-completion-for-bash-and-zsh) -enabled (`completion.zsh` is sourced), you can use it's `_fzf_complete` helper function, for example: -``` -_fzf_complete_foo() { - _fzf_complete "--multi --reverse" "$@" < <( - echo foo - echo bar - echo bazz - ) -} -``` - ### Configure Here are some variables which can be used to control the behavior of fzf-tab. @@ -197,16 +178,6 @@ printc() { The key trigger continuous completion. Default value: `/` -#### FZF_TAB_CUSTOM_COMPLETIONS - -Whether to search for custom completion functions. Default value: `1` - -#### FZF_TAB_CUSTOM_COMPLETIONS_PREFIX - -Default value: `"_fzf_complete_"` - -note: The default value matches fzf name convention so that the same functions can be used both by fzf and fzf-tab. - ## Difference from other plugins fzf-tab doesn't do "complete", it just shows your results of the default completion system. diff --git a/fzf-tab.zsh b/fzf-tab.zsh index 2770a98..e23f4f7 100644 --- a/fzf-tab.zsh +++ b/fzf-tab.zsh @@ -85,8 +85,6 @@ _fzf_tab_remove_space() { : ${FZF_TAB_SHOW_GROUP:=full} : ${FZF_TAB_NO_GROUP_COLOR:=$'\033[37m'} : ${FZF_TAB_CONTINUOUS_TRIGGER:='/'} -: ${FZF_TAB_CUSTOM_COMPLETIONS:='1'} -: ${FZF_TAB_CUSTOM_COMPLETIONS_PREFIX:='_fzf_complete_'} : ${(A)=FZF_TAB_QUERY=prefix input first} : ${(A)=FZF_TAB_SINGLE_GROUP=color header} : ${(A)=FZF_TAB_GROUP_COLORS=\ @@ -97,7 +95,7 @@ _fzf_tab_remove_space() { (( $+FZF_TAB_OPTS )) || FZF_TAB_OPTS=( --ansi # Enable ANSI color support, necessary for showing groups - --expect='$FZF_TAB_CONTINUOUS_TRIGGER' # For continuous completion + --expect='$FZF_TAB_CONTINUOUS_TRIGGER' # For continuous completion '--color=hl:$(( $#headers == 0 ? 108 : 255 ))' --nth=2,3 --delimiter='\x00' # Don't search FZF_TAB_PREFIX --layout=reverse --height='${FZF_TMUX_HEIGHT:=75%}' @@ -308,29 +306,7 @@ _fzf_tab_complete() { zle -C _fzf_tab_complete complete-word _fzf_tab_complete -# note: this function is called with user options -_fzf_tab_try_custom_completion() { - # do not steal fzf's completions - [[ $LBUFFER != *"${FZF_COMPLETION_TRIGGER-**}" ]] || return - local func prefix lbuf - () { - emulate -L zsh - local tokens=(${(z)LBUFFER}) - func=${FZF_TAB_CUSTOM_COMPLETIONS_PREFIX}${tokens[1]} - (( $+functions[$func] )) || return - if [[ $LBUFFER == *' ' ]]; then - lbuf=$LBUFFER - else - prefix=$tokens[-1] - lbuf=${LBUFFER:0:-$#prefix} - fi - } || return - # must run with user options; don't add `emulate -L zsh` above this line - "$func" "$lbuf" || true -} - fzf-tab-complete() { - (( ! FZF_TAB_CUSTOM_COMPLETIONS )) || ! _fzf_tab_try_custom_completion || return 0 # complete or not complete, this is a question # this name must be ugly to avoid clashes local -i _fzf_tab_continue=1 _fzf_tab_should_complete=0