denisidoro / navi

An interactive cheatsheet tool for the command-line
Apache License 2.0
15.19k stars 507 forks source link

ZSH widget doesn't work with VI mode #900

Open LukasKnuth opened 5 months ago

LukasKnuth commented 5 months ago

Might be (probably is) related to https://github.com/denisidoro/navi/issues/328

Describe the bug The expected CTRL-G keymap does not do anything.

To Reproduce

  1. Setup ZSH (I'm also using oh-my-zsh)
  2. Install the https://github.com/jeffreytse/zsh-vi-mode plugin
  3. Run eval "$(navi widget zsh)" at the end of .zshrc
  4. Start console emulator (I'm using Alacritty)

Expected behavior Pressing CTRL-G opens the Navi widget.

Versions:

Additional context

Speculation

What fixes this problem for me at the moment is setting the specific keymap when binding the key:

eval "$(navi widget zsh)"
bindkey -M viins '^g' _navi_widget

I think this happens because the zsh-vi-mode plugin changes the zsh input to VI mode. Perhaps this does not set a default keymap, so the command output by navi widget zsh (which doesn't specify a keymap) isn't added anywhere. The more specific command I added does override the binding as expected.

welcome[bot] commented 5 months ago

Thanks for opening your first issue here! In case you're facing a bug, please update navi to the latest version first. Maybe the bug is already solved! :)

Frestein commented 17 hours ago
function zvm_after_lazy_keybindings() {
    zvm_bindkey vicmd '^G' _navi_widget
}

function zvm_after_init() {
    zvm_bindkey viins '^G' _navi_widget
}