andsens / homeshick

git dotfiles synchronizer written in bash

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

zsh completion is not working

waiting-for-dev opened this issue · comments

I followed zsh completion instructions detailed in the wiki but it doesn't work at all...

Am I missing something?

EDIT by @andsens: Since this issue seems to be visited a lot, here's the solution (for this specific case, that is. If something else works for you, feel free to add a comment to the issue)

It should be as simple as just copy&pasting that line. fpath should contain
the path to homeshick and that's pretty much it.
Without further details I can't help you. Do you run any zsh framework like
oh-my-zsh?

On Wednesday, April 16, 2014, Marc Busqué notifications@github.com wrote:

I followed zsh completion instructions detailed in the wikihttps://github.com/andsens/homeshick/wiki/Installation#zsh-completionbut it doesn't work at all...

Am I missing something?


Reply to this email directly or view it on GitHubhttps://github.com//issues/89
.

Anders

Yeah... I don't know which other details could be useful...

Yes, I'm runing oh-my-zsh with just git and gitignore plugins enabled right now. I'm in Debian 3.2.54-2 x86_64 GNU/Linux

I'm in Debian 3.2.54-2 x86_64 GNU/Linux

I assume you mean the kernel version. Otherwise you'd be running Sarge or something :-)
What's the output of echo $fpath?

Yeah, that's the kernel :)

The output:

/home/marc/.homesick/repos/homeshick/completions /home/marc/.oh-my-zsh/plugins/gitignore /home/marc/.oh-my-zsh/plugins/git /home/marc/.oh-my-zsh/functions /home/marc/.oh-my-zsh/completions /usr/local/share/zsh/site-functions /usr/share/zsh/vendor-functions /usr/share/zsh/vendor-completions /usr/share/zsh/functions/Calendar /usr/share/zsh/functions/Chpwd /usr/share/zsh/functions/Completion /usr/share/zsh/functions/Completion/AIX /usr/share/zsh/functions/Completion/BSD /usr/share/zsh/functions/Completion/Base /usr/share/zsh/functions/Completion/Cygwin /usr/share/zsh/functions/Completion/Darwin /usr/share/zsh/functions/Completion/Debian /usr/share/zsh/functions/Completion/Linux /usr/share/zsh/functions/Completion/Mandriva /usr/share/zsh/functions/Completion/Redhat /usr/share/zsh/functions/Completion/Solaris /usr/share/zsh/functions/Completion/Unix /usr/share/zsh/functions/Completion/X /usr/share/zsh/functions/Completion/Zsh /usr/share/zsh/functions/Completion/openSUSE /usr/share/zsh/functions/Exceptions /usr/share/zsh/functions/MIME /usr/share/zsh/functions/Misc /usr/share/zsh/functions/Newuser /usr/share/zsh/functions/Prompts /usr/share/zsh/functions/TCP /usr/share/zsh/functions/VCS_Info /usr/share/zsh/functions/VCS_Info/Backends /usr/share/zsh/functions/Zftp /usr/share/zsh/functions/Zle

Hm, that's weird. I am on vacation right now and left my testing env for completion at home. Let me get back to you in a week, there are some different zsh variables you can set to debug this.

Ok, thanks a lot. I'll wait here :)

I'm experiencing this issue as well (in Fedora 20)

$fpath:

/home/adonisk/.rvm/scripts/zsh/Completion
/home/adonisk/.oh-my-zsh/plugins/themes
/home/adonisk/.oh-my-zsh/plugins/npm
/home/adonisk/.oh-my-zsh/plugins/node
/home/adonisk/.oh-my-zsh/plugins/gem
/home/adonisk/.oh-my-zsh/plugins/ruby
/home/adonisk/.oh-my-zsh/plugins/rvm
/home/adonisk/.oh-my-zsh/plugins/nvm
/home/adonisk/.oh-my-zsh/plugins/bower
/home/adonisk/.oh-my-zsh/plugins/colored-man
/home/adonisk/.oh-my-zsh/plugins/ssh-agent
/home/adonisk/.oh-my-zsh/plugins/urltools
/home/adonisk/.oh-my-zsh/plugins/last-working-dir
/home/adonisk/.oh-my-zsh/plugins/gitfast
/home/adonisk/.oh-my-zsh/functions
/home/adonisk/.oh-my-zsh/completions
/usr/share/zsh/site-functions
/usr/share/zsh/5.0.2/functions

