Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Qubitol opened this issue Feb 22, 2023 · 4 comments
Open

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

Qubitol opened this issue Feb 22, 2023 · 4 comments

Comments

@Qubitol
Copy link

Qubitol commented Feb 22, 2023

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
Copy link

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
Copy link

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
 }

@chevcast
Copy link

chevcast commented Jun 7, 2024

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 😃

chevcast pushed a commit to chevcast/fzf-git.sh that referenced this issue Jun 7, 2024
chevcast pushed a commit to chevcast/fzf-git.sh that referenced this issue Jun 7, 2024
chevcast pushed a commit to chevcast/fzf-git.sh that referenced this issue Jun 7, 2024
chevcast pushed a commit to chevcast/fzf-git.sh that referenced this issue Jun 7, 2024
chevcast pushed a commit to chevcast/fzf-git.sh that referenced this issue Jun 7, 2024
@julianinsua
Copy link

I had this issue and found it hard to configure the bindings... I needed some documentation to make it work. I finally managed to pull it off, but I don't know if this is the right solution. It might help someone else though. For reference: I'm using tmux, the vi-mode plugin for tmux, the neovim-tmux navigation plugin (all my Ctrl+h,j,k,l are taken) and zsh as a shell:

# Rebinding fzf-git to use alt instead of ctrl
# define functions
fzf_git_branches_widget() {
  _fzf_git_branches
}
fzf_git_hashes_widget() {
  _fzf_git_hashes
}
fzf_git_reflogs_widget() {
  _fzf_git_lreflogs
}
fzf_git_files_widget() {
  _fzf_git_files
}
fzf_git_tags_widget() {
  _fzf_git_tags
}
fzf_git_remotes_widget() {
  _fzf_git_remotes
}
fzf_git_stashes_widget() {
  _fzf_git_stashes
}
fzf_git_worktrees_widget() {
  _fzf_git_worktrees
}
fzf_git_eachref_widget() {
  _fzf_git_each_ref
}

# Register functions as widgets
zle -N fzf_git_branches_widget # register branches widget
zle -N fzf_git_hashes_widget # register hashes widget
zle -N fzf_git_reflogs_widget # register log widget
zle -N fzf_git_files_widget # register files widget
zle -N fzf_git_tags_widget # register tags widget
zle -N fzf_git_remotes_widget # register remotes widget
zle -N fzf_git_stashes_widget # register stashes widget
zle -N fzf_git_worktrees_widget # register worktrees widget
zle -N fzf_git_eachref_widget # register eachref widget

bindkey '\eg\eb' fzf_git_branches_widget
bindkey '\eg\eh' fzf_git_hashes_widget
bindkey '\eg\el' fzf_git_reflogs_widget
bindkey '\eg\ef' fzf_git_files_widget
bindkey '\eg\et' fzf_git_tags_widget
bindkey '\eg\er' fzf_git_remotes_widget
bindkey '\eg\es' fzf_git_stashes_widget
bindkey '\eg\ew' fzf_git_worktrees_widget
bindkey '\eg\ee' fzf_git_eachref_widget

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants