zimfw/completion

`Tab` on the empty `BUFFER`

kaznovac opened this issue ยท 2 comments

Is your feature request related to a problem? Please describe.
Pressing Tab (^I) on the empty (and/or whitespaces only) BUFFER just prints the Tab character.
note: BackTab from input module works as expected

Describe the solution you'd like
Run the completer as is, or maybe offer to configure something like magic-enter or navi

Describe alternatives you've considered
I've added this to .zshrc but it does not feel as well integrated as the rest of the ZIMFW (e.g. cannot move through the files - might make sense when there are some suffix aliases).

# complete on initial tab
zstyle ':completion:*' insert-tab false
# do not ask when menu should scroll
export LISTMAX=-1
#zstyle ':completion:*' list-prompt ''
#zstyle ':completion:*' select-prompt ''

function expand-or-complete-or-list-files() {
    if [[ -z ${BUFFER} ]]; then
        BUFFER="ls "
        CURSOR=3
        zle list-choices
        zle backward-kill-word
    else
        zle expand-or-complete
    fi
}
zle -N expand-or-complete-or-list-files
bindkey '^I' expand-or-complete-or-list-files

Additional context
macos terminal

ericbn commented

Hey @kaznovac. ๐Ÿ‘‹

I totally agree with you on the insert-tab false. Having the TAB inserted is annoying and has little to no purpose.

I don't think I like the export LISTMAX=-1 (or the list-prompt '') for a minimal configuration. See zimfw/zimfw#248. Maybe for users annoyed by this, setting up fzf to do a fuzzy find of the completion options seems like a better choice, using Aloxaf/fzf-tab for example. There's also the super carefully done marlonrichert/zsh-autocomplete.

I'm not sure about the completion of filenames on the empty buffer (I'm curious to see if there's a simpler implementation that uses the _files bindable command directly though, as my main hobby with Zim is figuring our simpler implementations with Zsh code... ๐Ÿ˜„). On the other hand, leaving the insert-tab false alone and allowing a completion on everying when the buffer is empty might be too much, yeah.

Hi @ericbn
Thanks for looking into this :)

As a user I find TAB behavior surprising (inconsistent), one would expect that the TAB should traverse menu in similar manner on the empty BUFFER as the Shift+TAB but in reverse order. I've tried the approach above, but I'm not experienced with the ZLE widgets.

Thanks for alternatives, I've tried the fzf (and it's alternative skim - off-topic: rust is amazing language) before but it didn't stick; as I prefer my shell enhancement utilities written in the shell. The zsh-autocomplete is new to me, nicely written for sure, but I find the zimfw/completion && zsh-users/zsh-history-substring-search do a better job (less visual clutter as I type)

List prompt/pager is just minor annoyance unrelated to this, and probably should be left to the user to configure.

I'm not sure about the completion of filenames on the empty buffer (I'm curious to see if there's a simpler implementation that uses the _files bindable command directly though, as my main hobby with Zim is figuring our simpler implementations with Zsh code... ๐Ÿ˜„).

Looking forward to this, even better if I can help :D

On the other hand, leaving the insert-tab false alone and allowing a completion on everying when the buffer is empty might be too much, yeah.

Maybe something like zimfw/magic-enter