From d4e1469e4b0c5aaf5c23be555e8b224f9254d781 Mon Sep 17 00:00:00 2001 From: gxlin Date: Thu, 15 Jul 2021 21:28:06 +0800 Subject: A usable boostrap config --- .vim/plugin/vimspector.plug | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .vim/plugin/vimspector.plug (limited to '.vim/plugin/vimspector.plug') 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': '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