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 · 2 comments
Open

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

segevfiner opened this issue Oct 23, 2018 · 2 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
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.

3 participants