Giter Site home page Giter Site logo

marlonrichert / zsh-autocomplete Goto Github PK

View Code? Open in Web Editor NEW
4.8K 25.0 140.0 4.33 MB

๐Ÿค– Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.

License: MIT License

Shell 100.00%
zsh completion autocomplete zsh-autocomplete zsh-plugin zsh-completion asynchronous autocompletion non-blocking zsh-plugins

zsh-autocomplete's Introduction

Do you use my software on a regular basis? Please consider sponsoring me. ๐Ÿ’

To advertise with me or get in touch with me otherwise, please open an issue here.

zsh-autocomplete's People

Contributors

3xploiton3 avatar aaronkollasch avatar alfredjkwack avatar cscribn avatar deathbeam avatar gordiandziwis avatar jaakkonen avatar jg-byte avatar jv-k avatar loichyan avatar marlonrichert avatar mordna avatar stefanlobbenmeier avatar vinnymeller avatar vxio avatar yuruihong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zsh-autocomplete's Issues

Expansion from CTRL+SPACE error with fuzzy file search

Hi,

Thanks for your work on this plugin. I cannot get the expansion to work using ctrl space as I get this error message:

_autocomplete.expand-or-complete.zle-widget:43: maximum nested function level reached; increase FUNCNEST?
_p9k_widget_zle-line-pre-redraw:43: maximum nested function level reached; increase FUNCNEST?

For example, ctrl-space alone works (directory selection) but vim (space) ctrl-space shows the error.
Vim ** then ctrl-T works as ctrl-space should.

Here are the FZF options:

FZF_COMPLETION_TRIGGER='**'
FZF_DEFAULT_COMMAND='ag --hidden --ignore-dir /RetroPie/ -g ""'
FZF_DEFAULT_OPTS='--bind=ctrl-space:abort,ctrl-k:kill-line'

Is there something I'm missing?

No completion in /etc, magic space issue with sudo

Just doing cd /etc/ does not prompt me with any suggestions, even when pressing tab.
Works fine when disabling the plugin.

2nd problem (did not want to open another issue for that only):
Just type cp x y then use the arrows to go back to the beginning of the line.
Then add sudo and press space to add a real space : the cp disappears.

Precision: I have cp aliased to cp -i

Keybindings in Konsole (KDE Plasma)

Hey,

First off - amazing plugin. Seeing this on reddit yesterday made me decided to refresh my zsh setup & install this plugin.

I have an issue (which I have fixed locally, so no rush) which is that the keybindings, eg:

key[Down]='^[[B'

don't correspond to what my terminal feeds in. For each of down, up, left, right, I had to swap the second '[' for a capital O. Not sure why this is the case.

breaks fzf kill/ssh/.. completion

fzf has some special completions defined (see completion.zsh), e.g. for "kill -9 [TAB]" it uses ps to list the processes. With zsh-autocomplete that list is broken.

Foolproof: add more warnings if plugins are put in a wrong order

This plugin requires that fzf (and accompanied ~/.fzf.zsh) must precede zsh-autocomplete.

Though it was mentioned in README, I don't think it was not emphasized enough. It would be great to have a fool-proof feature such that if an user have wrong ordering in their zshrc, a warning message would be printed (or disable the plugin).

Otherwise it would mess up everything: for example, any keypress of <TAB> will ALWAYS invoke fzf, make the shell almost unusable.

Odd key behavior

Hello,
Upon first installation, this plugin runs like a dream. Rebooting my terminal (I'm using Kitty), there is very erratic behavior. It's almost like the it's stuck in a hotkey mode. For example:
I want to type "sudo".
S: Just fine
u: is ignored (letter is not typed)
d: "do you want to display all 348 results?
o: same as above
spacebar: same as above.

I'm guess it's mistaking each key press for tab? Sorry if this doesn't make sense...I don't know a better way to explain it.

Running Kubuntu 20.04.

Not able to change directories without cd.

Not able to cd to a directory without cd, permission denied.
Without plugin.
tanish@us01:tanish/tanish_main1
โ–ถ IOR
tanish/tanish_main1/IOR

With plugin.
tanish@us01:tanish/tanish_main
โ–ถ IOR
zsh: permission denied: IOR

Super slow git remote completion

When I use git and do stuff like adding a remote or clone from remote, when start to type the https or ssh location, the input becomes super slow. Often does nothing happen anymore and then all keystrokes are applied at once. This happens always and is quite annoying. Can I disable that? I don't necessarily need completion for the remote location paths.

History expansions are mostly unusable due to premature auto-expansion

This plugin's immediate auto-expansion of history expansions causes the latter to be mostly unusable. Some examples are detailed below. The overarching theme is that history expansions should only be auto-expanded if they are unambiguous, where "ambiguous" is meant in the sense that the already typed history expansion could possibly be altered by further characters that have yet to be typed.

Such yet-to-be-typed characters could add a word designator (e.g. :1 after !!), alter a word designator (e.g. -2 after !:1), or add modifiers (e.g. :a after !$). Generally speaking, it is unknown whether a history expansion has been fully typed unless it uses the !{โ€ฆ} form or until a character is typed that does not further alter the expansion.

Perhaps a more usable approach would be to nix the current behavior and instead perform history auto-expansion as part of magic-space and/or a separate expand-under-the-cursor key-binding.

Example: !-2

If I want to expand the second-to-last command (or any part of it, using additional word designators), I would normally type !-2. However, history auto-expansion is invoked immediately after typing !-, which obviously fails, thereby causing the ! to be deleted, leaving the command line as if one had only typed -.

Of course, this problem applies likewise to any other intended event designator of the form !-n.

Example: !:1-2

If I want to insert the first two arguments of the last command, I would normally type !:1-2 or, equivalently, !!:1-2 or !-1:1-2. However, history auto-expansion is invoked immediately after typing !:1 or !! or !-, in all cases preventing the possibility of typing what was intended.

Numerous other examples can be found that follow this pattern, whereby one intends to use other word designators and/or history expansion modifiers. In all cases, the intended expansion is made impossible by premature auto-expansion.

Example: !#:1

If I want to reference the first argument of the currently-being-typed command, I would normally type !#:1. However, history auto-expansion is invoked after typing !#, thus expanding to the entire already-typed command (up to the previous word, inclusive).

Highlight flickering with zsh-autosuggestions after spaces

I use this plugin combined with zsh-autosuggestions. I observed that since using this plugin the highlighting for the autosuggestion flickers. So while typing I see as usual the autosuggestion command in the configured color (usually kinda decent colored). But then it starts to flicker. So it looks like a regular command. It becomes hard to tell that I not simply accepted this suggestion. Continue to type often restores the actual highlighting.

I must admit that my knowledge of all the background is minimal. So I wonder if you maybe have an idea why this happens. I can confirm that if I disable this plugin here temporally, the highlighting works fine.

setopt/unsetopt

The plugin isn't the right place to change setopts, especially something like AUTO_CD and BEEP.

Please use LOCAL_OPTIONS or even emulate -L zsh, so you can explicitly define needed option in functions without touching user configuration.

Let user choose case sensitivity behaviour

Installing plugin seem to mess with zsh options about case insensitive completions. It would be great if user could decide about this feature in personal configuration or better yet if it could be done old way with plain zsh functionality. Perhaps it is possible, but i couldn't figure it out. Not sure if it's a bug or is it simply not implemented.
Maybe it's the matter of command order in zsh dotfiles? Many plugins have specific rules about that.
I'm using this plugin along with zsh-autosuggestions, zsh-completions, zsh-syntax-highlighting and fzf and i don't have any manager.

zle-line-finish

when running a command like which fzf (might be with any command), no shell function 'zle-line-finish' exists flashes up then is erased and a blank prompt comes up. I have turned off my whole init file then back on, the behavior persists.

_zsh_autosuggest_highlight_reset:3: maximum nested function level reached

On every prompt I get

_zsh_autosuggest_highlight_reset:3: maximum nested function level reached; increase FUNCNEST?

Here is my zshrc

fpath=($fpath "$ZDOTDIR/plugins/pure")
promptinit
prompt pure
source "$ZDOTDIR/plugins/syntax-highlighting/zsh-syntax-highlighting.zsh"
source "$ZDOTDIR/plugins/autosuggestions/zsh-autosuggestions.zsh"
source "$ZDOTDIR/plugins/autocomplete/zsh-autocomplete.zsh"

If I set prompt after sourcing autocomplete all is ok

Don't break when sourced more than once

This occurs whenever I source my ~/.zshrc with this plugin

โฏ zshreload
_autocomplete.add-zsh-hook:1: job table full or recursion limit exceeded
 ๏Œƒ ๎‚ฐ ๏€• ~ ๎‚ฐ                                                                                                                                   ๎‚ฒ โœ” ๎‚ฒ 12:59:36 ๏€— 
 ๏Œƒ ๎‚ฐ ๏€• ~ ๎‚ฐ e_main_complete:208: command not found: 3174                                                                                      ๎‚ฒ โœ” ๎‚ฒ 12:59:39 ๏€— 
_main_complete:208: command not found: 3174
_main_complete:208: command not found: 3174
_main_complete:208: command not found: 793
_main_complete:208: command not found: 793
_main_complete:208: command not found: 793
_main_complete:208: command not found: ''
_main_complete:208: command not found: ''
_main_complete:208: command not found: ''
e_main_complete:208: command not found: 3174
_main_complete:208: command not found: 3174
_main_complete:208: command not found: 3174
_main_complete:208: command not found: 793
_main_complete:208: command not found: 793
_main_complete:208: command not found: 793
_main_complete:208: command not found: ''
_main_complete:208: command not found: ''
_main_complete:208: command not found: ''
e

My .zshrc

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
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

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="/home/shash/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="powerlevel10k/powerlevel10k"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
#CASE_SENSITIVE="true"
#complete setup zsh | source /dev/stdin
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"

# Uncomment the following line to change how often to auto-update (in days).
export UPDATE_ZSH_DAYS=1

# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS=true

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

#source /usr/share/fzf/completion.zsh
#source /usr/share/fzf/key-bindings.zsh
# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
zsh-syntax-highlighting
git
fzf
zsh-autosuggestions
zsh-autocomplete
docker
npm
yarn
history-substring-search
zsh-completions
encode64
pip
pyenv
python
sudo
autoupdate
)

source $ZSH/oh-my-zsh.sh
export QT_QPA_PLATFORMTHEME=qt5ct
# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
export LANG=en_GB.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
alias weather="curl wttr.in/Cardiff"
alias zshreload="source ~/.zshrc"
#export EDITOR="nano"
# Completion for kitty
kitty + complete setup zsh | source /dev/stdin

#autoload -Uz compinit
#compinit

autoload -U compinit && compinit
# Import colorscheme from 'wal' asynchronously
# &   # Run the process in the background.
# ( ) # Hide shell job control messages.
#(cat ~/.cache/wal/sequences &)
# Alternative (blocks terminal for 0-3ms)
#cat ~/.cache/wal/sequences
# To add support for TTYs this line can be optionally added.
#source ~/.cache/wal/colors-tty.sh
(cat $HOME/.config/wpg/sequences &)

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

Async update causes flood of errors.

As mentioned in #28 by @weilbith,
In the latest update has problem where
_autocomplete.async-list-choices:30: command not found: zpty โ”€โ•ฏ _autocomplete.async-list-choices:31: command not found: zpty
floods the console
I, also I should note that it doesn't actually prevent you from typing commands so you can just enter another shell and resolve the issue temporarily by rolling back the update.
Failing that you can always switch to another user and change the shell/sudo.

Option to not show results until N characters or Space input

Typing one character results in a horrible list of suggestions that flashes briefly at the start of every command

image

It's a minor grievance, but this flash looks pretty ugly and is a little annoying. I strongly suspect no one types one character and then auto-completes anyway, unless they use some kind of auto-cd feature.

An option to disable suggestions until for instance two characters or space has been typed could stop this ugly suggestion flood.

It doesn't need to be very sophisticated and edge cases like type two characters -> erase one could just be ignored, it's mostly the initial flash at every command that annoys me.

Ctr+Space _autocomplete.async_callback:11: bad math expression: illegal character: '

To repoduce:
"ls [Ctrl+Space]"
-> _autocomplete.async_callback:11: bad math expression: illegal character: '

Minimal .zshrc to repoduce:

Added by Zinit's installer

if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
print -P "%F{33}โ–“โ–’โ–‘ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma/zinit%F{220})โ€ฆ%f"
command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
command git clone https://github.com/zdharma/zinit "$HOME/.zinit/bin" &&
print -P "%F{33}โ–“โ–’โ–‘ %F{34}Installation successful.%f%b" ||
print -P "%F{160}โ–“โ–’โ–‘ The clone has failed.%f%b"
fi

source "$HOME/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit

End of Zinit's installer chunk

source /usr/share/fzf/shell/key-bindings.zsh
zinit load marlonrichert/zsh-autocomplete

TODO: Asynchronous `list-choices`

Not sure if it will actually improve performance, since of all the completion code, it's the calls to compadd that cause the most overhead, and those need to happen in the main thread, to update the completion menu. I already tried it once and didn't succeed. However, the automatic list-choices code is quite a bit different now than originally. So, I might try to give it another go at some point.

Asynchronous feature stopped plugin from working

Hey ๐Ÿ‘‹

Thanks again for your continuous work. Especially the asynchronous feature makes this plugin a must-have! Unfortunately it does not work anymore for me. Which means it does not appear automatically anymore, but I must trigger the suggestions manually with tab again. Note that I configured the plugin to use tab and also do the suggestions appear grouped, as I also configured for this plugin. So the plugin is still there and somehow working. But not automated anymore.

So my local version is on commit 0260d55 which is the HEAD@master here on GitHub for the moment. I tried to do a minimized setup, but this fails already. So how do I try to achieve a minimal testing environment for reproducibility:

> zsh -d -f  # zsh without any configuration
host% source $XDG_CACHE_HOME/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-marlonrichert-SLASH-zsh-autocomplete/zsh-autocomplete.plugin.zsh
host% fpath+=($XDG_CACHE_HOME/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-marlonrichert-SLASH-zsh-autocomplete)
host% cd ~/  # expect auto completion here

Of course can the location of the plugin differ. Since I use antibody as my zsh plugin manager that's how it looks for me. Anyways I load the plugin manually here, doing the same as antibody would do. The point is, that already the source command fails with the error message (eval):1: _autocomplete.add-zsh-hook: function definition file not found. I guess that's bad. ๐Ÿ˜‚
So if we could make it to fix this minimized setup, then I could continue to checkout if something else in my custom setup affects this problem.

Thank you so much in advanced. I want to experience the asynchronous completion
myself!!!!

How to enhance change directory completion sources

Describe the solution you'd like

I'm using the tool fasd to access frequently used directories and files faster without providing the full path. If I use the fasd command directly, I get beautifully auto-completion of its results while I type. It would be awesome if I could get these candidates as another group in the completion menu when using cd for directories and files for an editor like vim or similar commands.

Describe alternatives you've considered

Currently I have a mapping that I need to trigger manually. It calls fzf with the list of currently available results by fasd for the current input text. I then filter the results in fzf, select and entry, get back to the command line and then continue.
Could be improved...

Additional context

This plugin is awesome. So is fasd. Hope to get them combined on a new level. ๐Ÿ˜‰

Insert longest common prefix

Matches are presented in lexicographical order with no regard to the accuracy of the matches.

I would expect suggestions starting with my input to be prioritized over a match in a substring.

This interferes with the behavior of the tab key, as compared to in the normal shell experience. I would expect tab to first insert perfect matches starting with what I've typed, and not the first match in lexicographical order.

Steps to reproduce:

โžœ  cat test
atestfile  testfile
\t
โžœ  cat atestfile

Expected behavior:

โžœ  cat test
testfile  atestfile
\t
โžœ  cat testfile

zsh-autocomplete overrides fzf configuration

First of all, thanks for the amazing completion experience with this plugin!

I'm trying this out now and found out it exports $FZF_* environment variables which override my customisations to fzf. I'm wondering why is it doing so and if it's needed โ€” maybe it can be scoped to the plugin's usage of fzf somehow?

Hidden files ignored by auto-suggest / leading dot ignored

Hidden files are ignored or downprioritized by auto-suggest. Typing the name of a dotfile will match that part against substrings in other filenames, but not exact matches of dotfiles.

Steps to reproduce:

โžœ touch .test file.test
โžœ rm .tes
file.test
โžœ \t
โžœ rm file.test

Expected:

โžœ touch .test file.test
โžœ rm .tes
.test file.test
โžœ \t
โžœ rm .test

can not change current directory without "cd"

Hi, I fail to change any directories without "cd"

โฏ source ~/.oh-my-zsh/custom/plugins/zsh-autocomplete/zsh-autocomplete.plugin.zsh
โฏ ~
zsh: permission denied: /home/user
โฏ cd ~
...

Is there any thing wrong with my operations, or is this a bug?

Work better with history-substring-search-up/down

Is your feature request related to a problem? Please describe.

Because zsh-autocomplete sets zstyle ':zle:up/down-line-or-beginning-search' leave-cursor no, it is awkward to use with up/down arrow keys bound to history-substring-search-up/down. When typing the up arrow, the cursor does not move to the end of the line.

% zsh -df
% source path/to/zsh-autocomplete.plugin.zsh
% autoload up-line-or-beginning-search
% zle -N up-line-or-beginning-search
% autoload down-line-or-beginning-search
% zle -N down-line-or-beginning-search
% bindkey "^[OA" up-line-or-beginning-search
% bindkey "^[OB" down-line-or-beginning-search
% zโ†‘

Describe the solution you'd like

Some way of getting prefix history search to move the cursor to the end of line while still working with zsh-autocomplete.

Describe alternatives you've considered

Setting zstyle ':zle:up/down-line-or-beginning-search' leave-cursor yes does not work, because after pressing up once, the search prefix (apparently) becomes the whole line.

% zstyle ':zle:up-line-or-beginning-search' leave-cursor yes
% bโ†‘โ†‘

Update the Asciinema video

The video that's currently in the Readme doesn't accurately reflect the latest behavior. I will create a new one when I have time.

Order and jump completion groups

Just some new ideas to make this plugin even better as it is already.

I like to use the group option for the suggestion menu (disabled by default, zstyle ':autocomplete:*' groups 'always'). It looks more nice (personal opinion) and makes it more structured, understanding the suggestions even faster. The point is: sometimes I like to redorder the groups or jump between them. I must admit that I'm not too sure about the order I would like to set, but I would really appreciate the option to change it and tweak it over time, until I it works the best for me. So maybe sort directories over files is more convenient for my daily work. Not sure.
Nevertheless if I would find a good sort order, it would be absolutely awesome if I could jump between the groups. Continuing with the simple example of directories and files. And I know that I want to complete a directory, then I have to first iterate over all suggested files. Rather I would jump to the next group and then iterate through them. Maybe you are limited by zsh, I don't know. Maybe this is already natively supported and you must just teach us.

No matter the result, I love the plugin and every new feature makes it just a bigger work boost for a daily shell enthusiast.

Slow apt completion

Awesome work you are doing, not a real issue but an improvement suggestion which would benefit the plugin I guess.

I noticed that when I type sudo apt install, and then the first 2 to 5 first letters of a package, the completion is really slow (which is normal, lots of packages exists).

The issue is that the input is lagging and therefore I cannot see what I type in real time, I have to wait a bit to check what I wrote.

This might be related to #17 and #24 , for the async part.

(btw I tried disabling completion for apt but did not succeed)

  • I did not find a /usr/share/zsh/functions/Completion/Unix/_apt
  • I tried adding
    zstyle ':completion:(correct-word|list-choices):*:(pacman|trizen):argument-rest:*' tag-order "! argument-rest" "-"
    to my zshrc but did not change anything

Would be neat to enable async list-choices for a few commands though :) for those heavy completion cases.

Closing termnial window when pressing arrow up

This must have changed at some point today since I updated the plugin this evening, but when pressing the up arrow to attempt to cycle through my history, the terminal window closes instead.

On OSX using both iTerm and the terminal bundled with rubymine.

Tab character in completion can corrupt menu

Describe the bug

My .gitconfig uses tabs for indentation, and contains a multiline alias (for git push-status). Because of this, the autocomplete menu item for git push-status contains a tab and zsh-autocomplete does not cut off the entry before the end of line.

To Reproduce

Steps to reproduce the behavior:

% zsh -df
% source path/to/zsh-autocomplete.plugin.zsh
% cat <<. >>~/.gitconfig
[alias]
        # Show the status of this branch relative to @{push}.
        # When copying from the GitHub issue, be sure to replace those eight spaces with a tab character. :-)
        push-status = "! push_branch=$(git push-branch 2>/dev/null) || { echo \"No push branch set.\" && exit 0; } \
          ; both=$(git rev-list --left-right --count HEAD...@{push}) \
          ; [[ $both == '0    0' ]] && echo \"Your branch is up to date with push branch $push_branch.\" \
          || echo \"Your branch is ${both%%   *} commit(s) ahead and ${both##*    } commit(s) behind push branch $push_branch.\" #"
.
% git push-sta|  <-- cursor

Expected behavior

The autocomplete menu to be rendered correctly.

"Screenshot"

๏€•  ~ ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท ๏€— 10:32:01
โฏ git sta
ingit sta
push-status  alias for '! push_branch=$(git push-branch 2>/dev/null) || { echo "No push branch set." && exit 0; }         ; both=$(gi
stash        stash away changes to dirty working directory
status       show working-tree status

Desktop

  • OS + distribution: Ubuntu 20.04
  • Zsh version: 5.8
  • Plugin version: 33d9812

Additional context

I am actually not sure how to determine the line length in the case of tabs. So maybe this is an unsolvable problem and the answer is "just don't use tabs in your .gitconfig in combination with multiline aliases".

Path completion includes './', '../' and invalid paths cause red text

Hey,
thanks for your contentiously great work. Your recent contribution make this plugin a real pleasure for daily work!
This issue here is nothing big and does not hinder the daily work. It includes two parts. But they are both pretty small and somewhat related, so I decided to make both into one.
The first are the path completion candidates ./ and ../. When the last typed character for a path is a slash, these two candidates are always there. They are annoying, because they are at the top of the list and must be jumped over to get to the "actual" candidates. Especially when your path reaches a directory with only files, the only two remaining candidates are these two. I would argue that they add no value and are more confusing and annoying than helpful.
The second issue is that if I type a "invalid" path, I get red text. If I for example cd and type a directory name wrong, I see in red letters local directory. When I do something with a path that does intentionally not exist yet, it is even worse. So in zsh typing take /tmp/new_test will show me three red lines with file, directory, file or directory.
Could you maybe elaborate why it is like this and discuss about solutions? Would
be amazing. ๐Ÿ˜Š

