Closed fecet closed 1 year ago
Thanks for the request!
I'd like to understand the use case, and set the expectations better.
Is it correct that you'd want to use this ipdb interface directly from the neovim?
But how complicated are the commands in ipdb, so you need to use vim keybinds for it? I might be wrong here, but is it as simple as p var
, n
, ... or do you use complicated commands so you'd need vim keybindings and Jupyter completion as well? Do you need arrow keys to scroll through the command history as well? For me, I wouldn't mind going to the browser and typing some commands, but your use case may be different.
Yes, I would like ipdb to be displayed as a terminal in neovim, where I can manipulate it within neovim. It is not important whether the output is displayed within neovim. Most of the time, ipdb commands are simple, but ipdb can also input any Python command, and some variable names may be long. It would be convenient if it could communicate with neovim to obtain automatic completion.
Additionally, ipdb displays the filename and line number in trace, if we could directly jump to the corresponding code snippet, we could modify it directly and use the %autoreload
magic to test the changes.
Instead of using %debug
directly in the notebook, there must be a way to connect to an existing kernel with ipdb in terminal. If you can do this, probably there's no need for Jupynium's browser synchronisation?
You are pefectly right, but I could not locate any documentation on how to connect to an existing kernel in ipdb. I have opened an issue to address this matter https://github.com/gotcha/ipdb/issues/267.
I don't know if this could be relevant, but in this plugin (https://github.com/lkhphuc/jupyter-kernel.nvim/blob/main/rplugin/python3/jupyter_kernel/__init__.py) they have a minimal python code to connect to the exiting Jupyter kernel and get completion etc. Maybe there's a same way to connect to the kernel and do something else like opening directly in terminal?
If not, I think you can find a way to connect to the existing ipython/jupyter kernel and attach to it. Maybe it's not an issue with ipdb, but with ipython? And once you have the ipython ready you can just run %debug.
https://stackoverflow.com/questions/22447572/connect-terminal-ipython-to-existing-notebook-kernel
Maybe jupyter console --existing
It seems that jupyter_client
can accomplish this task, but I haven't found a simple way to connect to an existing notebook. The jupyter console --existing
option will freeze and throw a timeout error.
I will continue to investigate and see if it can meet my needs. Thank you for your reply.
TIL there is a debugger in jupyter, namely, we can use
to enter most recent traceback, see https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-debug.
This feature is extremely useful for me, but currently I have to leave neovim and interact with ipdb command line in Jupyter. If there is a dap-like interface that can be opened in neovim, it would be a killer feature.
Normally, we may need to implement dap for ipykernel's pdb, but because jupynium runs through the browser, we only need to forward input from neovim and output from Jupyter.
This is a big request, but if you also find this feature useful, I am willing to do my best to provide help.