-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimspector-bindings.vim
65 lines (53 loc) · 1.65 KB
/
vimspector-bindings.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
let s:mapped = {}
function! s:OnJumpToFrame() abort
if has_key( s:mapped, string( bufnr() ) )
return
endif
nmap <silent> <buffer> J <Plug>VimspectorStepOver
nmap <silent> <buffer> L <Plug>VimspectorStepInto
nmap <silent> <buffer> H <Plug>VimspectorStepOut
nmap <silent> <buffer> K <Plug>VimspectorStepOut
nmap <silent> <buffer> C <Plug>VimspectorContinue
nmap <silent> <buffer> I <Plug>VimspectorBalloonEval
nmap <silent> <buffer> E :call vimspector#Reset()<CR>
nmap <silent> <buffer> R <Plug>VimspectorRestart
nmap <silent> <buffer> W :VimspectorWatch <CR>
let s:mapped[ string( bufnr() ) ] = { 'modifiable': &modifiable }
setlocal nomodifiable
endfunction
function! s:OnDebugEnd() abort
let original_buf = bufnr()
let hidden = &hidden
augroup VimspectorSwapExists
au!
autocmd SwapExists * let v:swapchoice='o'
augroup END
try
set hidden
for bufnr in keys( s:mapped )
try
execute 'buffer' bufnr
silent! nunmap <buffer> J
silent! nunmap <buffer> L
silent! nunmap <buffer> H
silent! nunmap <buffer> K
silent! nunmap <buffer> C
silent! nunmap <buffer> I
silent! nunmap <buffer> E
silent! nunmap <buffer> R
silent! nunmap <buffer> W
let &l:modifiable = s:mapped[ bufnr ][ 'modifiable' ]
endtry
endfor
finally
execute 'noautocmd buffer' original_buf
let &hidden = hidden
endtry
au! VimspectorSwapExists
let s:mapped = {}
endfunction
augroup TestCustomMappings
au!
autocmd User VimspectorJumpedToFrame call s:OnJumpToFrame()
autocmd User VimspectorDebugEnded ++nested call s:OnDebugEnd()
augroup END