Allow customizing warning messages

Is your feature request related to a problem? Please describe.

I would like to be able to customize the messages that zsh-autocomplete outputs. In particular, I would like to make the outputs extremely terse so they produce minimal visual distraction, although this would obviously be bad UX for new users.

Describe the solution you'd like

I think it would be nice if the messages were customizable via zstyle.

Thoughts on suggestions display

Thought 1

Current behavior :
When too much suggestions, nothing is displayed. Pressing tab enables a partial list of suggestions.

Proposition :
Add a message to notify user that there is actually some suggestions but too much to fit in screen.
Something like "Too much (X) items to display."

My thoughts :
This plugin always almost displays something so it felt weird having no information on current directory content for the use case cd /usr/share/ which had a lot of stuff inside.

Thought 2

Current behavior:
Height size of suggestions list seems to be pre-determined (I suppose as a function of the terminal height) and is quite big.

Proposition :
Enable custom height of suggestions list via zstyle.
Might be a percent of terminal height, or absolute but it might be easier to implement percent.

My thoughts :
As of personnal preference, It would be great to set height of list to like 50% of terminal height so I can see more of my command history when the suggestion list is long.

Thought 3

Current behavior :
Same as thought 1 : When too much suggestions, nothing is displayed. Pressing tab enables a partial list of suggestions.

Proposition :
(Could be an option to enable)
Display a partial list of suggested items with a bottom line saying that there is more which is not displayed.

My thoughts :
Well I went into this plugin to have suggestions at all time and sometimes my terminal is too small or there is too much items to display, but I wish I add suggestions anyway.

Let's hear other users thoughts on this and tell me if something is unclear !

Enabling autodescriptions by default

This isn't so much a bug report as it is a feature request: would it be possible to have groups and autodescriptions enabled by default as opposed to having to press shift+tab each time?
An option to have it always turned on would work too

Vi mode configuration in prompt causes bindkey conflict

I use vi mode and have my prompt set up for it accordingly. Here's the relevant code:

function zle-keymap-select {
  if [[ ${KEYMAP} == vicmd ]] ||
     [[ $1 = 'block' ]]; then
    echo -ne '\e[2 q'
  elif [[ ${KEYMAP} == main ]] ||
       [[ ${KEYMAP} == viins ]] ||
       [[ ${KEYMAP} = '' ]] ||
       [[ $1 = 'beam' ]]; then
    echo -ne '\e[6 q'
  fi
}
zle -N zle-keymap-select
zle-line-init() {
    echo -ne "\e[6 q"
}
zle -N zle-line-init
echo -ne '\e[5 q' # Use beam shape cursor on startup.
preexec() { echo -ne '\e[6 q' ;} # Use beam shape cursor for each new prompt.

What this does is change the cursor from beam to block depending on the mode (beam for insert, block for normal)

If i run bindkey "^I" with that block present, i get "^I" fzf-completion as a result. If i remove it, bindkey "^I" prints "^I" complete-word.

My steps for tracking this down were creating a minimal .zshrc that only sourced fzf and the plugin, and then re-adding everything back little by little.

Simplify Customization Options

I'm really enjoying this plugin; thanks for your hard work and continued attention!

As a suggestion, it would be nice to simplify the customization options using ENV variables set in a user's .zshrc file (likely before sourcing zsh-autocomplete). Some recommended variable names:

  • Always show group names:
export ZSH_AUTOCOMPLETE_ALWAYS_SHOW_GROUP_NAMES=true
  • Turn off automatic spelling correction:
export ZSH_AUTOCOMPLETE_AUTO_CORRECT_SPELLING=true
  • Use tab to cycle matches:
export ZSH_AUTOCOMPLETE_CYCLE_WITH_TAB=true
  • Use tab and shift-tab to navigate the menu:
export ZSH_AUTOCOMPLETE_NAVIGATE_WITH_TAB=true

I could see the last two conflicting with one another, but that could be called out in the README.md.

Typying laggs due to slow completion

Hey,
thanks again for this plugin! ๐Ÿ™

I use it now just my second day, but what really bothers me are the lags. This is especially the case for paths. Each time I enter a slash it starts to lag. I guess this will apply for all completions that are not optimized or simply slow.
I must admit I have rarely a knowledge of such things in Zsh, but is is possible to do asynchronous completion? As much as I like this plugin: this is a no-go for me at the moment. Maybe I need to disable completion sources that are slow. I don't know.

space (magic-space) is too aggressive

Currently, it automatically accepts the completion when there are completions (automatically) being shown.

Say we want to type for a in 0 1 2; do. There is a.py that is file suggestion.

โฏโฏโฏ for a|     
a.py          

Pressing space here, it will accept the completion:

โฏโฏโฏ for a.py |
a.py         bin/         etc/     ...(more)

which should not be the case.

fzf trigger sequence (**) does not work as expected (even using control + space)

This is some really cool work. Thanks for sharing it!

Describe the bug

The fzf search menu no longer seems to pop up when the trigger sequence is used when zsh-autocomplete is enabled, even when using the new shortcutโ€”controlโฃ.

To Reproduce

Steps to reproduce the behavior:

% zsh -df

% [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

% cat dir/** [TAB]
>
3/3
> dir/file1.txt
> dir/file2.txt
> dir/file3.txt

% source ~/dir/dir/zsh-autocomplete.plugin.zsh

% cat dir/** [CTRL][SPACE]
file1.txt    file2.txt    file3.txt

Of course, this fixes itself if I run zstyle ':autocomplete:tab:*' completion fzf. tab is now controlled by fzf, and the trigger sequence ** works as expected. But then normal autocomplete seems broken at that point.

Expected behavior

I thought controlโฃ (with zsh-autocomplete) would trigger the kind of behaviour fzf would trigger by hitting tab normally (without zsh-autocomplete).

Desktop

  • OS + distribution: macOS 10.15.5
  • Zsh version: 5.7.1
  • Plugin version: 33d9812

Down arrow key has no effect

Just cloned this repo and added it to my zsh config (with oh-my-zsh).
All seems to work fine (I don't have fzf installed), except the Down arrow key that has no effect. So I basically have no opportunity to navigate through proposals.
I tried commenting all my other zsh plugins but same issue.

My zshrc : here.

Also it would be nice to be able to enable/disable some key bindings.
For example I would gladly disable the Tab that selects first choice to keep the zsh behavior of hitting Tab twice to enter the suggestion grid.

key: assignment to invalid subscript range

When I try to install it using zinit like this

zinit ice wait'2'
zinit load marlonrichert/zsh-autocomplete

I get this error

/Users/klas.mellbourn/.zinit/plugins/marlonrichert---zsh-autocomplete/zsh-autocomplete.plugin.zsh:87: key: assignment to invalid subscript range

I'm on commit b0edf5c

ale-line-finish

when running a command like which fzf (might be with any command), no shell function 'zle-line-finish' exists flashes up then is erased and a blank prompt comes up. I have turned off my whole init file then back on, the behavior persists.

can't clobber paremeter

I am seeing this error when almost every command I run right now. Mostly seems to be shell built ins though actually.

_autocomplete.async-list-choices:6: can't clobber parameter _autocomplete__async_fd containing file descriptor 25

zsh 5.8 (amd64-portbld-freebsd12.1
FreeBSD fluffy.lan 12.1-STABLE FreeBSD 12.1-STABLE r361783 GENERIC amd64

Using zimfw for my zshrc setup

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.