Skip to content

Instantly share code, notes, and snippets.

@McFrappe
Last active April 25, 2022 21:00
Show Gist options
  • Save McFrappe/7110b4ef5175168aaed80969b3027e92 to your computer and use it in GitHub Desktop.
Save McFrappe/7110b4ef5175168aaed80969b3027e92 to your computer and use it in GitHub Desktop.
Set VIM theme depending on OS theme mode. Checks OSX value `AppleInterfaceStyle` and acts accordingly.
" COLORS AND THEMING ##########################################################
function! SetBackgroundMode(...)
let g:new_bg = "light"
let g:ayucolor = "light" # If your theme supports light mode
let s:mode = systemlist("defaults read -g AppleInterfaceStyle")[0]
if s:mode ==? "Dark"
let g:ayucolor = "dark" # If your theme supports dark mode
let g:new_bg = "dark"
endif
if &background !=? g:new_bg
let &background = g:new_bg
endif
colorscheme ayu #Set your theme here
hi Normal guibg=NONE ctermbg=NONE
endfunction
call SetBackgroundMode()
call timer_start(30000,"SetBackgroundMode", {"repeat": -1})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment