burke / matcher

[abandoned] Intelligently searches through a list of file names for the one you were probably looking for.
BSD 2-Clause "Simplified" License
141 stars 9 forks source link

zle widget in the example is broken #12

Open a-sk opened 11 years ago

a-sk commented 11 years ago

Please look at the similar issue - https://github.com/clvv/fasd/issues/6

I got the same error invalid widget 'menu-select'

Please, consider changing zsh widget example to something like:

zle -C matcher-complete complete-word _generic
zstyle ':completion:matcher-complete:*' completer _matcher_complete
zstyle ':completion:matcher-complete:*' menu-select
cstrahan commented 11 years ago

@a-sk / @burke: The snippet above gets me half way there. However, the completions are listed in alphabetical order, as opposed to the order that matcher writes out to stdout.

Any idea how to fix the order?

cstrahan commented 11 years ago

I looked around for other completion funcs that sort, and I wound up with something like this:

_matcher_complete() {
  integer i=1
  (git ls-files 2>/dev/null || find .) | /usr/local/bin/matcher -l20 ${words[CURRENT]} | while read line; do
    compadd -U -2 -V $i -- "$line"
    i=$((i+1))
  done
  compstate[insert]=menu
}

I'm a ZSH noob, so I could quite possible be doing plenty of stupid things in the above code. man zshcompwid has some notes on the compadd flags.

fw42 commented 11 years ago

Not sure if this is the same behaviour as before, but it kind of works for me:

_matcher() {
  (git ls-files 2>/dev/null || locate .) | /Users/flo/.vim/matcher/matcher -l20 ${words[CURRENT]} | while read line; do
    compadd -U "$line"
  done
  compstate[insert]=menu # no expand
}

zle -C matcher complete-word _generic
zstyle ':completion:matcher:*' completer _matcher
zstyle ':completion:matcher:*' menu-select

# C-t to find matches for the search under the cursor
bindkey '^T' matcher

(ping @burke)