Insert mode with background shade

I’d like to have the background color shade slightly lighter once I’m in insert mode.
It’s just that looking to the right bottom corner is just too far away.

How could I achieve this?

# Dracula – A dark theme (https://draculatheme.com)
declare-option str background 'rgb:282a36'
declare-option str dimmed_background 'rgb:44475a'
declare-option str foreground 'rgb:f8f8f2'

# Dimmed background
hook -always global ModeChange 'push:normal:insert' %{
  set-face window Default "%opt{foreground},%opt{dimmed_background}"
}

# Restore background
hook -always global ModeChange 'pop:insert:normal' %{
  set-face window Default "%opt{foreground},%opt{background}"
}

EDIT: Update with hook -always.

3 Likes

Very nice, thank you!

@alexherbo2 I’ve got a follow up question.
Is it possible to also make this happen on using: \o & \i - since its my standard way of pasting from the clipboard. Or is there a better workaround?

\o and \i per definition don’t execute hooks, so that won’t work.
I paste from clipboard using the method described in the wiki which uses the ! command.

Edit: It seems I was wrong, I’m sorry. See @alexherbo2’s answer.

Yes it is possible using hook -always.

2 Likes