zsh-vi-mode
zsh-vi-mode copied to clipboard
Plugin overriding custom keymaps defined with bindkey
General information
- Terminal program: WezTerm 20240812-215703-30345b36 (xterm-256color), Iterm2
- Operating system: macOS 14.7 (23H124)
- ZSH framework: None
- ZSH version: zsh 5.9 (x86_64-apple-darwin23.0)
- ZVM version: zsh-vi-mode 0.11.0
Basic examination
- [x] I have read through the README page
- [x] I have the latest version of zsh-vi-mode
- [x] I have tested with another terminal program
Problem description
The plugin seems to override the custom keymaps defined with bindkey
for custom zle widgets. Here is a minimal .zshrc
cd ..
zle reset-prompt
zle accept-line
}
# Create the widget
zle -N cd_up_widget
bindkey '^U' cd_up_widget
source ~/.zsh/plugins/zsh-vi-mode/zsh-vi-mode.plugin.zsh
I have gone through the section in the readme that talks about strategies to deal with zvm overriding the keymaps and I followed the last option as mentioned below to workaround this issue
source ~/.zsh/plugins/zsh-vi-mode/zsh-vi-mode.plugin.zsh
cd_up_widget() {
cd ..
zle reset-prompt
zle accept-line
}
function zvm_after_init() {
zle -N cd_up_widget
bindkey '^U' cd_up_widget
}
Although this works, I am not sure if this is the best way to deal with this because it slowly has started to bloat where I have to put a lot of stuff here.
function zvm_after_init() {
source <(fzf --zsh)
zle -N cd_up_widget
bindkey '^U' cd_up_widget
bindkey '^[[A' history-substring-search-up # up
bindkey '^[[B' history-substring-search-down # down
}
So I am wondering if there is a better way to handle this.
Reproduction steps
- Create the zle widget and bindkey with minimal
.zshrc
- Source the plugin
- Try the keymap bound with
bindkey
Expected behavior
Plugin should not override any keymaps which are not set explicitly by this plugin else it can break functionality of lot of other plugins or custom widgets user may have written on their own.