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

disable vi mode show only for insert mode #205

Closed
ferdinandyb opened this issue Jul 8, 2022 · 9 comments
Closed

disable vi mode show only for insert mode #205

ferdinandyb opened this issue Jul 8, 2022 · 9 comments
Labels
NYI/NewFeat Not yet implemented or New Feature

Comments

@ferdinandyb
Copy link

I haven't been able to find such on option, but since in a terminal insert mode is really the default I only want to show any other modes, but not insert mode.

@akinomyoga
Copy link
Owner

akinomyoga commented Jul 8, 2022

Thank you for the suggestion! This is not what you have suggested, but I think you might like the setting described in #85 (comment), where you can remove ble/prompt/print $'\e[1m-- INSERT --\e[m'. Could you try the setting and tell me what you would think of it?

@ferdinandyb
Copy link
Author

thanks, looks like something that would work for me! I'll check soon :)

@ferdinandyb
Copy link
Author

So I spent a little time trying out the example you linked. It seems to add a vim-airline like capability, and it's probably by poor bash skills, but I didn't manage to set it up in a way, that during insert mode it is not shown at all (commenting out the line with the print INSERT will actually just drop the case down to ?????) and setting this empty in case of insert mode still leaves the color bar at the bottom so one would have to catch insert mode one more level higher really.

On the hand I'm mostly happy with the base set up, since I could just set bleopt keymap_vi_mode_name_insert=INSERT to empty. The only problem with this, is that because of this line (which for some reason is at 379 in the version install under .local) even if I set bleopt keymap_vi_mode_name_insert=, I'll still see the two -- surrounding the mode information. A workaround could be to remove this line, but make the default settings to include these, or to introduce a new option with the default surrounding characters, or a similar option like the one normal mode has. I guess the easiest and least disruptive would be a new option for the surrounding characters. Although probably you may see even better alternatives.

Btw, thank you very being so very responsive!

@akinomyoga
Copy link
Owner

(commenting out the line with the print INSERT will actually just drop the case down to ?????)

As I wrote in the first reply, you could actually remove ble/prompt/print $'\e[1m-- INSERT --\e[m' instead of commenting the entire line out.

setting this empty in case of insert mode still leaves the color bar at the bottom

Maybe you can set the face to none? The status bar is still present but will not be so outstanding with none. Here's an example:

function ferdinandyb/set-up-status-line {
  bleopt keymap_vi_mode_show=
  bleopt keymap_vi_mode_update_prompt=1

  function ble/prompt/backslash:ferdinandyb/currentmode {
    local mode; ble/keymap:vi/script/get-mode
    case $mode in
    (*n)  ble/prompt/print $'\e[1m-- NORMAL --\e[m' ;;
    (*v)  ble/prompt/print $'\e[1m-- VISUAL --\e[m' ;;
    (*V)  ble/prompt/print $'\e[1m-- V-LINE --\e[m' ;;
    (*^V) ble/prompt/print $'\e[1m-- V-BLOQ --\e[m' ;;
    (*s)  ble/prompt/print $'\e[1m-- SELECT --\e[m' ;;
    (*S)  ble/prompt/print $'\e[1m-- S-LINE --\e[m' ;;
    (*^S) ble/prompt/print $'\e[1m-- S-BLOQ --\e[m' ;;
    (i)   ;;
    (R)   ble/prompt/print $'\e[1m-- RPLACE --\e[m' ;;
    (^R)  ble/prompt/print $'\e[1m-- VPLACE --\e[m' ;;
    (*)   ble/prompt/print $'\e[1m-- ?????? --\e[m' ;;
    esac

    ble-face prompt_status_line=none
  }

  bleopt prompt_status_line='\q{ferdinandyb/currentmode}'
}
blehook/eval-after-load keymap_vi ferdinandyb/set-up-status-line

ble/keymap:vi/update-mode-name just implements what Vim does, where only the mode names can change depending on the locale. In Vim, nothing else can be configurable. The options bleopt keymap_vi_mode_name_* are just prepared to specify the localized name of the modes but not intended for adjusting the appearance. It is in principle possible to provide hundreds of bleopt options to tweak every corner of the behavior of the Vim mode indicator, but I wouldn't like to do that. Rather, I would like to just provide users a way to write their own functions to produce the mode indicator. This is actually the reason that I recommend disabling the default mode indicator and showing the tailored mode indicator implemented by the user in the status line. For example, vim-airline uses this approach in Vim.

A workaround could be to remove this line, but make the default settings to include these,

This doesn't work because ble.sh implements the combination of modes as in Vim, so the mode indicator doesn't always show a single-mode name but can be a combination of several modes. If we just include -- in the mode name, for example, in the single-command blockwise visual mode, the mode marker will become (-- insert --) -- VISUAL -- -- BLOCK -- instead of -- (insert) VISUAL BLOCK --, which is not something we want. As in #57 (comment), there are 30 possible combinations of modes, and I don't want to provide 30 options to configure each combination one by one.

or to introduce a new option with the default surrounding characters,

I don't think this can be used to turn off the mode indicator only for the insert mode. If we make it an empty string, it also makes the surrounding characters of other modes empty. Or, we might prepare the options of the surrounding characters for each mode, but again, I don't want to provide 30+30 prefix and suffix options to control the surrounding strings for each mode combination.

or a similar option like the one normal mode has.

The normal mode is strictly not a mode but a special mode combination that no modes are activated. On the other hand, the insert mode is a mode that can be combined with other modes. And, as I have already written, I don't want to provide 30 options to control each mode combination separately.

I guess the easiest and least disruptive would be a new option for the surrounding characters. Although probably you may see even better alternatives.

I'm now thinking of adding another prompt shown in the position where the built-in mode indicator is currently shown.

@ferdinandyb
Copy link
Author

Thanks for the very detailed explanation! The snippet you provided actually does pretty much what I wanted so I'll go with it now, although if you do implement a prompt at the below-the-line position, I might revisit this topic. Thanks again!

@akinomyoga
Copy link
Owner

if you do implement a prompt at the below-the-line position, I might revisit this topic. Thanks again!

I have implemented bleopt prompt_vi_mode_indicator in commit 2b905f8. To suppress the mode indicator only in the insert mode, you can use e.g. the following setting:

# blerc

function ferdinandyb/set-up-mode-indicator {
  # Define \q{ferdinandyb/mode-indicator}
  function ble/prompt/backslash:ferdinandyb/mode-indicator {
    if local mode; ble/keymap:vi/script/get-mode; [[ $mode != i ]]; then
      # call the built-in mode indicator
      ble/prompt/process-prompt-string '\q{keymap:vi/mode-indicator}'
    fi
  }

  # Specify \q{ferdinandyb/mode-indicator} in the mode-indicator prompt
  bleopt prompt_vi_mode_indicator='\q{ferdinandyb/mode-indicator}'

  # In case you would like to show "-- NORMAL --" instead of "~"
  bleopt keymap_vi_mode_string_nmap=$'\e[1m-- NORMAL --\e[m'
}
blehook/eval-after-load keymap_vi ferdinandyb/set-up-mode-indicator

Could you try it and let me hear what you think?

@akinomyoga
Copy link
Owner

@ferdinandyb Have you already taken a look at this? Can I close the issue if you are satisfied with the current implementation?

@ferdinandyb
Copy link
Author

Sorry, I seemed to have missed this update, but it works as expected, thank you very much for fixing all the issues so fast!

@akinomyoga
Copy link
Owner

OK, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NYI/NewFeat Not yet implemented or New Feature
Projects
None yet
Development

No branches or pull requests

2 participants