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
35 lines (26 loc) · 989 Bytes
/
breakpoint.vim
File metadata and controls
35 lines (26 loc) · 989 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
" DESC: Set scriptname
let g:scriptname = expand("<sfile>:t")
" OPTION: g:pymode_breakpoint -- bool. Breakpoints enabled
call helpers#SafeVar("g:pymode_breakpoint", 1)
" OPTION: g:pymode_breakpoint_key -- string. Key for set/unset breakpoint.
call helpers#SafeVar("g:pymode_breakpoint_key", "<leader>b")
" DESC: Disable script loading
if helpers#SafeVar("b:breakpoint", 1) || g:pymode_breakpoint == 0
finish
endif
" DESC: Set or unset breakpoint
" ARGS: lnum -- int, number of current line
fun! <SID>:BreakPoint(lnum) "{{{
let import = "import ipdb; ipdb.set_trace() ### XXX BREAKPOINT"
let line = getline(a:lnum)
if strridx(line, import) != -1
normal dd
return 1
endif
let plnum = prevnonblank(a:lnum)
let indent = indent(plnum)
call append(line('.') - 1, repeat(' ', indent) . import)
normal k
endfunction "}}}
" DESC: Set keys
exe "nnoremap <silent> <buffer> " g:pymode_breakpoint_key ":call <SID>:BreakPoint(line('.'))<CR>"