zdharma-continuum / zinit

๐ŸŒป Flexible and fast ZSH plugin manager
MIT License
2.95k stars 126 forks source link

completions don't work until I press tab twice #145

Closed jgkaplan closed 2 years ago

jgkaplan commented 2 years ago

Issue description

This probably isn't a bug, but I'm not sure where else to ask about this. When first opening a new terminal window, completions don't work. After pressing tab a few times, everything works normally. I get the following error: image

zinit config

#zmodload zsh/zprof

#####################
# ZSH settings      #
#####################
#don't beep
setopt nobeep
## TAB COMPLETIONS
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'       # Case insensitive tab completion
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"         # Colored completion (different colors for dirs/files/etc)
zstyle ':completion:*' rehash true                              # automatically find new executables in path
# Speed up completions
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.cache/zsh_completion_cache
zstyle ':completion:*' menu select

#####################
# ZINIT             #
#####################
### Added by Zinit's installer
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
    print -P "%F{33}โ–“โ–’โ–‘ %F{220}Installing DHARMA Initiative Plugin Manager (zdharma-continuum/zinit)โ€ฆ%f"
    command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
    command git clone https://github.com/zdharma-continuum/zinit $HOME/.zinit/bin && \
        print -P "%F{33}โ–“โ–’โ–‘ %F{34}Installation successful.%F" || \
        print -P "%F{160}โ–“โ–’โ–‘ The clone has failed.%F"
fi

source "$HOME/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit

### End of Zinit's installer chunk

# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
    zdharma-continuum/zinit-annex-as-monitor \
    zdharma-continuum/zinit-annex-bin-gem-node \
    zdharma-continuum/zinit-annex-patch-dl \
    zdharma-continuum/zinit-annex-rust

##### autosuggestions
zinit ice wait"0a" lucid atload"_zsh_autosuggest_start"
zinit light zsh-users/zsh-autosuggestions

##### completions
zinit ice wait"0b" lucid blockf atpull'zinit creinstall -q .'
zinit light zsh-users/zsh-completions

##### syntax highlighting
zinit ice wait"0c" lucid atinit"zicompinit; zicdreplay"
zinit light zdharma-continuum/fast-syntax-highlighting

##### history search
zinit ice wait"0b" lucid atload'bindkey "$terminfo[kcuu1]" history-substring-search-up; bindkey "$terminfo[kcud1]" history-substring-search-down'
zinit light zsh-users/zsh-history-substring-search
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down

#####################
# STARSHIP          #
#####################
eval "$(starship init zsh)"
# zinit ice as"command" from"gh-r" \ # `starship` binary as command, from github release
#           atclone"./starship init zsh > init.zsh; ./starship completions zsh > _starship" \ # starship setup at clone(create init.zsh, completion)
#           atpull"%atclone" src"init.zsh" # pull behavior same as clone, source init.zsh
# zinit light starship/starship

#####################
# NVM               #
#####################
export NVM_COMPLETION=true
export NVM_LAZY_LOAD=true
export NVM_DIR="$HOME/.nvm"
zinit light lukechilds/zsh-nvm

#####################
# EXA colors        #
#####################
zinit ice wait"2" lucid from"gh-r" as"program" mv"bin/exa* -> exa"
zinit light ogham/exa
# zinit ice wait blockf atpull'zinit creinstall -q .'
# color ls
# alias ls='ls -G'
alias ls='exa'

#####################
# PATH              #
#####################
export PATH=$PATH:/Applications/Racket\ v7.8/bin

# opam configuration
# test -r /Users/joshuakaplan/.opam/opam-init/init.zsh && . /Users/joshuakaplan/.opam/opam-init/init.zsh > /dev/null 2> /dev/null || true
export PATH="/usr/local/opt/bison/bin:$PATH"
export PATH=$HOME/.local/bin:$PATH

#####################
# CONDA             #
#####################
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
# __my_conda_init() {
# __conda_setup="$("${HOME}/opt/anaconda3/bin/conda" 'shell.zsh' 'hook' 2> /dev/null)"
# if [ $? -eq 0 ]; then
#     eval "$__conda_setup"
# else
    if [ -f "$HOME/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "$HOME/opt/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="$HOME/opt/anaconda3/bin:$PATH"
    fi
# fi
# unset __conda_setup
# }
# zinit wait lucid for \
#     atinit'__my_conda_init' \
#     zdharma-continuum/null
# unset __my_conda_init
# <<< conda initialize <<<

#####################
# jog command       #
#####################
function zshaddhistory() {
    echo "${1%%$'\n'}|${PWD}   " >> ~/.zsh_history_ext
}

function jog() {
    grep -v "jog" ~/.zsh_history_ext | grep -a --color=never "${PWD}   " | cut -f1 -d"|" | tail
}

#zprof

zinit version or commit ID

9ee45d6804fdf4972a9e913a1ad86d77de124231

zsh version

5.8

host info

CPUTYPE=x86_64 MACHTYPE=x86_64 OSTYPE=darwin20.0 Darwin 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64

vladdoster commented 2 years ago

Because you are doing things out of order

See the wiki

jgkaplan commented 2 years ago

Switching to that order didn't change anything

jgkaplan commented 2 years ago

It seems to be an issue with how I was loading NVM. When I remove that part of the code, things work fine

vladdoster commented 2 years ago

You should load it via the OMZP::nvm syntax

vladdoster commented 2 years ago

@jgkaplan my 2ยข before I re-close this issue.

The plugin, lukechilds/zsh-nvm hasn't been updated in over two years. The oh-my-zsh nvm plugin has activity as of two days ago.

Additionally, the OMZ version will almost certainly load faster and have peace of mind knowing you're using an actively maintained ZSH plugin.