1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 02:30:03 +08:00

Add toggle theme mapping

This commit is contained in:
wsdjeg 2017-04-18 23:55:34 +08:00
parent 32d52c4db5
commit c354ee5232
3 changed files with 48 additions and 1 deletions

View File

@ -173,3 +173,29 @@ function! SpaceVim#layers#colorscheme#plugins() abort
\ ['jacoborus/tender'],
\ ]
endfunction
let s:cs = ['gruvbox', 'molokai', 'onedark', 'jellybeans']
let s:Number = SpaceVim#api#import('data#number')
function! SpaceVim#layers#colorscheme#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['T', 'n'],
\ 'call call(' . string(s:_function('s:cycle_spacevim_theme'))
\ . ', [])', 'cycle-spacevim-theme', 1)
endfunction
" function() wrapper
if v:version > 703 || v:version == 703 && has('patch1170')
function! s:_function(fstr) abort
return function(a:fstr)
endfunction
else
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
let s:_s = '<SNR>' . s:_SID() . '_'
function! s:_function(fstr) abort
return function(substitute(a:fstr, 's:', s:_s, 'g'))
endfunction
endif
function! s:cycle_spacevim_theme() abort
let id = s:Number.random(0, len(s:cs))
exe 'colorscheme ' . s:cs[id]
endfunction

View File

@ -22,4 +22,24 @@ function! SpaceVim#layers#ui#config() abort
let g:signify_disable_by_default = 0
let g:signify_line_highlight = 0
noremap <silent> <F2> :TagbarToggle<CR>
" Ui toggles
call SpaceVim#mapping#space#def('nnoremap', ['T', 'F'], '<F11>', 'fullscreen-frame', 0)
call SpaceVim#mapping#space#def('nnoremap', ['T', 'm'], 'call call(' . string(s:_function('s:toggle_menu_bar')) . ', [])', 'menu-bar', 1)
endfunction
" function() wrapper
if v:version > 703 || v:version == 703 && has('patch1170')
function! s:_function(fstr) abort
return function(a:fstr)
endfunction
else
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
let s:_s = '<SNR>' . s:_SID() . '_'
function! s:_function(fstr) abort
return function(substitute(a:fstr, 's:', s:_s, 'g'))
endfunction
endif
function! s:toggle_menu_bar() abort
echom 1
endfunction

View File

@ -6,7 +6,8 @@ function! SpaceVim#mapping#space#init() abort
nmap <Space> [SPC]
let g:_spacevim_mappings_space = {}
let g:_spacevim_mappings_space['?'] = ['Unite menu:CustomKeyMaps -input=[SPC]', 'show mappings']
let g:_spacevim_mappings_space.t = {'name' : '+Toggle editor visuals'}
let g:_spacevim_mappings_space.t = {'name' : '+Toggles'}
let g:_spacevim_mappings_space.T = {'name' : '+UI toggles/themes'}
let g:_spacevim_mappings_space.a = {'name' : '+Applications'}
let g:_spacevim_mappings_space.b = {'name' : '+Buffers'}
let g:_spacevim_mappings_space.f = {'name' : '+Files'}