zinit icon indicating copy to clipboard operation
zinit copied to clipboard

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

Open psprint opened this issue 2 years ago • 2 comments

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

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [ ] I have added tests to cover my changes.
  • [ ] All new and existing tests passed.

psprint avatar Jul 06 '22 13:07 psprint

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 avatar Jul 06 '22 18:07 psprint

@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 avatar Jul 19 '22 14:07 psprint

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

psprint avatar Sep 29 '22 14:09 psprint

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

psprint avatar Sep 30 '22 14:09 psprint

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

psprint avatar Sep 30 '22 14:09 psprint

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

psprint avatar Dec 29 '22 10:12 psprint