From bd166c76b65006f2945d5072fe07e4777c085eff Mon Sep 17 00:00:00 2001 From: gxlin Date: Tue, 16 Mar 2021 19:47:31 +0800 Subject: More vim config --- .vim/plugins/vimspector.vim | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .vim/plugins/vimspector.vim (limited to '.vim/plugins/vimspector.vim') diff --git a/.vim/plugins/vimspector.vim b/.vim/plugins/vimspector.vim new file mode 100644 index 0000000..a39d4bd --- /dev/null +++ b/.vim/plugins/vimspector.vim @@ -0,0 +1,68 @@ +Plug 'puremourning/vimspector', { 'on': 'VimspectorContinue' } + +let g:vimspector_install_gadgets = ['debugpy'] + +nmap dc VimspectorContinue +nmap dq VimspectorStop +nmap db VimspectorToggleBreakpoint +nmap dn VimspectorStepOver +nmap ds VimspectorStepInto +nmap df VimspectorStepOut +nmap di VimspectorBalloonEval +xmap di VimspectorBalloonEval + +let s:mapped = {} + +function! s:set_debug_keymaps() abort + if has_key(s:mapped, string(bufnr())) + return + endif + + " nmap c VimspectorContinue + " nmap q VimspectorStop + " nmap b VimspectorToggleBreakpoint + nmap m VimspectorStepOver + " nmap s VimspectorStepInto + " nmap f VimspectorStepOut + " nmap i VimspectorBalloonEval + " xmap i 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 c + " silent! nunmap q + " silent! nunmap b + silent! nunmap m + " silent! nunmap s + " silent! nunmap f + " silent! nunmap i + " silent! xunmap 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 -- cgit v1.2.3