sindresorhus / pure

Pretty, minimal and fast ZSH prompt
MIT License
13.22k stars 977 forks source link

[ Help needed ]/Feature request: add more vim mode indicators #552

Open BachoSeven opened 4 years ago

BachoSeven commented 4 years ago

Hi, I have been enjoying this theme's vi-mode; and tried to implement indicators for Visual and Replace mode, using ideas from this config and using the syntax from this suggestion; which is the same implemented in prompt_pure_update_vim_prompt_widget() in this theme's code.

I have been struggling to get the zsh nested parameter substitiution to work; would appreciate any tips. Here is what I have come up with at the moment:

prompt_pure_update_vim_prompt_widget() {
    setopt localoptions noshwordsplit

    prompt_pure_state[prompt]=${${${${KEYMAP/virep/${PURE_PROMPT_VIREP_SYMBOL:-▶}}/(vivis|vivli)/${PURE_PROMPT_VIVIS_SYMBOL:-V}}/vicmd/${PURE_PROMPT_VICMD_SYMBOL:-❮}}/(main|viins)/${PURE_PROMPT_SYMBOL:-❯}}

    prompt_pure_reset_prompt
}

Essentially I was trying to implement a case statement inside the substitution...

If this is doable in such a way, I would do a PR as it seems like a cool feature to implement; p10k have it already but I had no luck in trying to understand how they do it (reference). I have tried p10k's implementation of pure; but it also has no replace&visual indicators.