diff --git a/plugins/zsh-patina/README.md b/plugins/zsh-patina/README.md index ec383323c..d23e79c64 100644 --- a/plugins/zsh-patina/README.md +++ b/plugins/zsh-patina/README.md @@ -4,6 +4,9 @@ Initializes [zsh-patina](https://github.com/michel-kraemer/zsh-patina), a "blazingly fast Zsh plugin performing syntax highlighting of your command line while you type 🌈" +The plugin also caches completions for the `zsh-patina` command in +`$ZSH_CACHE_DIR/completions/_zsh-patina`, refreshed each time the plugin loads. + To use it, add `zsh-patina` to the plugins array in your `.zshrc` file: ```zsh diff --git a/plugins/zsh-patina/zsh-patina.plugin.zsh b/plugins/zsh-patina/zsh-patina.plugin.zsh index bc6259ab1..6172f458b 100644 --- a/plugins/zsh-patina/zsh-patina.plugin.zsh +++ b/plugins/zsh-patina/zsh-patina.plugin.zsh @@ -2,6 +2,20 @@ if (( $+ZSH_HIGHLIGHT_VERSION )) || (( ${plugins[(Ie)zsh-syntax-highlighting]} ) echo '[oh-my-zsh] zsh-patina conflicts with zsh-syntax-highlighting, please enable only one of them' elif [[ -x ${ZSH_PATINA_BINARY:-$commands[zsh-patina]} ]]; then eval "$(${ZSH_PATINA_BINARY:-$commands[zsh-patina]} activate)" + + # If the completion file doesn't exist yet, we need to autoload it and + # bind it to `zsh-patina`. Otherwise, compinit will have already done that. + if [[ ! -f "$ZSH_CACHE_DIR/completions/_zsh-patina" ]]; then + typeset -g -A _comps + autoload -Uz _zsh-patina + _comps[zsh-patina]=_zsh-patina + fi + + zmodload -F zsh/files b:zf_mv + () { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._zsh-patina" + zf_mv -f -- =( "$1" completion ) "$ZSH_CACHE_DIR/completions/_zsh-patina" + } "${ZSH_PATINA_BINARY:-$commands[zsh-patina]}" &| else echo '[oh-my-zsh] zsh-patina not found, please install it from https://github.com/michel-kraemer/zsh-patina' fi