vimr
vimr copied to clipboard
Detect macOS Dark Mode
Recommending that we copy MacVim to allow changing colorscheme when macOS dark mode is toggled: https://github.com/macvim-dev/macvim/pull/929
It adds a OSAppearanceChanged event and a v:os_appearance var:
" inside ~/.vimrc
func! ChangeBackground()
if (v:os_appearance == 1)
set background=dark
colorscheme onedark
else
set background=light
colorscheme bclear
endif
redraw!
endfunc
if has("gui_vimr")
call ChangeBackground()
au OSAppearanceChanged * call ChangeBackground()
endif
In the meantime, I use dark-notify for that.
This is a good idea.