aboutsummaryrefslogtreecommitdiffstats
path: root/autoload
diff options
context:
space:
mode:
authorGravatar Ethan Schoonover <es@ethanschoonover.com>2011-04-12 16:17:59 -0700
committerGravatar Ethan Schoonover <es@ethanschoonover.com>2011-04-12 16:17:59 -0700
commit4a9b7ecc66e6a451e273befcf418d36cb7167637 (patch)
treec7f602500bea56e34fb64f7c8880c6a3bb427b03 /autoload
parent4727d3afd6ac9278e4e5dcee6762ed8bb3501eef (diff)
downloadvim-colors-solarized-4a9b7ecc66e6a451e273befcf418d36cb7167637.tar.gz
updated vim solarized togglebg plugin to fix silent error on unique remapping
Diffstat (limited to 'autoload')
-rw-r--r--autoload/togglebg.vim47
1 files changed, 47 insertions, 0 deletions
diff --git a/autoload/togglebg.vim b/autoload/togglebg.vim
new file mode 100644
index 0000000..f060cee
--- /dev/null
+++ b/autoload/togglebg.vim
@@ -0,0 +1,47 @@
+" Toggle background
+" Last Change: April 7, 2011
+" Maintainer: Ethan Schoonover
+" License: OSI approved MIT license
+
+if exists("g:loaded_togglebg")
+ finish
+endif
+let g:loaded_togglebg = 1
+
+" noremap is a bit misleading here if you are unused to vim mapping.
+" in fact, there is remapping, but only of script locally defined remaps, in
+" this case <SID>TogBG. The <script> argument modifies the noremap scope in
+" this regard (and the noremenu below).
+nnoremap <unique> <script> <Plug>ToggleBackground <SID>TogBG
+inoremap <unique> <script> <Plug>ToggleBackground <ESC><SID>TogBG<ESC>a
+vnoremap <unique> <script> <Plug>ToggleBackground <ESC><SID>TogBG<ESC>gv
+nnoremenu <script> Window.Toggle\ Background <SID>TogBG
+inoremenu <script> Window.Toggle\ Background <ESC><SID>TogBG<ESC>a
+vnoremenu <script> Window.Toggle\ Background <ESC><SID>TogBG<ESC>gv
+noremap <SID>TogBG :call <SID>TogBG()<CR>
+
+function! s:TogBG()
+ let &background = ( &background == "dark"? "light" : "dark" ) | exe "colorscheme " . g:colors_name
+endfunction
+
+if !exists(":ToggleBG")
+ command ToggleBG :call s:TogBG()
+endif
+
+function! ToggleBackground()
+ echo "Please update your ToggleBackground mapping. ':help togglebg' for information."
+endfunction
+
+function! togglebg#map(mapActivation)
+ try
+ exe "silent! nmap <unique> ".a:mapActivation." <Plug>ToggleBackground"
+ exe "silent! imap <unique> ".a:mapActivation." <Plug>ToggleBackground"
+ exe "silent! vmap <unique> ".a:mapActivation." <Plug>ToggleBackground"
+ finally
+ return 0
+ endtry
+endfunction
+
+if !exists("no_plugin_maps") && !hasmapto('<Plug>ToggleBackground')
+ call togglebg#map("<F5>")
+endif