From d781d3d48e30f6fecf5762daf4909a5325cb9d6d Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 3 May 2020 20:06:38 +0100 Subject: [PATCH] Switch from zplug to zinit for ZSH plugins Zinit allows near instant shell startup by loading plugins in the background after initializing the shell. This has yielded a 60-70ms startup time instead of around 360ms as it was with zplug. And even if you disable the background loading, zinit itself is still faster at around 130ms. --- .gitmodules | 3 +++ zsh/zinit | 1 + zshrc | 69 +++++++++++++++++++++++------------------------------ 3 files changed, 34 insertions(+), 39 deletions(-) create mode 160000 zsh/zinit diff --git a/.gitmodules b/.gitmodules index 51eab98..a566a01 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "zsh/zplug/zplug"] path = zsh/zplug/zplug url = https://github.com/zplug/zplug +[submodule "zsh/zinit"] + path = zsh/zinit + url = https://github.com/zdharma/zinit.git diff --git a/zsh/zinit b/zsh/zinit new file mode 160000 index 0000000..ff12246 --- /dev/null +++ b/zsh/zinit @@ -0,0 +1 @@ +Subproject commit ff12246fb49b6a3e1ae274e5fb9b0508ab892f75 diff --git a/zshrc b/zshrc index 7ff71ed..f3464a5 100644 --- a/zshrc +++ b/zshrc @@ -11,43 +11,45 @@ fi # ============================================================================== -# zplug +# Zinit # ============================================================================== -ZPLUG_HOME="$DOTZSH/zplug/zplug" -ZPLUG_CACHE_DIR="$HOME/.local/zsh/zplug/cache" -ZPLUG_REPOS="$HOME/.local/zsh/zplug/repos" +declare -A ZINIT +ZINIT[BIN_DIR]="$DOTZSH/zinit" +ZINIT[HOME_DIR]="$HOME/.local/zsh/zinit" -source "$ZPLUG_HOME/init.zsh" -alias zp="zplug" +source "${ZINIT[BIN_DIR]}/zinit.zsh" -zplug "lib/history", from:oh-my-zsh, defer:1 -zplug "lib/completion", from:oh-my-zsh, defer:1 -zplug "jimeh/zsh-peco-history", defer:2 -zplug "plugins/bundler", from:oh-my-zsh -zplug "plugins/git", from:oh-my-zsh -zplug "zsh-users/zsh-completions" -zplug "zsh-users/zsh-autosuggestions" -zplug "zsh-users/zsh-syntax-highlighting", defer:3 +# Enable using oh-my-zsh compatible themes. +zinit snippet OMZ::lib/theme-and-appearance.zsh +zinit snippet OMZ::lib/git.zsh +zinit snippet OMZ::plugins/git +zinit cdclear -q # forget completions provided up to this point -zplug "jimeh/plain.zsh-theme", as:theme +# Enable interactive selection of completions. +zinit snippet OMZ::lib/completion.zsh -# Install plugins if there are plugins that have not been installed -if ! zplug check --verbose; then - printf "Install? [y/N]: " - if read -q; then - echo - zplug install - fi -fi +# Set various sane defaults for ZSH history management. +zinit snippet OMZ::lib/history.zsh -# Configure zsh-syntax-highlighting -if zplug check zsh-users/zsh-syntax-highlighting; then - ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) -fi +# Enable Ruby Bundler plugin from oh-my-zsh. +zinit snippet OMZ::plugins/bundler -zplug load +zinit ice pick'plain.zsh-theme' +zinit light jimeh/plain.zsh-theme +zinit ice wait'0' lucid +zinit load jimeh/zsh-peco-history + +zinit ice wait'0' lucid blockf +zinit light zsh-users/zsh-completions + +zinit ice wait'0' lucid atload"!_zsh_autosuggest_start" +zinit light zsh-users/zsh-autosuggestions + +ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) +zinit ice wait'0' lucid atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" +zinit light zdharma/fast-syntax-highlighting # ============================================================================== # Private Dotfiles @@ -58,17 +60,6 @@ if [ -f "$DOTPFILES/zshrc" ]; then fi -# ============================================================================== -# Completion -# ============================================================================== - -# Enable bash-style completion. -autoload -Uz +X compinit && compinit -autoload -Uz +X bashcompinit && bashcompinit - -fpath=("$DOTZSH/completion" "${fpath[@]}") - - # ============================================================================== # Tool specific setup # ==============================================================================