Well, it didn’t work 
If you run the following command interactively:
set-face global Default default,red
…does the buffer background change to red? If not, do you get an error message (check the *debug*
buffer to be sure)?
If the background colour changes, you should be able to try the following:
# Whenever a window switches to insert mode,
# override its Default face to have a red background
hook global ModeChange .*:insert %{ set-face window Default default,red }
# Whenever a window leaves insert mode,
# remove its override of the Default face
hook global ModeChange .*:insert:.* %{ unset-face window Default }
…do I just need to change insert
with normal
in this pair of hooks?
Kakoune doesn’t just have a “current mode”, it has a “mode stack”. The top of the stack is “normal mode”, you can add an “insert” mode by pressing i
, and from insert mode you can add another temporary normal mode with <a-semicolon>
. From that temporary normal mode you can add another insert mode with i
, and keep on going until you have as many nested modes as you like.
The original hooks given by Prion would set the colorscheme to “solarized-light” every time an insert mode was entered and set the colorscheme to “solarized-dark” every time an insert mode was exited (even if there were still more insert modes still in effect). Changing those hooks from “insert” to “normal” wouldn’t do what you want, since <a-semicolon>
is the only way to push a new normal mode, and it’s hardly ever used outside scripting.
The hooks in my example above only care about “is insert the current mode” or “is insert mode no longer current”, and not about whether we got there by pushing or popping. so it should be safe to edit them from “insert” to "normal. However, a buffer usually starts in normal mode, so neither of those editing hooks would be fired, and your colours wouldn’t change until after you’d entered and left insert mode for the first time. Making the changes in response to entering/leaving insert mode just makes things a bit tidier.