Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add vi-mode plugin #272

Draft
wants to merge 9 commits into
base: mnml
Choose a base branch
from
25 changes: 25 additions & 0 deletions functions/geometry_vi.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# A geometry plugin to display the ZLE vi-mode state.

update_rprompt() {
RPROMPT=${${RPROMPT/\[NORMAL\]/}/\[INSERT\]/}
RPROMPT="[$1]$RPROMPT"
}

update_prompt() {
PROMPT=${${PROMPT/\[NORMAL\]/}/\[INSERT\]/}
PROMPT="[$1]$PROMPT"
}

function zle-keymap-select {
alxbl marked this conversation as resolved.
Show resolved Hide resolved
keymap=$([[ $KEYMAP == vicmd ]] && echo "NORMAL" || echo "INSERT")
(( ${GEOMETRY_RPROMPT[(i)geometry_vi]} <= ${#GEOMETRY_RPROMPT} )) && update_rprompt $keymap
(( ${GEOMETRY_PROMPT[(i)geometry_vi]} <= ${#GEOMETRY_PROMPT} )) && update_prompt $keymap
zle reset-prompt
}

zle -N zle-keymap-select
alxbl marked this conversation as resolved.
Show resolved Hide resolved

geometry_vi() {
# Empty render function, these are handled by zle-keymap-select
}
alxbl marked this conversation as resolved.
Show resolved Hide resolved