65bbd24eec6b64f2f526c974781f08373277be0c

Author
bretello <bretello@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(vi-mode): add `INSERT_MODE_INDICATOR` (#9732)

Co-authored-by: bretello <bretello@distruzione.org>

Diff

 1diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md
 2index 46bb6d07008ac69be8dd47d306b410c25dc13f2c..a1d6bc6b0b99bf6cd4ceaa381a92e369d081b3b5 100644
 3--- a/plugins/vi-mode/README.md
 4+++ b/plugins/vi-mode/README.md
 5@@ -32,16 +32,21 @@ plugins=(... vi-mode)
 6 - `MODE_INDICATOR`: controls the string displayed when the shell is in normal mode.
 7   See [Mode indicator](#mode-indicator) for details.
 8 
 9-## Mode indicator
10+- `INSERT_MODE_INDICATOR`: controls the string displayed when the shell is in insert mode.
11+  See [Mode indicator](#mode-indicator) for details.
12+
13+## Mode indicators
14 
15 *Normal mode* is indicated with a red `<<<` mark at the right prompt, when it
16-hasn't been defined by theme.
17+hasn't been defined by theme, *Insert mode* is not displayed by default.
18 
19-You can change this indicator by setting the `MODE_INDICATOR` variable. This setting
20-supports Prompt Expansion sequences. For example:
21+You can change these indicators by setting the `MODE_INDICATOR` (*Normal mode*) and
22+`INSERT_MODE_INDICATORS` (*Insert mode*) variables.
23+This settings support Prompt Expansion sequences. For example:
24 
25 ```zsh
26-MODE_INDICATOR="%F{yellow}+%f"
27+MODE_INDICATOR="%F{white}+%f"
28+INSERT_MODE_INDICATOR="%F{yellow}+%f"
29 ```
30 
31 You can also use the `vi_mode_prompt_info` function in your prompt, which will display
32diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh
33index dd4afdd8b4f90f4a39c5bb4a2ca04fa63f6b794c..b40b29961d739ad95ed06af02d229d1a5548ee7e 100644
34--- a/plugins/vi-mode/vi-mode.plugin.zsh
35+++ b/plugins/vi-mode/vi-mode.plugin.zsh
36@@ -123,7 +123,7 @@ wrap_clipboard_widgets copy vi-yank vi-yank-eol vi-backward-kill-word vi-change-
37 wrap_clipboard_widgets paste vi-put-{before,after}
38 unfunction wrap_clipboard_widgets
39 
40-# if mode indicator wasn't setup by theme, define default
41+# if mode indicator wasn't setup by theme, define default, we'll leave INSERT_MODE_INDICATOR empty by default
42 if [[ -z "$MODE_INDICATOR" ]]; then
43   MODE_INDICATOR='%B%F{red}<%b<<%f'
44 fi
45@@ -136,7 +136,7 @@ function vi_mode_prompt_info() {
46   # set RPS1/RPROMPT to something else in their custom config.
47   : "${VI_MODE_RESET_PROMPT_ON_MODE_CHANGE:=true}"
48 
49-  echo "${${VI_KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/}"
50+  echo "${${VI_KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/$INSERT_MODE_INDICATOR}"
51 }
52 
53 # define right prompt, if it wasn't defined by a theme