dim-an / cod

cod is a completion daemon for bash/fish/zsh
Apache License 2.0
517 stars 23 forks source link

Path completion don't work #55

Open Strongleong opened 2 years ago

Strongleong commented 2 years ago

Can't really come up with good title, sorry. Bad English knowledge.

So, I made bare git repository for my dot files and make alias config for this repo. After config -h cod picked up possible flags and commands as expected. But when I try type something like config add ~/.config/ and press TAB nothing happens.

dim-an commented 2 years ago

Are you sure, cod learned completions? I have following doubts:

You can try cod list. Does it show your command config -h?

Strongleong commented 2 years ago

1) My alias: alias config='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME' 2) I typed config --help, sorry for my mistake in original post :sweat_smile: 3) My cod list:

~ > cod list
2   /usr/bin/fd --help
3   /usr/bin/git '--git-dir=$HOME/dotfiles/' '--work-tree=$HOME' --help
5   /usr/local/bin/phpactor --help
1   /usr/bin/pip --help

Cod definitely detected help page for my alias, it can autocomplete all of git commands and flags. But do not autocomplete files(

dim-an commented 2 years ago

Are you using bash shell? Can you please show me output of complete command? (It shows how completion is configured for all of your commands).

Strongleong commented 2 years ago

I am using zsh shell. Nor complete, nor cod complete don't wokrs

dim-an commented 2 years ago

zsh stores functions used in completions in _comps map. Could you please provide output of such command

for key value in ${(kv)_comps}; do echo "$key -> $value" ; done

Strongleong commented 2 years ago

Output of this command is to long, I post it on pastebin

https://pastebin.com/zjuXtrWK

dim-an commented 2 years ago

https://pastebin.com/zjuXtrWK git -> _git

So your git command is completed using built in _git function (that's not surprising, zsh has a lot of completions by default). When cod takeovers completion of the command, entries in _comp

Example from my machine:

ipython3 -> __cod_complete_zsh
logrep -> __cod_complete_zsh
cod -> __cod_complete_zsh

So we have 2 questions:

  1. Why your default _git completion doesn't complete filenames (and I'm afraid I'm not an expert here).
  2. Why cod didn't takeover git completion. I'll take a look at that.