junegunn / fzf-git.sh

bash and zsh key bindings for Git objects, powered by fzf
511 stars 46 forks source link

Keybindings do not work in case one uses zsh-vi-mode plugin #23

Open Qubitol opened 1 year ago

Qubitol commented 1 year ago

Hi, thank you for creating this amazing tool: fzf has been an absolute game-changer for me.

I had trouble in making the keybindings of fzf-git work after having installed zsh-vi-mode plugin. I solved this issue by re-creating the keybindings according to what is advised in the zsh-vi-mode README, namely by doing:

# Set keybindings for zsh-vi-mode insert mode
function zvm_after_init() {
    zvm_bindkey viins "^P" up-line-or-beginning-search
    zvm_bindkey viins "^N" down-line-or-beginning-search
    for o in files branches tags remotes hashes stashes each_ref; do
        eval "zvm_bindkey viins '^g^${o[1]}' fzf-git-$o-widget"
        eval "zvm_bindkey viins '^g${o[1]}' fzf-git-$o-widget"
    done
}
# Set keybindings for zsh-vi-mode normal and visual modes
function zvm_after_lazy_keybindings() {
    for o in files branches tags remotes hashes stashes each_ref; do
        eval "zvm_bindkey vicmd '^g^${o[1]}' fzf-git-$o-widget"
        eval "zvm_bindkey vicmd '^g${o[1]}' fzf-git-$o-widget"
        eval "zvm_bindkey visual '^g^${o[1]}' fzf-git-$o-widget"
        eval "zvm_bindkey visual '^g${o[1]}' fzf-git-$o-widget"
    done
}

I guess there is nothing to do from your side, maybe you could consider adding a little statement on the README.

Thanks.

bergtholdt commented 9 months ago

Works for me, only thing that lreflogs is missing in the list of widgets:

# Set keybindings for zsh-vi-mode insert mode
function zvm_after_init() {
    zvm_bindkey viins "^P" up-line-or-beginning-search
    zvm_bindkey viins "^N" down-line-or-beginning-search
    for o in files branches tags remotes hashes stashes lreflogs each_ref; do
        eval "zvm_bindkey viins '^g^${o[1]}' fzf-git-$o-widget"
        eval "zvm_bindkey viins '^g${o[1]}' fzf-git-$o-widget"
    done
}
# Set keybindings for zsh-vi-mode normal and visual modes
function zvm_after_lazy_keybindings() {
    for o in files branches tags remotes hashes stashes lreflogs each_ref; do
        eval "zvm_bindkey vicmd '^g^${o[1]}' fzf-git-$o-widget"
        eval "zvm_bindkey vicmd '^g${o[1]}' fzf-git-$o-widget"
        eval "zvm_bindkey visual '^g^${o[1]}' fzf-git-$o-widget"
        eval "zvm_bindkey visual '^g${o[1]}' fzf-git-$o-widget"
    done
}
raulchen commented 1 month ago

Thanks for providing this solution. I found that unbinding ^G before sourcing fzf-git can also fix this issue.

function zvm_after_init() {
    bindkey -r '^G'  
    source fzf-git.sh
 }
catdadcode commented 4 weeks ago

Thank you guys! I had no idea what my issue even was as I have had zsh-vi-mode installed for a long time already. Glad this issue was right here 😃