Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send to repl in debug mode [python] #455

Open
TheJoeSchr opened this issue Jan 13, 2023 · 3 comments
Open

Send to repl in debug mode [python] #455

TheJoeSchr opened this issue Jan 13, 2023 · 3 comments
Labels
client-python enhancement New feature or request

Comments

@TheJoeSchr
Copy link

Hi,

I love this extension. So much that I also want to use it when working with other language than clojure. I know there is already support for python, but when working on bigger projects it's often needed to debug into before you are at the right part. so just using REPL is not quite working.

long story short, there is this great debugger extension nvim-dap and nvim-dap-ui, so no need for conjure to redo this work. but also conjure does a really good job of selecting expression, running them, posting results as virtual text, etc.

So I think the ideal solution would be, if conjure could just used the REPL already running by nvim-dap. On there readme, they have a snippet how to send it to the REPL:
vnoremap <M-k> <Cmd>lua require("dapui").eval()<CR>
from: https://github.com/mfussenegger/nvim-dap-ui#evaluate-expression

How could I tell conjure to use this instead of starting it's own python REPL?
Ideally detecting if nvim-dap is running or not!

Thanks for your great work!

@Olical
Copy link
Owner

Olical commented Jan 22, 2023

I'm actually investigating Clojure DAP support at the moment, but it has nothing to do with Conjure and wouldn't benefit from it in any way as far as I can tell. DAP is entirely seperate to REPL evals as far as I know so far 🤔 https://github.com/Olical/clojure-dap

On reflection, I see what you're talking about now. I don't think this would ever be a sort of magically "if you have DAP it just uses that" sort of thing, instead it would be an entirely different client called conjure.client.python.dap, probably. So it would requiring copy/paste/editing an existing client and mapping the eval method of the client to call the dapui module's function.

Afraid there's no easy one line fix here, it requires a bit of thought and experimentation, but it's certainly possible.

Why do you want to lean on DAP specifically? Just so you can have evals + debugging in the same context? I guess that would make sense and will be the behaviour with my Clojure version since Conjure + DAP will both connect to the same running nREPL.

@Olical Olical added enhancement New feature or request client-python labels Jan 22, 2023
@TheJoeSchr
Copy link
Author

First of all, thanks so much for taking the time and reflecting on what I meant. I sometimes fail to communicate my intentions, with language not native and general laziness 😄

I have https://github.com/Olical/clojure-dap in my .vimrc since you basically created it, ready to load ;)

Why do you want to lean on DAP specifically? Just so you can have evals + debugging in the same context? I guess that would make sense and will be the behaviour with my Clojure version since Conjure + DAP will both connect to the same running nREPL.

yes that's what I meant. Just for further reference, here is my dreamworkflow. For python. Because afaik it's a clojure is already pretty great. with REPL based debugging, where you can still step into a long running program IF you had the foresight to run with nREPL.

  1. start long running python program via debugger
  2. hit (conditional) breakpoint
  3. see error
  4. write some (exploratory) code and
    4a. evaluate it via conjure + debugger REPL (so all context, libraries, etc is loaded)
    4b. until bug is fixed
  5. save edited file
  6. continue debugging
    7a. (with debugpy autoReload: { enabled: true })

I mean, if the same is possible by just using conjure with python, I would be happy as well. But I don't know how I could start a main.py with complex args and long running loop so I then latter can jack-in to it's REPL via conjure. Maybe I'm mixing concepts.

@TheJoeSchr
Copy link
Author

Maybe pre-loading something like this to every process and then connect via conjure is an easier approach: https://github.com/ionelmc/python-manhole

Afraid there's no easy one line fix here, it requires a bit of thought and experimentation, but it's certainly possible.

Also I forgot to say, I'm of course not really expecting you to support this usecase out of box. But if you could point me into the right direction, I may be able to cobble something together and then share via extension. Also just knowing it's possible helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client-python enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants