sillybun / vim-repl

Best REPL environment for Vim
GNU General Public License v2.0
446 stars 39 forks source link

Cannot get ipdb to work #112

Closed flenzen closed 3 years ago

flenzen commented 3 years ago

Describe the bug The readme page does not sufficiently explain how to get debugging using ipdb running. With how I understand the readme, I cannot get ipdb debugging to work.

Samples The samples are taken using the following python code:

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b,a%b)
print(gcd(60,48))

Variant 1. The cursor is placed in line 2. I open the ipython terminal using :REPLToggle. I see the ipython-prompt. With the python code active, I issue :REPLDebugStopAtCurrentLine. ipython receives the command tbreak 2, which fails:

In [1]: tbreak 2
  File "<ipython-input-1-32f0c35095e8>", line 1
    tbreak 2
           ^
SyntaxError: invalid syntax

In [2]: c
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-2b66fd261ee5> in <module>
----> 1 c

NameError: name 'c' is not defined

obviously, this code is intended for ipdb, which is installed.

Variant 2 I do the same, but without the ipython terminal open. When I issue REPLDebugStopAtCurrentLine, I get

"ZYTREPL1 [führe aus]" [Verändert] --Keine Zeilen im Puffer--
"ZYTREPL1 [führe aus]" [Verändert] --Keine Zeilen im Puffer--
"ZYTREPL1 [führe aus]" [Verändert] --Keine Zeilen im Puffer--

(more lines appearing; it should translate as something like "ZYTREPL1 [executing]" [changed] --No lines in buffer--.

Desktop (please complete the following information): vim: 8.2 python: 3.9.0 ipython: 7.19.0 ipdb3: 0.13.7


**Additional context**
relevant part of the vimrc:

noremap :REPLToggle let g:repl_program = { \ 'python': 'ipython', \ 'default': 'zsh', \ } let g:repl_exit_commands = { \ 'ipython': 'quit()', \ 'python3': 'quit()' \ } let g:repl_python_auto_send_unfinish_line = 1 let g:repl_cursor_down = 1 let g:repl_python_automerge = 1 let g:repl_python_auto_import = 1 let g:repl_ipython_version = '7.19' autocmd Filetype python nnoremap :REPLDebugStopAtCurrentLine autocmd Filetype python nnoremap :REPLPDBN autocmd Filetype python nnoremap :REPLPDBS

sillybun commented 3 years ago

The reason is that you haven't install ipdb

install it via:

python -m pip install ipdb

Then use Variant 2

flenzen commented 3 years ago

I have ipdb installed. Since my default ipython runs python3, I have ipdb installed using ˋpython3 -m pip install ipdbˋ. Still, variant 2 is not working. Do you have a clue where my fault could lie instead?

sillybun commented 3 years ago

Can you check whether: python -m ipdb works or not?

sillybun commented 3 years ago

Update the plugin and check if it works.

flenzen commented 3 years ago

With python2 (which is my default python), it works. Do you know how can I configure vim-repl to work with ipdb3?

sillybun commented 3 years ago

I have update the plugin, you can configure it via:

    let g:repl_program = {
        \   'python': 'ipython',
        \   'python-debug': 'python3 -m ipdb',
        \   'default': 'zsh',
        \   'r': 'R',
        \   'lua': 'lua',
        \   'vim': 'vim -e',
        \   'snippets': 'ipython',
        \   }

In your case you can change your configuration to:

noremap <C-r> :REPLToggle<cr>
let g:repl_program = {
            \   'python': 'ipython',
            \   'python-debug': 'ipdb3',
            \   'default': 'zsh',
            \   }
let g:repl_exit_commands = {
            \   'ipython': 'quit()',
            \   'python3': 'quit()'
            \ }
let g:repl_python_auto_send_unfinish_line = 1
let g:repl_cursor_down = 1
let g:repl_python_automerge = 1
let g:repl_python_auto_import = 1
let g:repl_ipython_version = '7.19'
autocmd Filetype python nnoremap <F12> <Esc>:REPLDebugStopAtCurrentLine<Cr>
autocmd Filetype python nnoremap <F10> <Esc>:REPLPDBN<Cr>
autocmd Filetype python nnoremap <F11> <Esc>:REPLPDBS<Cr>
flenzen commented 3 years ago

That helped, thank you very much for your quick help!