Maybe someone could make a oh-my-zsh plugin for homeshick?

@varemenos in your case it seems you don't have the homeshick link in your output. Have you added the following line in your .zshrc?

fpath=($HOME/.homesick/repos/homeshick/completions $fpath)

Oops, i ran it after commenting out that line from my rc file.

/home/adonisk/.homesick/repos/homeshick/completions
/scripts/zsh/Completion
/home/adonisk/.oh-my-zsh/plugins/themes
/home/adonisk/.oh-my-zsh/plugins/npm
/home/adonisk/.oh-my-zsh/plugins/node
/home/adonisk/.oh-my-zsh/plugins/gem
/home/adonisk/.oh-my-zsh/plugins/ruby
/home/adonisk/.oh-my-zsh/plugins/rvm
/home/adonisk/.oh-my-zsh/plugins/nvm
/home/adonisk/.oh-my-zsh/plugins/bower
/home/adonisk/.oh-my-zsh/plugins/colored-man
/home/adonisk/.oh-my-zsh/plugins/ssh-agent
/home/adonisk/.oh-my-zsh/plugins/urltools
/home/adonisk/.oh-my-zsh/plugins/last-working-dir
/home/adonisk/.oh-my-zsh/plugins/gitfast
/home/adonisk/.oh-my-zsh/functions
/home/adonisk/.oh-my-zsh/completions
/usr/share/zsh/site-functions
/usr/share/zsh/5.0.2/functions

Alright, back again :-)
I use this script to reload the completion when I'm fiddling with it, could you give it a go and see if running it makes any difference?

f=$HOME/.homesick/repos/homeshick/completions/_homeshick
unfunction $f:t 2> /dev/null
autoload -U $f:t

type _homeshick should return "_homeshick is a shell function". If it does not, try running source $HOME/.homesick/repos/homeshick/completions/_homeshick. That should force-load the _homeshick function into the current shell (you can double check by either running type _homeshick again or invoking _homeshick directly, it should respond with "_arguments:comparguments:312: can only be called from completion function")

My suspicion is that something's awry with the autoloading, but let's worry about that after you've tried the above, try to figure out what exactly did the trick (e.g. did you have to source the file for it to work or was the autoload statement enough?)

Yeah, after runing your script and later type _homeshick it returns with _homeshick is a shell function. :)

Interesting...

  • What are the contents of $fpath now?
  • Does autocompletion work?
  • What did type _homeshick return previously? (you can just open up a new shell, the environment should be a fresh one then)
  • The content of $fpath is:
/home/marc/.homesick/repos/homeshick/completions /home/marc/.oh-my-zsh/plugins/gitignore /home/marc/.oh-my-zsh/plugins/git /home/marc/.oh-my-zsh/functions /home/marc/.oh-my-zsh/completions /usr/local/share/zsh/site-functions /usr/share/zsh/vendor-functions /usr/share/zsh/vendor-completions /usr/share/zsh/functions/Calendar /usr/share/zsh/functions/Chpwd /usr/share/zsh/functions/Completion /usr/share/zsh/functions/Completion/AIX /usr/share/zsh/functions/Completion/BSD /usr/share/zsh/functions/Completion/Base /usr/share/zsh/functions/Completion/Cygwin /usr/share/zsh/functions/Completion/Darwin /usr/share/zsh/functions/Completion/Debian /usr/share/zsh/functions/Completion/Linux /usr/share/zsh/functions/Completion/Mandriva /usr/share/zsh/functions/Completion/Redhat /usr/share/zsh/functions/Completion/Solaris /usr/share/zsh/functions/Completion/Unix /usr/share/zsh/functions/Completion/X /usr/share/zsh/functions/Completion/Zsh /usr/share/zsh/functions/Completion/openSUSE /usr/share/zsh/functions/Exceptions /usr/share/zsh/functions/MIME /usr/share/zsh/functions/Misc /usr/share/zsh/functions/Newuser /usr/share/zsh/functions/Prompts /usr/share/zsh/functions/TCP /usr/share/zsh/functions/VCS_Info /usr/share/zsh/functions/VCS_Info/Backends /usr/share/zsh/functions/Zftp /usr/share/zsh/functions/Zle
  • Autocompletion does not work
  • type _homeshick previously returned _homeshick not found

