mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-24 05:20:04 +08:00
Add windows transient state (#1602)
* Add windows transient state * Add windows transient state
This commit is contained in:
parent
f880f996ee
commit
91bc2e930e
@ -120,9 +120,17 @@ function! SpaceVim#layers#core#config() abort
|
||||
\ . string(s:_function('s:jump_to_url')) . ', [])',
|
||||
\ 'jump to url', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['<Tab>'], 'try | b# | catch | endtry', 'last buffer', 1)
|
||||
let lnum = expand('<slnum>') + s:lnum - 1
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['b', '.'], 'call call('
|
||||
\ . string(s:_function('s:buffer_transient_state')) . ', [])',
|
||||
\ 'buffer transient state', 1)
|
||||
\ ['buffer transient state',
|
||||
\ [
|
||||
\ '[SPC b .] is to open the buffer transient state',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:filename . ':' . lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['b', 'd'], 'call SpaceVim#mapping#close_current_buffer()', 'kill this buffer', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['b', 'D'],
|
||||
\ 'call SpaceVim#mapping#kill_visible_buffer_choosewin()',
|
||||
|
@ -55,6 +55,17 @@ function! SpaceVim#mapping#space#init() abort
|
||||
\ 'call call('
|
||||
\ . string(function('s:windows_layout_toggle'))
|
||||
\ . ', [])', 'windows-layout-toggle', 1)
|
||||
let s:lnum = expand('<slnum>') + 3
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', '.'], 'call call('
|
||||
\ . string(s:_function('s:windows_transient_state')) . ', [])',
|
||||
\ ['buffer transient state',
|
||||
\ [
|
||||
\ '[SPC b .] is to open the buffer transient state',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'd'],
|
||||
\ 'close', 'delete window', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'D'],
|
||||
@ -465,4 +476,42 @@ function! s:comment_to_line(invert) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:windows_transient_state() abort
|
||||
|
||||
let state = SpaceVim#api#import('transient_state')
|
||||
call state.set_title('Buffer Selection Transient State')
|
||||
call state.defind_keys(
|
||||
\ {
|
||||
\ 'layout' : 'vertical split',
|
||||
\ 'left' : [
|
||||
\ ],
|
||||
\ 'right' : [
|
||||
\ {
|
||||
\ 'key' : 'n',
|
||||
\ 'desc' : 'next buffer',
|
||||
\ 'func' : '',
|
||||
\ 'cmd' : 'bnext',
|
||||
\ 'exit' : 0,
|
||||
\ },
|
||||
\ ],
|
||||
\ }
|
||||
\ )
|
||||
call state.open()
|
||||
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
|
||||
|
||||
" vim:set et nowrap sw=2 cc=80:
|
||||
|
Loading…
Reference in New Issue
Block a user