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

Merge pull request #1214 from SpaceVim/win_leader

Add: Win leader guide
This commit is contained in:
Wang Shidong 2017-12-31 01:35:02 -06:00 committed by GitHub
commit 6c822cb770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 30 deletions

View File

@ -605,6 +605,9 @@ call SpaceVim#mapping#guide#register_prefix_descriptions(
call SpaceVim#mapping#guide#register_prefix_descriptions( call SpaceVim#mapping#guide#register_prefix_descriptions(
\ g:spacevim_denite_leader, \ g:spacevim_denite_leader,
\ 'g:_spacevim_mappings_denite') \ 'g:_spacevim_mappings_denite')
call SpaceVim#mapping#guide#register_prefix_descriptions(
\ g:spacevim_windows_leader,
\ 'g:_spacevim_mappings_windows')
call SpaceVim#mapping#guide#register_prefix_descriptions( call SpaceVim#mapping#guide#register_prefix_descriptions(
\ '[KEYs]', \ '[KEYs]',
\ 'g:_spacevim_mappings_prefixs') \ 'g:_spacevim_mappings_prefixs')

View File

@ -121,36 +121,50 @@ endfunction
function! SpaceVim#mapping#leader#defindWindowsLeader(key) abort function! SpaceVim#mapping#leader#defindWindowsLeader(key) abort
if !empty(a:key) if !empty(a:key)
call zvim#util#defineMap('nnoremap', '[Window]', '<Nop>', exe 'nnoremap <silent><nowait> [Window] :<c-u>LeaderGuide "' .
\ 'Defind window prefix', 'normal [Window]') \ a:key . '"<CR>'
call zvim#util#defineMap('nmap' , a:key, '[Window]', exe 'nmap ' .a:key . ' [Window]'
\ 'Use ' . a:key . ' as window prefix', 'normal ' . a:key) let g:_spacevim_mappings_windows = {}
nnoremap <silent> [Window]p
call zvim#util#defineMap('nnoremap <silent>', '[Window]p', \ :<C-u>vsplit<CR>:wincmd w<CR>
\ ':<C-u>vsplit<CR>:wincmd w<CR>', let g:_spacevim_mappings_windows.p = ['vsplit | wincmd w',
\ 'vsplit vertically,switch to next window','vsplit | wincmd w') \ 'vsplit vertically,switch to next window']
call zvim#util#defineMap('nnoremap <silent>', '[Window]v', nnoremap <silent> [Window]v
\ ':<C-u>split<CR>', 'split window', 'split') \ :<C-u>split<CR>
call zvim#util#defineMap('nnoremap <silent>', '[Window]g', let g:_spacevim_mappings_windows.v = ['split',
\ ':<C-u>vsplit<CR>', 'vsplit window', 'vsplit') \ 'split window']
call zvim#util#defineMap('nnoremap <silent>', '[Window]t', nnoremap <silent> [Window]g
\ ':<C-u>tabnew<CR>', 'Create new tab', 'tabnew') \ :<C-u>vsplit<CR>
call zvim#util#defineMap('nnoremap <silent>', '[Window]o', let g:_spacevim_mappings_windows.g = ['vsplit',
\ ':<C-u>only<CR>', 'Close other windows', 'only') \ 'vsplit window']
call zvim#util#defineMap('nnoremap <silent>', '[Window]x', nnoremap <silent> [Window]t
\ ':<C-u>call zvim#util#BufferEmpty()<CR>', \ :<C-u>tabnew<CR>
\ 'Empty current buffer', 'call zvim#util#BufferEmpty()') let g:_spacevim_mappings_windows.t = ['tabnew',
call zvim#util#defineMap('nnoremap <silent>', '[Window]\', \ 'create new tab']
\ ':<C-u>b#<CR>', 'Switch to the last buffer','b#') nnoremap <silent> [Window]o
call zvim#util#defineMap('nnoremap <silent>', '[Window]q', \ :<C-u>only<CR>
\ ':<C-u>close<CR>', 'Close current windows','close') let g:_spacevim_mappings_windows.o = ['only',
call zvim#util#defineMap('nnoremap <silent>', '[Window]Q', \ 'Close other windows']
\ ':<C-u>call SpaceVim#mapping#close_current_buffer()<CR>', nnoremap <silent> [Window]x
\ 'delete current windows', \ :<C-u>call zvim#util#BufferEmpty()<CR>
\ 'call SpaceVim#mapping#close_current_buffer()') let g:_spacevim_mappings_windows.x = ['call zvim#util#BufferEmpty()',
call zvim#util#defineMap('nnoremap <silent>', '[Window]c', \ 'Empty current buffer']
\ ':<C-u>call SpaceVim#mapping#clearBuffers()<CR>', nnoremap <silent> [Window]\
\ 'Clear all the buffers', 'call SpaceVim#mapping#clearBuffers()') \ :<C-u>b#<CR>
let g:_spacevim_mappings_windows['\'] = ['b#',
\ 'Switch to the last buffer']
nnoremap <silent> [Window]q
\ :<C-u>close<CR>
let g:_spacevim_mappings_windows.q = ['close',
\ 'Close current windows']
nnoremap <silent> [Window]Q
\ :<C-u>call SpaceVim#mapping#close_current_buffer()<CR>
let g:_spacevim_mappings_windows.Q = ['call SpaceVim#mapping#close_current_buffer()',
\ 'delete current windows']
nnoremap <silent> [Window]c
\ :<C-u>call SpaceVim#mapping#clearBuffers()<CR>
let g:_spacevim_mappings_windows.c = ['call SpaceVim#mapping#clearBuffers()',
\ 'Clear all the buffers']
endif endif
endfunction endfunction
@ -304,6 +318,8 @@ function! SpaceVim#mapping#leader#getName(key) abort
return '[g]' return '[g]'
elseif a:key == 'z' elseif a:key == 'z'
return '[z]' return '[z]'
elseif a:key == g:spacevim_windows_leader
return '[WIN]'
else else
return '<leader>' return '<leader>'
endif endif
@ -315,6 +331,8 @@ function! SpaceVim#mapping#leader#defindKEYs() abort
call extend(g:_spacevim_mappings_prefixs[g:spacevim_unite_leader], g:_spacevim_mappings_unite) call extend(g:_spacevim_mappings_prefixs[g:spacevim_unite_leader], g:_spacevim_mappings_unite)
let g:_spacevim_mappings_prefixs[g:spacevim_denite_leader] = {'name' : '+Denite prefix'} let g:_spacevim_mappings_prefixs[g:spacevim_denite_leader] = {'name' : '+Denite prefix'}
call extend(g:_spacevim_mappings_prefixs[g:spacevim_denite_leader], g:_spacevim_mappings_denite) call extend(g:_spacevim_mappings_prefixs[g:spacevim_denite_leader], g:_spacevim_mappings_denite)
let g:_spacevim_mappings_prefixs[g:spacevim_windows_leader] = {'name' : '+Window prefix'}
call extend(g:_spacevim_mappings_prefixs[g:spacevim_windows_leader], g:_spacevim_mappings_windows)
endfunction endfunction