1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 05:20:04 +08:00

Add number transient state

This commit is contained in:
wsdjeg 2017-11-30 00:49:36 +08:00
parent a93d86ea22
commit 4be5048c02

View File

@ -166,8 +166,46 @@ function! SpaceVim#layers#default#config() abort
let g:_spacevim_mappings_space.f.v = {'name' : '+Vim(SpaceVim)'} let g:_spacevim_mappings_space.f.v = {'name' : '+Vim(SpaceVim)'}
call SpaceVim#mapping#space#def('nnoremap', ['f', 'v', 'v'], 'let @+=g:spacevim_version | echo g:spacevim_version', 'display-and-copy-version', 1) call SpaceVim#mapping#space#def('nnoremap', ['f', 'v', 'v'], 'let @+=g:spacevim_version | echo g:spacevim_version', 'display-and-copy-version', 1)
call SpaceVim#mapping#space#def('nnoremap', ['f', 'v', 'd'], 'SPConfig', 'open-custom-configuration', 1) call SpaceVim#mapping#space#def('nnoremap', ['f', 'v', 'd'], 'SPConfig', 'open-custom-configuration', 1)
call SpaceVim#mapping#space#def('noremap', ['n', '-'], '<C-x>', 'Decrease number under cursor', 0) call SpaceVim#mapping#space#def('nnoremap', ['n', '-'], 'call call('
call SpaceVim#mapping#space#def('noremap', ['n', '+'], '<C-a>', 'Increase number under cursor', 0) \ . string(s:_function('s:number_transient_state')) . ', ["-"])',
\ 'Decrease number under cursor', 0)
call SpaceVim#mapping#space#def('nnoremap', ['n', '+'], 'call call('
\ . string(s:_function('s:number_transient_state')) . ', ["+"])',
\ 'Increase number under cursor', 0)
endfunction
function! s:number_transient_state(n) abort
if a:n ==# '+'
exe "normal! \<c-a>"
else
exe "normal! \<c-x>"
endif
let state = SpaceVim#api#import('transient_state')
call state.set_title('Number Transient State')
call state.defind_keys(
\ {
\ 'layout' : 'vertical split',
\ 'left' : [
\ {
\ 'key' : ['+','='],
\ 'desc' : 'increase number',
\ 'func' : '',
\ 'cmd' : "normal! \<c-a>",
\ 'exit' : 0,
\ },
\ ],
\ 'right' : [
\ {
\ 'key' : '-',
\ 'desc' : 'decrease number',
\ 'func' : '',
\ 'cmd' : "normal! \<c-x>",
\ 'exit' : 0,
\ },
\ ],
\ }
\ )
call state.open()
endfunction endfunction
let s:file = SpaceVim#api#import('file') let s:file = SpaceVim#api#import('file')