]> git.r.bdr.sh - rbdr/dotfiles/blame - vim/autoload/togglebg.vim
Turn off the blur
[rbdr/dotfiles] / vim / autoload / togglebg.vim
CommitLineData
0d23b6e5
BB
1" Toggle Background
2" Modified: 2011 Apr 29
3" Maintainer: Ethan Schoonover
4" License: OSI approved MIT license
5
6if exists("g:loaded_togglebg")
7 finish
8endif
9let g:loaded_togglebg = 1
10
11" noremap is a bit misleading here if you are unused to vim mapping.
12" in fact, there is remapping, but only of script locally defined remaps, in
13" this case <SID>TogBG. The <script> argument modifies the noremap scope in
14" this regard (and the noremenu below).
15nnoremap <unique> <script> <Plug>ToggleBackground <SID>TogBG
16inoremap <unique> <script> <Plug>ToggleBackground <ESC><SID>TogBG<ESC>a
17vnoremap <unique> <script> <Plug>ToggleBackground <ESC><SID>TogBG<ESC>gv
18nnoremenu <script> Window.Toggle\ Background <SID>TogBG
19inoremenu <script> Window.Toggle\ Background <ESC><SID>TogBG<ESC>a
20vnoremenu <script> Window.Toggle\ Background <ESC><SID>TogBG<ESC>gv
21tmenu Window.Toggle\ Background Toggle light and dark background modes
22nnoremenu <script> ToolBar.togglebg <SID>TogBG
23inoremenu <script> ToolBar.togglebg <ESC><SID>TogBG<ESC>a
24vnoremenu <script> ToolBar.togglebg <ESC><SID>TogBG<ESC>gv
25tmenu ToolBar.togglebg Toggle light and dark background modes
26noremap <SID>TogBG :call <SID>TogBG()<CR>
27
28function! s:TogBG()
29 let &background = ( &background == "dark"? "light" : "dark" )
30 if exists("g:colors_name")
31 exe "colorscheme " . g:colors_name
32 endif
33endfunction
34
35if !exists(":ToggleBG")
36 command ToggleBG :call s:TogBG()
37endif
38
39function! ToggleBackground()
40 echo "Please update your ToggleBackground mapping. ':help togglebg' for information."
41endfunction
42
43function! togglebg#map(mapActivation)
44 try
45 exe "silent! nmap <unique> ".a:mapActivation." <Plug>ToggleBackground"
46 exe "silent! imap <unique> ".a:mapActivation." <Plug>ToggleBackground"
47 exe "silent! vmap <unique> ".a:mapActivation." <Plug>ToggleBackground"
48 finally
49 return 0
50 endtry
51endfunction
52
53if !exists("no_plugin_maps") && !hasmapto('<Plug>ToggleBackground')
54 call togglebg#map("<F5>")
55endif