From 170060d4914ef5d0e9aa094a44e5c1d9c1abb02a Mon Sep 17 00:00:00 2001 From: Blallo Date: Mon, 13 May 2019 16:05:54 +0200 Subject: [PATCH] Easy breakpoints and other stuff for python. --- ftplugin/python.vim | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/ftplugin/python.vim b/ftplugin/python.vim index 88b24d2..29881ef 100644 --- a/ftplugin/python.vim +++ b/ftplugin/python.vim @@ -32,11 +32,11 @@ function! ChangePythonLineLength() abort let &l:colorcolumn = l:line_length + 1 endfunction -call ChangePythonLineLength() +" call ChangePythonLineLength() let b:ale_linters = ['flake8'] let b:ale_fixers = [ -\ 'remove_trailing_lines', +\ 'black', \ 'autopep8', \ 'yapf', \] @@ -63,3 +63,21 @@ if !empty(s:virtualenv) \ . ' ' . ale#Escape(ale#path#Dirname(s:virtualenv) . '/manage.py') . ' test' endif endif + +if !exists("g:python_debugger") + let g:python_debugger = 'ipdb' +endif +let g:python_debug_line = 'import ' . g:python_debugger . '; ' . g:python_debugger . '.set_trace()' + +function! InsertBreakpoint() abort + let l:curr_indent = indent(line(".")) + let l:line = '' + while l:curr_indent > 0 + let l:line .= ' ' + let l:curr_indent -= 1 + endwhile + let l:line = l:line . g:python_debug_line + :put =l:line +endfunction + +nnoremap d :call InsertBreakpoint()