diff --git a/autoload/SpaceVim/layers/debug.vim b/autoload/SpaceVim/layers/debug.vim index 1e3f6b34c..836b48f4f 100644 --- a/autoload/SpaceVim/layers/debug.vim +++ b/autoload/SpaceVim/layers/debug.vim @@ -11,12 +11,15 @@ function! SpaceVim#layers#debug#config() abort call SpaceVim#mapping#space#def('nnoremap', ['d', 'c'], 'VBGcontinue', 'Continue the execution', 1) call SpaceVim#mapping#space#def('nnoremap', ['d', 'o'], 'VBGstepOver', 'step over', 1) call SpaceVim#mapping#space#def('nnoremap', ['d', 'i'], 'VBGstepIn', 'step into functions', 1) - call SpaceVim#mapping#space#def('nnoremap', ['d', 'o'], 'VBGstepOut', 'step out of current function', 1) + call SpaceVim#mapping#space#def('nnoremap', ['d', 'O'], 'VBGstepOut', 'step out of current function', 1) call SpaceVim#mapping#space#def('nnoremap', ['d', 'k'], 'VBGkill', 'Terminates the debugger', 1) let g:_spacevim_mappings_space.d.e = {'name' : '+Evaluate/Execute'} call SpaceVim#mapping#space#def('nnoremap', ['d', 'e', 's'], 'VBGevalSelectedText', 'Evaluate and print the selected text', 1) call SpaceVim#mapping#space#def('nnoremap', ['d', 'e', 'e'], 'VBGevalWordUnderCursor', 'Evaluate the under the cursor', 1) call SpaceVim#mapping#space#def('nnoremap', ['d', 'e', 'S'], 'VBGexecuteSelectedText', 'Execute the selected text', 1) + call SpaceVim#mapping#space#def('nnoremap', ['d', '.'], 'call call(' + \ . string(s:_function('s:buffer_transient_state')) . ', [])', + \ 'debug transient state', 1) endfunction function! SpaceVim#layers#debug#launching(ft) abort @@ -30,3 +33,61 @@ function! SpaceVim#layers#debug#launching(ft) abort echohl None endif endfunction + +function! s:buffer_transient_state() abort + let state = SpaceVim#api#import('transient_state') + call state.set_title('Debug Transient State') + call state.defind_keys( + \ { + \ 'layout' : 'vertical split', + \ 'left' : [ + \ { + \ 'key' : 'o', + \ 'desc' : 'step over', + \ 'func' : '', + \ 'cmd' : 'VBGstepOver', + \ 'exit' : 0, + \ }, + \ { + \ 'key' : 'i', + \ 'desc' : 'step into functions', + \ 'func' : '', + \ 'cmd' : 'VBGstepIn', + \ 'exit' : 0, + \ }, + \ ], + \ 'right' : [ + \ { + \ 'key' : 'O', + \ 'desc' : 'step out of current function', + \ 'func' : '', + \ 'cmd' : 'VBGstepOut', + \ 'exit' : 0, + \ }, + \ { + \ 'key' : 'k', + \ 'desc' : 'Terminates the debugger', + \ 'func' : '', + \ 'cmd' : 'VBGkill', + \ 'exit' : 1, + \ }, + \ ], + \ } + \ ) + 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 diff --git a/docs/layers/debug.md b/docs/layers/debug.md index ca6db7b73..5433e93b9 100644 --- a/docs/layers/debug.md +++ b/docs/layers/debug.md @@ -36,3 +36,9 @@ To use this configuration layer, add `call SpaceVim#layers#load('debug')` to you | `SPC d e e` | Evaluate the `` under the cursor | | `SPC d e S` | Execute the selected text | | `SPC d k` | Terminates the debugger | + +**Debug Transient State** + +key bindings is too long? use `SPC d .` to open the debug transient state: + +![Debug Transient State](https://user-images.githubusercontent.com/13142418/33995923-16171792-e0a5-11e7-8a10-3624adcbba91.png)