diff --git a/autoload/SpaceVim/layers/core.vim b/autoload/SpaceVim/layers/core.vim index ee7150dc1..f2af0cef4 100644 --- a/autoload/SpaceVim/layers/core.vim +++ b/autoload/SpaceVim/layers/core.vim @@ -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', [''], 'try | b# | catch | endtry', 'last buffer', 1) + let lnum = expand('') + 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()', diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 4408c9d38..395eed408 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -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('') + 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(''), '\zs\d\+\ze__SID$') + endfunction + let s:_s = '' . 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: