forked from python-mode/python-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbreakpoint.vim
More file actions
45 lines (33 loc) · 1005 Bytes
/
breakpoint.vim
File metadata and controls
45 lines (33 loc) · 1005 Bytes
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
fun! pymode#breakpoint#init() "{{{
if !g:pymode_breakpoint
return
endif
if g:pymode_breakpoint_cmd == ''
let g:pymode_breakpoint_cmd = 'import pdb; pdb.set_trace() # XXX BREAKPOINT'
if g:pymode_python == 'disable'
return
endif
endif
PymodePython << EOF
from imp import find_module
for module in ('pudb', 'ipdb'):
try:
find_module(module)
vim.command('let g:pymode_breakpoint_cmd = "import %s; %s.set_trace() # XXX BREAKPOINT"' % (module, module))
break
except ImportError:
continue
EOF
endfunction "}}}
fun! pymode#breakpoint#operate(lnum) "{{{
let line = getline(a:lnum)
if strridx(line, g:pymode_breakpoint_cmd) != -1
normal dd
else
let plnum = prevnonblank(a:lnum)
call append(line('.')-1, repeat(' ', indent(plnum)).g:pymode_breakpoint_cmd)
normal k
endif
" Save file without any events
call pymode#save()
endfunction "}}}