How do I conditionally change the status line colour?
I've figured that I can subscribe to vis.events.WIN_STATUS to get my statusline to contain exactly what I want it to, but I wish I could additionally change the background colour of the statusline according to the editor mode I'm in.
For example, the statusbar could be purple when I'm in insert mode.
Here's my best attempt at what I figure it should look like:
vis.events.subscribe(vis.events.WIN_STATUS, function(win)
if vis.mode == vis.modes.INSERT then
win:style_define(win.STYLE_STATUS, 'fore:red')
end
if vis.mode == vis.modes.NORMAL then
win:style_define(win.STYLE_STATUS, '')
end
end)
But that does nothing… no errors, just nothing. I guess I'd need to tell it to reload the style somehow, so it actually gets changed?
Is overwriting style definitions like this even supported?
Maybe I should be requesting a "mode changed" event type instead, and putting this in there?
Try win.STYLE_STATUS_FOCUSED and back:red. However, you will likely encounter some glitches where the changes do not take immediate effect.
And yes the mode change events should eventually be added, they have been requested before (e.g. #564, #525).