feat: add completions ice (#417)

This can be used to overwrite `as'null'`, which would otherwise not trigger
completion detection and installation.

It will override the `nocompletions` ice when both are specified (e.g., using
the default ice annex).
This commit is contained in:
Jan Katins 2022-12-05 14:21:28 +01:00 committed by GitHub
parent cfd3261892
commit 59975d70d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 7 deletions

View file

@ -734,6 +734,7 @@ ### Completions<a name="completions"></a>
| :-------------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `blockf` | <div align="justify" style="text-align: justify;">Disallow plugin to modify `fpath`. Useful when a plugin wants to provide completions in traditional way. Zinit can manage completions and plugin can be blocked from exposing them.</div> |
| `nocompletions` | <div align="justify" style="text-align: justify;">Don't detect, install and manage completions for this plugin. Completions can be installed later with `zinit creinstall {plugin-spec}`.</div> |
| `completions` | <div align="justify" style="text-align: justify;">Do detect, install and manage completions for this plugin. Overwrites `as'null'` or `nocompletions`.</div> |
### Command Execution After Cloning, Updating or Loading<a name="command-execution-after-cloning-updating-or-loading"></a>

View file

@ -184,7 +184,7 @@ ____
Downloads snippet
file with curl, wget, lftp or lynx,
directory, with Subversion when svn-ICE is active.
directory, with Subversion when svn-ICE is active.
Github supports Subversion protocol and allows to clone subdirectories.
This is used to provide a layer of support for Oh-My-Zsh and Prezto.
@ -792,7 +792,7 @@ ____
`#compdef <names ...>'
____
Has 549 line(s). Doesn't call other functions.
Has 573 line(s). Doesn't call other functions.
Uses feature(s): _autoload_, _bindkey_, _compdef_, _compdump_, _eval_, _read_, _setopt_, _unfunction_, _zle_, _zstyle_

View file

@ -1459,7 +1459,7 @@ ____
`#compdef <names ...>'
____
Has 549 line(s). Doesn't call other functions.
Has 573 line(s). Doesn't call other functions.
Uses feature(s): _autoload_, _bindkey_, _compdef_, _compdump_, _eval_, _read_, _setopt_, _unfunction_, _zle_, _zstyle_

View file

@ -50,3 +50,18 @@
assert $state equals 0
assert "$ZPLUGINS/test---make/whatever" is_file
}
@test 'completions' {
run zinit as"null" id-as"test/completions" atclone"touch _whatever" completions for zdharma-continuum/null
assert $state equals 0
assert "$ZPLUGINS/test---completions/_whatever" is_file
assert "$ZINIT[COMPLETIONS_DIR]/_whatever" is_file
}
# If both are given, the completions wins
@test 'completions-overwrite' {
run zinit as"null" id-as"test/completions-overwrite" atclone"touch _whatever2" nocompletions completions for zdharma-continuum/null
assert $state equals 0
assert "$ZPLUGINS/test---completions-overwrite/_whatever2" is_file
assert "$ZINIT[COMPLETIONS_DIR]/_whatever2" is_file
}

View file

@ -500,7 +500,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
# After additional executions like atclone'' - install completions (1 - plugins)
local -A OPTS
OPTS[opt_-q,--quiet]=1
[[ 0 = ${+ICE[nocompletions]} && ${ICE[as]} != null && ${+ICE[null]} -eq 0 ]] && \
[[ (0 = ${+ICE[nocompletions]} && ${ICE[as]} != null && ${+ICE[null]} -eq 0) || 0 != ${+ICE[completions]} ]] && \
.zinit-install-completions "$id_as" "" "0"
if [[ -e ${TMPDIR:-/tmp}/zinit.skipped_comps.$$.lst || -e ${TMPDIR:-/tmp}/zinit.installed_comps.$$.lst ]] {
@ -913,7 +913,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
# FUNCTION: .zinit-download-snippet [[[
# Downloads snippet
# file with curl, wget, lftp or lynx,
# directory, with Subversion when svn-ICE is active.
# directory, with Subversion when svn-ICE is active.
#
# Github supports Subversion protocol and allows to clone subdirectories.
# This is used to provide a layer of support for Oh-My-Zsh and Prezto.
@ -1339,7 +1339,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
# After additional executions like atclone'' - install completions (2 - snippets)
local -A OPTS
OPTS[opt_-q,--quiet]=1
[[ 0 = ${+ICE[nocompletions]} && ${ICE[as]} != null && ${+ICE[null]} -eq 0 ]] && \
[[ (0 = ${+ICE[nocompletions]} && ${ICE[as]} != null && ${+ICE[null]} -eq 0) || 0 != ${+ICE[completions]} ]] && \
.zinit-install-completions "%" "$local_dir/$dirname" 0
if [[ -e ${TMPDIR:-/tmp}/zinit.skipped_comps.$$.lst || -e ${TMPDIR:-/tmp}/zinit.installed_comps.$$.lst ]] {

View file

@ -69,7 +69,7 @@ fi
ZINIT[ice-list]="svn|proto|from|teleid|bindmap|cloneopts|id-as|depth|if|wait|load|\
unload|blockf|pick|bpick|src|as|ver|silent|lucid|notify|mv|cp|\
atinit|atclone|atload|atpull|nocd|run-atpull|has|cloneonly|make|\
service|trackbinds|multisrc|compile|nocompile|nocompletions|\
service|trackbinds|multisrc|compile|nocompile|completions|nocompletions|\
reset-prompt|wrap|reset|sh|\!sh|bash|\!bash|ksh|\!ksh|csh|\
\!csh|aliases|countdown|ps-on-unload|ps-on-update|trigger-load|\
light-mode|is-snippet|atdelete|pack|git|verbose|on-update-of|\