jeffreytse / zsh-vi-mode

💻 A better and friendly vi(vim) mode plugin for ZSH.
MIT License
2.94k stars 102 forks source link

some ctrl-* keybindings only work with insert mode #195

Open diminutivesloop opened 1 year ago

diminutivesloop commented 1 year ago

General information

Basic examination

Problem description

Some ctrl-* keybindings only work in insert mode. Specifically I'm using the per-directory-history zsh plugin and I cannot use ctrl-g to switch between global and directory history when in normal mode even though other keyboard commands such as ctrl-c work in both modes. I'm initializing per-directory-history via zvm_after_init and I tried disabling lazy loading via ZVM_LAZY_KEYBINDINGS=false but this didn't fix the issue.

Reproduction steps

N/A

Expected behavior

Any ctrl-* keybindings that are not assigned to this plugin should work as expected in all input modes.

cohml commented 11 months ago

Big bump for this one please!!!

jeffreytse commented 11 months ago

Hi @diminutivesloop

Thanks for your reporting, I want to confirm the bellowing items with you firstly:

  1. Is it this plugin?
  2. Are you sure, without enabling zsh-vi-mode, this plugin can work under vi normal mode?

Thanks & Regards

cohml commented 11 months ago

I'm not @diminutivesloop, but I can be another data point.

I use this plugin, which is the same as the one you linked, except that I install it via Oh-My-Zsh.

With per-directory-history enabled, here's what I've observed:

jeffreytse commented 11 months ago

@cohml Have you tried to source the plugin as below?

zvm_after_init() {
  source <your_plugin_location>/per-directory-history.plugin.zsh
}
cohml commented 11 months ago

Hey that fixes it for me!

I know your README already covers this a bit. For some reason it just hadn't occurred to me that zvm_after_init could also work with zsh plugins too.

But in retrospect that makes perfect sense. The README even mentioned zsh-autocomplete specifically... I think your bases are all already covered here 😅

Anyway, sorry for the confusion and thanks for the help! I vote to close this issue.

jeffreytse commented 11 months ago

@cohml You're welcome, and hope this plugin can accelerate your daily work. And also welcome to star this project for further updates in the future. : )

cohml commented 11 months ago

I'm still not @diminutivesloop lol, so I'd wait for him to respond before closing.

But I will star for sure. This project is great and you are a very responsive dev. Thanks again!

jeffreytse commented 11 months ago

@cohml You're welcome, welcome to submit your issues whenever you meet. : )

diminutivesloop commented 11 months ago

Hi @diminutivesloop

Thanks for your reporting, I want to confirm the bellowing items with you firstly:

1. Is it [this plugin](https://github.com/jimhester/per-directory-history)?

2. Are you sure, without enabling zsh-vi-mode, this plugin can work under vi normal mode?

Thanks & Regards

Yes that's the plugin I'm referring to. And I did just test with the regular vi-mode plugin and the issue manifests in that case as well.

cohml commented 11 months ago

@diminutivesloop Try this. Just add that to your .zshrc, adjusting the path as necessary ofc.

I had the same issue as you, and this solution seems to have fixed it.

jeffreytse commented 11 months ago

@diminutivesloop Could you try as @cohml said, and see if your issue could be settled down?

diminutivesloop commented 11 months ago

@jeffreytse That appears to work. I tried the same thing before with no success, but that may have been before I switched to installing the HEAD version of this plugin to address another issue.

Update: so I was able to fix the keybinding issue by initializing per-directory-history from zvm_after_init() however I noticed that the shortcut wasn't working exactly as expected. Instead of starting in local mode and then switching to global on ctrl+g it would start in global mode and I had to trigger the keyboard shortcut twice to get to local mode. Eventually I was able to fix both issues by including per-directory-history in my ohmyzsh plugins array in addition to sourcing it in zvm_after_init().