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

zsh-completions require compinit in the .zshrc file? #277

Closed
daften opened this issue Dec 20, 2014 · 9 comments
Closed

zsh-completions require compinit in the .zshrc file? #277

daften opened this issue Dec 20, 2014 · 9 comments

Comments

@daften
Copy link

daften commented Dec 20, 2014

Is that necessary, after changing the fpath?

@daften
Copy link
Author

daften commented Dec 20, 2014

Adding the line in changing the fpath at the beginning also helps.
Oh-my-zsh later performs compinit anyway

@gilbertwyw
Copy link

I find that i need to put the fpath modification like this:

fpath=(
  /usr/local/share/zsh-completions
  /usr/local/share/zsh/site-functions
  $fpath
)

source $ZSH/oh-my-zsh.sh

# User configuration

wondering if there's more location-independent way of doing this. Was hoping that I can put it below that user configuration line.

@liangguohuan
Copy link

I finish install oh-my-zsh, then i add

fpath=(/usr/local/share/zsh/zsh-completions/src $fpath)

to .zshrc at the beginning, but it still doesn't work,
i must compinit in every zsh, then it can work.

who can tell me what's the problom ?

@gilbertwyw
Copy link

quote from brew info zsh-completions:

You may also need to force rebuild zcompdump:

rm -f ~/.zcompdump; compinit

HTH

@liangguohuan
Copy link

hi, gilbertwyw,
i must compinit in every zsh, then it can work. means i do it like you say,
i saw the tips via manual installation before.

my system is ubuntu 14.04.

@apjanke
Copy link

apjanke commented Oct 2, 2015

Yes, you need to call compinit in your .zshrc so it is run every time the shell starts. That is how zsh initializes the completion system; it is normal.

@apjanke
Copy link

apjanke commented Nov 16, 2015

Sorry, disregard my last comment: I didn't see that some of you were running Oh My Zsh. OMZ calls compinit for you as part of the startup process, so you don't have to do it yourself.

The issue with OMZ and compinit here is (at least partly) that OMZ expects a different plugin structure than zsh-completions has. OMZ expects the definitions for all completion definitions to be in the root directory of the plugin. Its startup process goes like this:

  • Add the root dir of each plugin to $fpath
  • Run compinit
  • Source each of the plugins' <foo>.plugin.zsh files to load them

Since zsh-completion uses zsh-completion.plugin.zsh to put its src/ dir on $fpath, it doesn't happen until OMZ has already run compinit, so its completions aren't included. You can do another compinit after sourcing ~/.oh-my-zsh/oh-my-zsh.sh to pick them up. However, multiple compinits could be a performance issue, and could break completions from plugins which define them explicitly using compdef and similar commands, instead of auto-loaded _name completion definitions.

@nicoulaj nicoulaj closed this as completed Feb 4, 2016
@lfaoro
Copy link

lfaoro commented Jul 28, 2017

add this to your .zshrc then source it:

rm -f "$HOME/.zcompdump"; compinit
source ~/.zshrc

problem solved

vgallissot pushed a commit to vgallissot/ansible-role-zsh that referenced this issue Jan 8, 2018
* I thought it could be done via /etc/profile.d/*.sh scripts but it
fails over a lot of things. Mostly missing zsh functions.
This issue covers subject -> zsh-users/zsh-completions#277

* done via a symlink from user's home directory to a common shared file
defaulted to /etc/oh-my-zsh.zshrc file

TODO_LEFT:
* gopath & stuff might be needed in ZSH_CUSTOMPATH
@Baneeishaque
Copy link

fpath=(/usr/local/share/zsh-completions $fpath)
rm -f "$HOME/.zcompdump"; compinit
source ~/.zshrc

Causes zsh to stuck on startup.

fpath=(/usr/local/share/zsh-completions $fpath)
rm -f "$HOME/.zcompdump"; compinit

Fixed the issue.

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

7 participants