jeffreytse / zsh-vi-mode

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

Unable to define zvm_config outside of zsh-vi-mode.zsh #193

Closed VeryDampTowel closed 12 months ago

VeryDampTowel commented 1 year ago

General information

Basic examination

Problem description

When cloning this repo, it seems that the only way to set custom options such as escape keys is inside zsh-vi-mode.zsh. I've tried defining the zvm_config function in my .zshrc file but that does not appear to work as the escape key still shows as the default. Is the intended behavior to only define customizations in zsh-vi-mode.zsh? If so, then this makes it difficult to maintain customizations while also maintaining the latest version of ZVM.

Function I am trying to add:

function zvm_config() {
  ZVM_LINE_INIT_MODE=$ZVM_MODE_INSERT
  ZVM_VI_ESCAPE_BINDKEY=jj
}

To clarify, this works if I define the above function in zsh-vi-mode.zsh, but I would like to have this function in my .zshrc config so I could pull any updates to ZVM without losing my configurations.

Reproduction steps

  1. Pull project
  2. Define above function in .zshrc
  3. Restart terminal and $ZVM_VI_ESCAPE_BINDKEY is still default option.

Expected behavior

Ability to define customizations outside of zsh-vi-mode.zsh

jeffreytse commented 1 year ago

Hi @parispjones,

Sorry for the late working on this reporting issue, I think this issue was related to #206 and has been fixed. Could you try again with the latest version?

Thanks & Regards

VeryDampTowel commented 12 months ago

Hi @jeffreytse,

It looks like it's still not working for me.

function zvm_config() {
  ZVM_LINE_INIT_MODE=$ZVM_MODE_INSERT
  ZVM_VI_ESCAPE_BINDKEY=jj
}
source ~/.zsh-vi-mode.zsh
  1. Add above function to .zshrc
  2. Reload zsh
  3. Cry because it doesn't work.
jeffreytse commented 12 months ago

Hi @parispjones

As $ZVM_VI_ESCAPE_BINDKEY was an early stage variable, you can config it by the following code snippets:

zvm_config() {
    ZVM_VI_ESCAPE_BINDKEY=jj
    ZVM_VI_INSERT_ESCAPE_BINDKEY=$ZVM_VI_ESCAPE_BINDKEY
    ZVM_VI_VISUAL_ESCAPE_BINDKEY=$ZVM_VI_ESCAPE_BINDKEY
    ZVM_VI_OPPEND_ESCAPE_BINDKEY=$ZVM_VI_ESCAPE_BINDKEY
}

source ~/zsh-vi-mode.zsh

or

# Config before sourcing the plugin
ZVM_VI_ESCAPE_BINDKEY=jj

source ~/zsh-vi-mode.zsh

Thanks & Regards

VeryDampTowel commented 12 months ago

Confirmed it works now! You rock.