Autocompletion does not work

Does autocompletion for anything else work? In any case, try running

autoload -U compinit
compinit

Try adding a print test in the _homeshick completion script and see if test is printed when you press tab.

For advanced debugging you can try:

zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*' group-name ""

Then zsh will tell you what exactly is being completed or whether some command cannot be found.

Yeah, completion is working for other programs...

Adding print test inside _homeshick() function body makes no difference... :(

I'm beginning to run out of ideas here :-)
Have you by any chance aliased homeshick to something different and are trying to use completion on that?

Nope, just standard installation :)

Can you try executing the interactive script in the test/ folder? It should drop you into a test environment where only homeshick is set up. This way you have an entirely clean environment.

Then run

source "$HOME/.homesick/repos/homeshick/homeshick.sh"
fpath=($HOME/.homesick/repos/homeshick/completions $fpath)
autoload -U compinit
compinit

... and check if completion is working.

Yes, it works!! :) Well, homeshick commands are autocompleted, but castles aren't. I don't know if they are autocompleted normally.

Nice :-)
OK, so this really seems like a problem with your setup. I suggest you try to reduce your .zshrc to the bare minimals and then build up from there until the autocompletion doesn't work.
I am closing this issue, since this is not a fault with the completion script or the installation instructions.
When you figure out what the problem is, please report back, that could save others with the same problem quite a bit of debugging (and a might add it to the docs, if it is a common thing).

Well, homeshick commands are autocompleted, but castles aren't. I don't know if they are autocompleted normally.

It's a totally fresh environment, so there aren't any castles except homeshick (you should be able to autocomplete that).

Ok, I'll try. It's strange, because I have a very pristine .zshrc because I installed oh-my-zsh a short time ago, but I have done some minimal setup so I'll check it.

You are right, I can complete homeshick castle.

I'll report back any news..

I'm also having a weird issue with them unless I source .zshrc again, might prove useful
EDIT: It should be noted I'm not using oh-my-zsh or anything

I can't tell you anything else than to try and run homeshick/test/interactive and reproduce the issue there. If you can't, it's your setup. You can then try to add your config piece by piece, to see where it goes wrong.

Figured it out.. compinit is called at the beginning of my .zshrc and moving it to the end fixed it.
Though that is strange cause http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Use-of-compinit says "If the number of completion files changes, compinit will recognise this and produce a new dump file. However, if the name of a function or the arguments in the first line of a #compdef function (as described below) change, it is easiest to delete the dump file by hand so that compinit will re-create it the next time it is run. The check performed to see if there are new functions can be omitted by giving the option -C. In this case the dump file will only be created if there isn’t one already."
Maybe I just understand it wrong?

Ok, it is the same for me. If I run compinit after homeshick lines, then autocompletion works...

a bit cross-referencing might not hurt

I did initial implementation for oh-my-zsh plugin: ohmyzsh/ohmyzsh#3142
feel free to provide feedback there

had the same problem on Linux 4.15.15-1-ARCH x86_64 GNU/Linux.
Reinstalling zsh (pacman) without any change to .zshrc fixed the issue.