lincheney / fzf-tab-completion

Tab completion using fzf
GNU General Public License v3.0
623 stars 40 forks source link

How to customize and add colors? #69

Open lime-desu opened 1 year ago

lime-desu commented 1 year ago

Sorry, not related issue but since I wanted to customize fzf-tab-completion (on zsh) and add colors to distinguish folders and files

lincheney commented 1 year ago

Hi This is not something that comes out of the box right now (to be more specific, even if you set zstyle ':completion:*:ABC' list-colors XYZ, it won't show up in color) This might be something I implement in the future (or I am open to PRs also). Otherwise, you may look at https://github.com/Aloxaf/fzf-tab instead which I believe does do the coloring already.

lime-desu commented 1 year ago

Thank you very much! I did try fzf-tab though I've had many problems with my zsh configuration.

Btw when reassigning it on different key bindings how can i disable the tab? (pressing tab again will trigger fzf-tab-completion as i rebind it on ctrl+tab)

lincheney commented 1 year ago

Not exactly sure what you mean by this. Can you provide more detail? What are you expecting to happen when you press tab? (possibly helpful: you can check what keys do what by running bindkey)

lime-desu commented 1 year ago

Sure this is a different issue but following the installation method doesn't work on my zsh setup. It gives me this following error message:

/home/void/.local/share/oh-my-zsh/custom/plugins/fzf-tab-completion/zsh/fzf-zsh-completion.sh:7: parse error near `|'

# this is what i put on my .rc
source $ZSH/custom/plugins/fzf-tab-completion/zsh/fzf-zsh-completion.sh
bindkey '^I' fzf_completion

So I am using my own fork, and which I've submitted a pull request too, since the standard installation process doesn't work on mine.

Going back to the issue which I've asked before (pressing tab again will trigger fzf-tab-completion as i rebind it on ctrl+tab)

But hey, I've reread the installation process carefully and I've found the culprit:

If you have also enabled fzf's zsh completion, then the bindkey line is optional.

This note above, and this snippet below is what caused of my problem

# resource fzf completion `**` doesn't work when using on fedora + zsh-autocomplete
# [[ -e /usr/share/zsh/site-functions/fzf ]] && source /usr/share/zsh/site-functions/fzf

(Since I'm resourcing again the fzf completion key because it doesn't work on my fedora machine before)

Now this is what my assigned bindkey (ctrl-tab): bindkey '^[[27;5;9~' fzf_completion an works as inteded (i've removed resourcing the fzf_completion so when pressing tab it wouldn't trigger it)

Though I've resolved my problem another issue occur, that I can't use the fzf **completion, but if either I enable it again now pressing tab will trigger fzf-tab-completion and will conflict tab completion with zsh-autocomplete.

such dilemma haha, so yeah I chose the latter, rebinded to ctrl-tab though no ** completion for me :(

lincheney commented 1 year ago

On your first one: there is no | on line 7 of https://github.com/lincheney/fzf-tab-completion/blob/master/zsh/fzf-zsh-completion.sh#L7, so not sure what is happening there.

On your second one: yeah i guess this is an unfortunate effect of the way the two repos work together. You can always try something like bindkey '\t' expand-or-complete afterwards to restore the old tab-key behaviour (or set it to some other zsh widget as well).

lime-desu commented 1 year ago

Ok so I find a decent solution towards my problem. (this commit fixes it lime-desu/dootsfile@f010e11).

Now another question, (sorry if i'm asking too much), I've seen this screencast: https://raw.githubusercontent.com/lincheney/fzf-tab-completion/master/example.svg. On the first example how can i do that directory expansion thing? What's your zsh configuration? I've tried on mine ls /u/s/zsh i don't get such expansion (directory exist)

lincheney commented 1 year ago

uhhhh tbh I'm not actually sure. This is a zsh setting (which means its independent of fzf-tab-completion) I tried with a default zsh and was able to get it working with just a compinit

//tmp/% zsh -f
localhost% autoload -U compinit 
localhost% compinit
localhost% ls /u/s/zsh # tab expands to ls /usr/share/zsh/

for reference, here are some of the options I have in my .zshrc, but I'm not sure which bits are relevant

zstyle ':completion:*' add-space true
zstyle ':completion:*' completer _expand _complete _ignored _match _correct _approximate _prefix
zstyle ':completion:*' completions 1
zstyle ':completion:*' glob 1
zstyle ':completion:*' group-name ''
zstyle ':completion:*' insert-unambiguous true
zstyle ':completion:*' list-suffixes true
zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]}'
zstyle ':completion:*' match-original both
zstyle ':completion:*' preserve-prefix '//[^/]##/'
zstyle ':completion:*' substitute 1
zstyle ':completion:*' insert-tab false
zstyle ':completion:*' verbose true
lime-desu commented 1 year ago

Yes, thank you very much! The compinit will do the job.