Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocompletion with zap package manager #78

Open
Andrew15-5 opened this issue Feb 25, 2023 · 6 comments
Open

Autocompletion with zap package manager #78

Andrew15-5 opened this issue Feb 25, 2023 · 6 comments
Assignees

Comments

@Andrew15-5
Copy link

I just wanted to say (it's not really an issue for me) that I had trouble getting autocompletion working with zap. But I figured it out and here is my MWE:

# .zshrc

[ -f $HOME/.local/share/zap/zap.zsh ] ||
zsh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.zsh)
source $HOME/.local/share/zap/zap.zsh

fpath=($ZAP_DIR/plugins/zsh-z $fpath) # the most critical line to get everything to work

autoload -Uz compinit
compinit

zstyle ':completion:*' menu select # optional

ZSHZ_CMD=f # I have an alias z=fg
plug agkozak/zsh-z

I don't know, maybe it's a bug with zap (it's v0.2) but all other plugins work as expected. This is the first one.

P.S. I was too lazy to hop on the train of "lazy cding" but now I can see the potential, specifically because autocompletion with paths is working. Really cool plugin, I can't wait when I'll feel all the gains it can give.

@agkozak agkozak self-assigned this Feb 28, 2023
@agkozak
Copy link
Owner

agkozak commented Feb 28, 2023

Zsh-z adds its own directory to fpath, so you shouldn't need to do that yourself. But compinit needs to run after fpath has been assembled. Try rearranging the lines so that compinit runs after plug agkozak/zsh-z and I think you'll find it all works.

@Andrew15-5
Copy link
Author

Thank you, that works:

# .zshrc

[ -f $HOME/.local/share/zap/zap.zsh ] ||
zsh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.zsh)
source $HOME/.local/share/zap/zap.zsh

ZSHZ_CMD=f # I have an alias z=fg
plug agkozak/zsh-z

zstyle ':completion:*' menu select # optional

autoload -Uz compinit
compinit

Now I will remember that loading plugins comes first.

@Andrew15-5
Copy link
Author

Update: If I put compinit at the end of my config file (after a bunch of settings and plugins) it considerably slows down init time for shell to be fully ready. Because of that and since I only have a problem with one plugin, I put the init lines right after this plugin — much faster.

@agkozak agkozak reopened this Feb 28, 2023
@agkozak
Copy link
Owner

agkozak commented Feb 28, 2023

Could you send me the exact .zshrc that you're using, with nothing omitted? I'll try to figure out what's happening.

@Andrew15-5
Copy link
Author

Apparently this it has something to do with zap-zsh/completions. Because I shrank down my config and the noticeable loading time is still there.

Loads pretty fast:

[ -f $HOME/.local/share/zap/zap.zsh ] ||
zsh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.zsh)
source $HOME/.local/share/zap/zap.zsh

ZHOME=${ZDOTDIR:-$HOME}

HISTFILE=$ZHOME/.history.zsh
HISTSIZE=1000000000
SAVEHIST=1000000000

ZSHZ_CMD=f
plug agkozak/zsh-z

autoload -Uz compinit
compinit

plug zap-zsh/completions

Loads very slow:

[ -f $HOME/.local/share/zap/zap.zsh ] ||
zsh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.zsh)
source $HOME/.local/share/zap/zap.zsh

ZHOME=${ZDOTDIR:-$HOME}

HISTFILE=$ZHOME/.history.zsh
HISTSIZE=1000000000
SAVEHIST=1000000000

plug zap-zsh/completions

ZSHZ_CMD=f
plug agkozak/zsh-z

autoload -Uz compinit
compinit

So in this config, the plugin order matters (if you value your time).

P.S. I'm basically still a beginner to all the cool zsh stuff. But I'm nearly an expert at POSIX sh or Bash scripting, well at least I used them (still am) for several years in terminal and scripts every day. But zsh config file is nothing like bash, therefore I almost blindly copy and paste some lines and hope that they would work.

@Andrew15-5
Copy link
Author

2 more points:

  • Now I'm confident that for some plugins order is important (I had one bug with hlissner/zsh-autopair and zsh-users/zsh-syntax-highlighting which must be plugged in this order)
  • I also noticed some weird slow-downs whenever I used terminal (kitty) and opened Neovim only today when I was not at home, which means I'm completely clueless what it was

This has nothing to do with this project (maybe 1%), but maybe it still has some value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants