mattmc3 / zephyr

:wind_face: A Zsh framework as nice as a cool summer breeze
MIT License
125 stars 13 forks source link

Question about the plugins' usage #29

Closed toooonyy closed 2 weeks ago

toooonyy commented 2 weeks ago

Hi mattmc3, recently I decided to switch OMZ to a faster zsh plugin manager and I founded antidote thanks for the great work! However I'm not sure if I'm missing use antidoe, or adding too many overleaping plugins with zephyr, could you help me figure this out? My current .zshrc and .zsh_plugins.txt file looks like this

.zshrc

#export PATH="/opt/homebrew/bin:$PATH"
#export PATH="/opt/homebrew/sbin:$PATH"
#fpath+=("/opt/homebrew/share/zsh/site-functions")

if [[ -o interactive ]]; then
    /opt/homebrew/bin/fastfetch
fi
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

HISTSIZE=1000000       # Set the amount of lines you want saved
SAVEHIST=1000000       # This is required to actually save them, needs to match with HISTSIZE

setopt EXTENDED_HISTORY          # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY        # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY             # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST    # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS          # Don\'t record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS      # Delete old recorded entry if new entry is a duplicate.
setopt HIST_FIND_NO_DUPS         # Do not display a line previously found.
setopt HIST_IGNORE_SPACE         # Don\'t record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS         # Don\'t write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS        # Remove superfluous blanks before recording entry.

ZSH_HIGHLIGHT_HIGHLIGHTERS+=(main brackets pattern)
# Declare the variable
typeset -A ZSH_HIGHLIGHT_PATTERNS

# To have commands starting with `rm -rf` in red:
ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')

# Lazy-load antidote and generate the static load file only when needed
source /opt/homebrew/opt/antidote/share/antidote/antidote.zsh
antidote load

eval "$(zoxide init zsh)"

alias ls="eza --icons=automatic=automatic"
alias ll="eza --icons=automatic --git --long --all --time-style=long-iso"
alias l="eza --icons=automatic --git --long --time-style=long-iso"
alias lt="eza --icons=automatic --git --tree --level=3 --time-style=long-iso"

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

.zsh_plugins.txt

# run towards the TOP of your .zsh_plugins.txt before any compdef calls
mattmc3/ez-compinit

Aloxaf/fzf-tab

zsh-users/zsh-history-substring-search
zsh-users/zsh-syntax-highlighting kind:defer

marlonrichert/zsh-autocomplete
zsh-users/zsh-autosuggestions

mattmc3/zephyr path:plugins/homebrew
mattmc3/zephyr path:plugins/compstyle
mattmc3/zephyr path:plugins/completion
mattmc3/zephyr path:plugins/macos

romkatv/powerlevel10k

My quesions are

  1. Does the order plugin's order in .zsh_plugins.txt affect the order of loading they?
  2. Is mattmc3/ez-compinit still necessary if I use your zephyr/completion?
  3. Does zephyr/compstyle conflict with marlonrichert/zsh-autocomplete or Aloxaf/fzf-tab?
  4. Last question or maybe request, is it possible to include an auto-clean mechanics, that removes all typo or wrong commands from the history file so they won't be suggested, in this project? (I'm having this fish plugin in mind.)
mattmc3 commented 2 weeks ago

Great questions. Let's see if I can answer them:

  1. Yes, the order of plugins in .zsh_plugins.txt definitely matters. If you are using kind:defer, those all happen at the end. You can pretty easily see what antidote is doing by simply looking in the .zsh_plugins.zsh cache file.
  2. ez-compinit and zephyr/completion are mostly the same plugin - one's just stand-alone because it was easier to point people to than Zephyr's completion subplugin, since not all plugin managers support nested plugins. No need for both.
  3. If you are using alozaf/fzf-tab, you probably don't need all the completion styles from compstyle, but it doesn't hurt. I don't use marlonrichert/zsh-autocomplete, but I can't see how the compstyles would conflict, nor has anyone opened a bug report to that effect. But let's be sure we're clear - the compstyle plugin is simply setting zstyles, and is different than the completion plugin. I think I've seen where zsh-autocomplete tries to handle compinit for you, so you may want to read the docs/examine the plugin to be sure.
  4. Marlon has another plugin that supposedly does this, but I haven't used it either: https://unix.stackexchange.com/a/629701
toooonyy commented 2 weeks ago

Great questions. Let's see if I can answer them:

  1. Yes, the order of plugins in .zsh_plugins.txt definitely matters. If you are using kind:defer, those all happen at the end. You can pretty easily see what antidote is doing by simply looking in the .zsh_plugins.zsh cache file.
  2. ez-compinit and zephyr/completion are mostly the same plugin - one's just stand-alone because it was easier to point people to than Zephyr's completion subplugin, since not all plugin managers support nested plugins. No need for both.
  3. If you are using alozaf/fzf-tab, you probably don't need all the completion styles from compstyle, but it doesn't hurt. I don't use marlonrichert/zsh-autocomplete, but I can't see how the compstyles would conflict, nor has anyone opened a bug report to that effect. But let's be sure we're clear - the compstyle plugin is simply setting zstyles, and is different than the completion plugin. I think I've seen where zsh-autocomplete tries to handle compinit for you, so you may want to read the docs/examine the plugin to be sure.
  4. Marlon has another plugin that supposedly does this, but I haven't used it either: https://unix.stackexchange.com/a/629701

Thx for the quick reply, I've adjust my .zsh_plugins.txt now it's like this

zsh-users/zsh-history-substring-search
zsh-users/zsh-syntax-highlighting kind:defer

Aloxaf/fzf-tab

# marlonrichert/zsh-autocomplete
zsh-users/zsh-autosuggestions

mattmc3/zephyr path:plugins/homebrew
# mattmc3/zephyr path:plugins/compstyle
mattmc3/zephyr path:plugins/completion
mattmc3/zephyr path:plugins/macos

romkatv/powerlevel10k

For question 4 I found this nice answer https://superuser.com/questions/902241/how-to-make-zsh-not-store-failed-command, which is better IMO as the other solution immediately deletes your typo commands so you can't even find and correct it using up arrow.