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

oh-my-zsh installation instructions are sub-optimal #603

Open
segevfiner opened this issue Oct 23, 2018 · 3 comments
Open

oh-my-zsh installation instructions are sub-optimal #603

segevfiner opened this issue Oct 23, 2018 · 3 comments

Comments

@segevfiner
Copy link
Contributor

The current instructions: README.md#oh-my-zsh, suggest to add zsh-completions to plugins and rerun compinit.

But that's sub-optimal. This will cause Zsh to rebuild the completion cache twice on each Zsh invocation: The first when you source oh-my-zsh, and the second time when you rerun compinit. This defeats the whole point of the completions cache, and will negatively impact the startup time of Zsh.

Sadly, oh-my-zsh doesn't seem to have a way for a plugin to add more fpath entries, besides the root folder of the plugin, before it invokes compinit. I think it's best to just suggest adding the zsh-completions src dir to fpath before the source $ZSH/oh-my-zsh.sh line, in order to avoid this issue. Something like this:

fpath=($ZSH/custom/plugins/zsh-completions/src $fpath)
@felipecrs
Copy link
Contributor

felipecrs commented Nov 12, 2021

Just to clarify, the suggestion is to replace:

plugins=(… zsh-completions)

source "$ZSH/oh-my-zsh.sh"

autoload -U compinit && compinit

With:

fpath+="${ZSH_CUSTOM:-"$ZSH/custom"}/plugins/zsh-completions/src"

source "$ZSH/oh-my-zsh.sh"

The above is just an optimized version of the previously suggested, which takes the ZSH_CUSTOM into account if set.

References ohmyzsh/ohmyzsh#10412

felipecrs added a commit to felipecrs/dotfiles that referenced this issue Nov 12, 2021
Now we don't recompiled the completions twice, at least. However, this
could probably be done better if OMZ supported such a thing, at least
for zsh-completions.

References ohmyzsh/ohmyzsh#10412
References zsh-users/zsh-completions#603
@felipecrs
Copy link
Contributor

It's important to remove zsh-completions from the OMZ plugins because otherwise fpath would be filled with the same contents twice.

bo5o added a commit to bo5o/zsh-asdf-direnv that referenced this issue Oct 28, 2022
compinit is called before plugins are loaded. to avoid having to call compinit
again after loading this plugin, suggest to set fpath outside of the plugin in
zshrc.

see also this issue zsh-users/zsh-completions#603
ZhongRuoyu added a commit to ZhongRuoyu/dotfiles that referenced this issue Jan 31, 2023
zsh-completions won't work properly as an oh-my-zsh plugin. See
zsh-users/zsh-completions#603.
redxtech pushed a commit to redxtech/zsh-asdf-direnv that referenced this issue Jun 8, 2023
compinit is called before plugins are loaded. to avoid having to call compinit
again after loading this plugin, suggest to set fpath outside of the plugin in
zshrc.

see also this issue zsh-users/zsh-completions#603
geodimm added a commit to geodimm/dotfiles that referenced this issue Dec 4, 2023
@ragnarok22
Copy link

ragnarok22 commented Dec 8, 2024

I used to have my configuration like this on Arch with Kitty terminal:

plugins=(git zsh-completions zsh-autosuggestions zsh-syntax-highlighting)

fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src
source $ZSH/oh-my-zsh.sh

and I recently migrated to Mac and partial autocompletions doesn't work (Alt + right Arrow). I've been messing around with the plugin and reading the docs and issues and I just remove it from the plugin list and it works perfectly.

This is my final version:

plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src
source $ZSH/oh-my-zsh.sh

EDIT:
forget it. It doesn't works on tmux

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

Successfully merging a pull request may close this issue.

4 participants