diff options
author | gxlin <[email protected]> | 2021-07-15 21:28:06 +0800 |
---|---|---|
committer | gxlin <[email protected]> | 2021-07-15 21:28:06 +0800 |
commit | d4e1469e4b0c5aaf5c23be555e8b224f9254d781 (patch) | |
tree | e68a0e5dd44ee43efc2d70c081f41ae3237a78c1 /.vim/plugin/vimspector.plug | |
parent | 36f249e1a7250e24f0c415b5bc53ba1b2f5806d4 (diff) | |
download | dotfiles-d4e1469e4b0c5aaf5c23be555e8b224f9254d781.tar.gz dotfiles-d4e1469e4b0c5aaf5c23be555e8b224f9254d781.tar.bz2 dotfiles-d4e1469e4b0c5aaf5c23be555e8b224f9254d781.zip |
A usable boostrap config
Diffstat (limited to '.vim/plugin/vimspector.plug')
-rw-r--r-- | .vim/plugin/vimspector.plug | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/.vim/plugin/vimspector.plug b/.vim/plugin/vimspector.plug new file mode 100644 index 0000000..a39d4bd --- /dev/null +++ b/.vim/plugin/vimspector.plug @@ -0,0 +1,68 @@ +Plug 'puremourning/vimspector', { 'on': '<Plug>VimspectorContinue' } + +let g:vimspector_install_gadgets = ['debugpy'] + +nmap <silent> <Leader>dc <Plug>VimspectorContinue +nmap <silent> <Leader>dq <Plug>VimspectorStop +nmap <silent> <Leader>db <Plug>VimspectorToggleBreakpoint +nmap <silent> <Leader>dn <Plug>VimspectorStepOver +nmap <silent> <Leader>ds <Plug>VimspectorStepInto +nmap <silent> <Leader>df <Plug>VimspectorStepOut +nmap <silent> <Leader>di <Plug>VimspectorBalloonEval +xmap <silent> <Leader>di <Plug>VimspectorBalloonEval + +let s:mapped = {} + +function! s:set_debug_keymaps() abort + if has_key(s:mapped, string(bufnr())) + return + endif + + " nmap <silent> <buffer> c <Plug>VimspectorContinue + " nmap <silent> <buffer> q <Plug>VimspectorStop + " nmap <silent> <buffer> b <Plug>VimspectorToggleBreakpoint + nmap <silent> <buffer> m <Plug>VimspectorStepOver + " nmap <silent> <buffer> s <Plug>VimspectorStepInto + " nmap <silent> <buffer> f <Plug>VimspectorStepOut + " nmap <silent> <buffer> i <Plug>VimspectorBalloonEval + " xmap <silent> <buffer> i <Plug>VimspectorBalloonEval + + let s:mapped[string(bufnr())] = {'modifiable': &modifiable} + + setlocal nomodifiable +endfunction + +function! s:unset_debug_keymaps() abort + let original_buf = bufnr() + let hidden = &hidden + + try + set hidden + for bufnr in keys(s:mapped) + try + execute 'noautocmd buffer' bufnr + " silent! nunmap <buffer> c + " silent! nunmap <buffer> q + " silent! nunmap <buffer> b + silent! nunmap <buffer> m + " silent! nunmap <buffer> s + " silent! nunmap <buffer> f + " silent! nunmap <buffer> i + " silent! xunmap <buffer> i + + let &l:modifiable = s:mapped[bufnr]['modifiable'] + endtry + endfor + finally + execute 'noautocmd buffer' original_buf + let &hidden = hidden + endtry + + let s:mapped = {} +endfunction + +augroup CustomMappings + au! + autocmd User VimspectorJumpedToFrame call s:set_debug_keymaps() + autocmd User VimspectorDebugEnded call s:unset_debug_keymaps() +augroup end |