Skip to content

How to disable autosuggestion when having autocompletion selected? #767

Closed
@beyond-fu

Description

@beyond-fu

Environment

% typeset -p1 VENDOR OSTYPE ZSH_PATCHLEVEL _autocomplete__funcfiletrace
<output>
% git -C ~autocomplete log --oneline -n1
<output>
  • Operating system: Fedora41
  • Terminal emulator: Gnome47 default terminal(i.e. Ptyxis)

Steps to reproduce

% cd $(mktemp -d)
% git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
<output>
% > .zshrc <<EOF
setopt interactivecomments transientrprompt
PS1='%# '
PS2=
RPS2='%^'
source $PWD/zsh-autocomplete/zsh-autocomplete.plugin.zsh
EOF
% env -i HOME=$PWD PATH=$PATH TERM=$TERM ${TERMINFO:+TERMINFO=$TERMINFO} zsh -d
% <inputs>
<output>
Contents of ~autocomplete-log/YYYY-MM-DD.log (click to expand)

I saw this issue #576, but it seems to come up again, and changing the order of source zsh-autosuggestion and source zsh-autocompletion. I just installed the latest zsh-autosuggestion and zsh-autocompletion on Fedora41. When I select a completion candidate item, the suggusetion is still there and this is annoying. So I want to know how to make suggestion not showing when one of the completions is selected.

Before enter Tab to complete:
Screenshot From 2024-12-11 01-30-40
After completion:
Screenshot From 2024-12-11 01-30-56

Below is my .zshrc configuration:

if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

HISTFILE=~/.zsh_histfile
HISTSIZE=1000
SAVEHIST=2000
bindkey -v    
setopt autocd extendedglob nomatch
unsetopt beep notify

# Snap: zsh plugins manager
[[ -r ~/zsh_plugins/znap/znap.zsh ]] ||
    git clone --depth 1 -- \
        https://github.com/marlonrichert/zsh-snap.git ~/zsh_plugins/znap
source ~/zsh_plugins/znap/znap.zsh  # Start Znap

znap source marlonrichert/zsh-autocomplete
znap source zsh-users/zsh-autosuggestions
znap source zsh-users/zsh-syntax-highlighting

source ~/zsh_plugins/powerlevel10k/powerlevel10k.zsh-theme
. "$HOME/.cargo/env"

bindkey "^[[1;5C" "forward-word"
bindkey "^[[1;5D" "backward-word"
bindkey              '^I' menu-select
bindkey "$terminfo[kcbt]" menu-select
bindkey -M menuselect              '^I'         menu-complete
bindkey -M menuselect "$terminfo[kcbt]" reverse-menu-complete
bindkey  "^[[H"   beginning-of-line
bindkey  "^[[F"   end-of-line
bindkey  "^[[3~"  delete-char

zstyle ':autocomplete:*complete*:*' insert-unambiguous yes
zstyle ':autocomplete:*history*:*' insert-unambiguous yes
zstyle ':completion:*:*' matcher-list 'm:{[:lower:]-}={[:upper:]_}' '+r:|[.]=**'

zstyle -e ':autocomplete:*:*' list-lines 'reply=( $(( LINES / 2 )) )'
zstyle ':completion:*:messages' format $'\e[01;35m -- %d -- \e[00;00m'
zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found -- \e[00;00m'
zstyle ':autocomplete:*' ignored-input '..##'

[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions