zdharma-continuum / zinit

🌻 Flexible and fast ZSH plugin manager
MIT License
3.1k stars 128 forks source link

Initial version of an idea – an on demand plugin-id completor and #331

Closed psprint closed 1 year ago

psprint commented 2 years ago

PR provides an Initial version of an idea – an on demand plugin-id completor and verifier. One will be able to do, e.g.:

zinit fzf<Alt>-a » zinit junegunn/fzf
zinit cd rip<Alt>-a » zinit cd BurntSushi/ripgrep
zinit cd tmux/tmux<Alt>-v » "tmux/tmux" highlighted in blue
                          » or red, depending on existence  of such
                          » plugin on the disk

and so on. The <Alt>-a and <Alt>-v shortcuts work with ALL commands, regardless if it's zinit command or not.

Two autoloaded functions are added, ziactioncomplete (the proper implementation of the main features) and ziprocessbuffer (a very useful library function that takes care of $BUFFFER/$CURSOR processing), which is little uncommon for zinit (to use autoloading mechanism by the plugin manager itself).

Description

I'm looking for some ideas of what else interesting can be done by editing of command line by a widget function hooked to a key binding.

Motivation and Context

It solves particular problem of problematic, lengthy plugin-id entering... Completion doesn't support for-syntax, so big win here. Also, I think that action-complete has better responsiveness than regular completion (in the scenarios that it also works, like cd subcommand).

Related Issue(s)

How Has This Been Tested?

Types of changes

Checklist:

psprint commented 2 years ago

Introducing cycling and ice-completion (<Alt>-i).

Cycling will allow to choose a particular match, say for, e.g.:

zinit at<Alt-i> » zinit atclone<Alt-i> » zinit atinit<Alt-i> »
         » zinit atload<Alt-i> » zinit atpull<Alt-i> »
         » zinit run-atpull<Alt-i> » zinit atclone"

It works for plugin-id completion in the same way, i.e.: <Alt-a> cycles through the matches.

For ices, the value of the ice is preserved, e.g.:

  zinit at'./configure'<Alt-i> » zinit atclone'./configure'<Alt-i> »
               » zinit atinit'./configure'<Alt-i> »
               » etc.
psprint commented 2 years ago

@vladdoster Hi. Did you maybe tried the feature? You can easily switch to the PR via the @tj / git-extras git pr {PR num} [remote] command. Its coding style leaves much objections but it just works.

psprint commented 2 years ago

I've resolved conflicts. A small video: https://asciinema.org/a/VkIE2I7MfCoaaIh2mPxG6LLep

psprint commented 2 years ago

Presentation: https://asciinema.org/a/OQdu6fPXkEEqG67J7oNhGoVEv

psprint commented 2 years ago

@vladdoster I've simplified the code, there are no autosuggestions workarounds now

psprint commented 1 year ago

I'm closing because the feature is mature at #406.