jeffreytse / zsh-vi-mode

šŸ’» A better and friendly vi(vim) mode plugin for ZSH.
MIT License
3.13k stars 109 forks source link

Conflict with Zsh-autopair #185

Closed Tainted-Fool closed 1 year ago

Tainted-Fool commented 2 years ago

General information

Basic examination

Problem description

All my plugins were working properly until I introduced this plugin into the mix. Basically, this plugin conflicts with (zsh-autopair)[https://github.com/hlissner/zsh-autopair] . When I remove this plugin zsh-vi-mode, zsh-autopair works. The autopair plugin does not get initialized if I enable this plugin.

For example as soon as I press quotation mark " I should get another " right next to the cursor i.e. autopair. However, when I enable this, the pair does not show up unless I run source ~/.zshrc or initialize the autopair with autopair-init

Reproduction steps

  1. Add this to ~/.zshrc file:
    source ~/.zsh-autopair/autopair.zsh
    source ~/.zsh-vi-mode/zsh-vi-mode.plugin.zsh
    autopair-init
  2. Close terminal and re-open
  3. Try to trigger autopair by typing ', ", (, etc.
  4. Notice no pair - need to manually source or initialize autopair to fix

Expected behavior

Autopair to trigger as soon as you open a terminal. I don't mind initializing autopair but it should do it on its own based on the ~/.zshrc settings. Apart from that, I am loving the plugin so far! Keep up the good work šŸ˜„

musjj commented 1 year ago

This happens because zsh-vi-mode is lazy-loaded. This can cause some unpredictable things to happen, despite having the correct load order in your ~/.zshrc.

The simplest solution is to turn off lazy-loading by doing:

ZVM_INIT_MODE=sourcing

Or you can also do something like:

zvm_after_init_commands=(autopair-init)
Anomalocaridid commented 1 year ago

For posterity and just in case it helps someone with the same problem, setting ZVM_INIT_MODE=sourcing didn't help, but setting zvm_after_init_commands=(autopair-init) did.

Also it might be helpful to set AUTOPAIR_INIT_INHIBIT=1 so you don't initialize zsh-autopair twice.

Tainted-Fool commented 1 year ago

@musjj and @Anomalocaridid suggested fixed my issue. Thank you very much for the help. You guys rock!