-
Notifications
You must be signed in to change notification settings - Fork 95
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
WIP: Add vi-mode as built-in plugin #184
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Vi-mode | ||
|
||
Vi-mode plugin. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
# For some reason this line doesn't work inside a function, otherwise | ||
# it should be located in the _setup function. | ||
zle -N zle-keymap-select geometry_prompt_vi-mode_render | ||
geometry_prompt_vi-mode_setup() {} | ||
|
||
geometry_prompt_vi-mode_check() {} | ||
|
||
geometry_prompt_vi-mode_render() { | ||
# Removes previously state | ||
RPROMPT=${${RPROMPT/\[INSERT\] /}/\[NORMAL\] /} | ||
# swaps main/INSERT, vicmd/NORMAL | ||
local KEY=${${KEYMAP/main/INSERT}/vicmd/NORMAL} | ||
# Formats RPROMPT with mode + rest of prompt | ||
RPROMPT="[$KEY] $RPROMPT" | ||
# Resets prompt | ||
zle && zle reset-prompt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't this do an extra redraw per prompt line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I think it can be avoided though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How can it be avoided? can we just set a dirty bit somewhere? |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra newline