~gpanders/dotfiles

ref: c8e63bac959db19c138dcc3198a56514f0b444ff dotfiles/.vim/autoload/toggle_bg.vim -rw-r--r-- 608 bytes
c8e63bacGreg Anders Manage dotfiles directly in home directory 1 year, 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
" See :h xterm-true-color
if !has('nvim')
  let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
  let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif

function! toggle_bg#toggle()
  if exists('g:toggle_bg_dark') && exists('g:toggle_bg_light')
    if !&termguicolors
      set termguicolors
    endif

    if g:colors_name ==# g:toggle_bg_dark
      execute 'colorscheme' g:toggle_bg_light
    else
      execute 'colorscheme' g:toggle_bg_dark
    endif
  else
    " If no colorschemes are defined then just toggle the bg setting
    if &bg ==# 'dark'
      set bg=light
    else
      set bg=dark
    endif
  endif
endfunction