zinit icon indicating copy to clipboard operation
zinit copied to clipboard

[feat]: New syntax `zinit [glob. ice] (loc. ice Pl.Id) (...) ...

Open psprint opened this issue 3 years ago • 0 comments

If the feature solves a problem you have, specify it here.

I think that such syntax would be more tightly defined than currently available for syntax, because for syntax is more loose - it actually cannot be fully defined because it relies on:

  • object ids being different from ice names; so if someone somehow defines a plugin called wait the syntax will fail.

The new syntax doesn't have this problem. It also clearly denotes ranges of the ice mods activity, while for syntax doesn't do this in any way. For example, a for syntax with global and local ices for 2 plugins could look like this:

zi wait lucid for from"gh-r" A/B extract null C/D

In above example wait and lucid are active on both A/B and C/D plugins, while from"gh-r" is active only on A/B and extract null only on C/D. However, these ranges aren't clearly visible because they aren't denoted in any way. The new syntax would look like this:

zi wait lucid (from"gh-r" A/B) (extract null C/D)

what is clearly a more readable instruction.

Describe the proposed feature.

The feature is a new, optional syntax defined as:

zinit {global ices} ({local ices} plugin/snippet-ID) ({...} ...) ...

Global ices are active for all objects from the command, while local ices are active only for object given at the end of the round parenthesis. A boundary case is when only a single object is given, which leads to a correct, expected form:

zinit {global ices} (object-ID)
# Example
zinit wait lucid extract make (vim/vim)

And it can be also considered an improvement for currently available syntaxes, because of the parentheses nicely surrounding object denoting it.

Describe alternatives you've considered

I've also considered a syntax similar to for -- a with syntax:

zinit vim/vim with wait lucid extract make'install'
# Multi-object
zinit wait lucid \
          vim/vim with extract make'install' \
          junegunn/fzf with from"gh-r"

However it suffers from the same problems as for and it can be seen from the need of proper indenting for readability.

Additional context

I'm not sure if a new issue should be created for this small change located in the same area of the code -- support for as special modifier that would replace id-as like follows:

# Current syntax
zi id-as'latest-vim' wait lucid make extract for vim/vim
# New syntax
zi wait lucid make extract for vim/vim as latest-vim
# New syntax + the parens-syntax
zi wait lucid make extract (vim/vim as latest-vim)
# All extensions / 2 objects
zi wait lucid make extract (vim/vim as latest-vim) (junegunn/fzf-bin as fzf)

Related Issues

No response

psprint avatar May 23 '22 12:05 psprint