kdheepak / nvim-dap-julia

MIT License
15 stars 0 forks source link

Show next "event" #2

Open fredrikekre opened 4 months ago

fredrikekre commented 4 months ago

With Debugger.jl in the REPL I find the About to run: foo(...) status extremely useful. Is this something that can be displayed in neovim? I guess it might require some custom method implemented in DebugAdapter.jl (I could not find an official DAP request for this).

kdheepak commented 4 months ago

nvim-dap has support for extensions

==============================================================================
LISTENERS EXTENSIONS API                                       *dap-listeners*

nvim-dap supports subscribing and listening to all responses or events that a
debug adapter might send to nvim-dap.

...

Please refer to the Debug Adapter Protocol specification to get a list of all
events or requests and their response formats:

- https://microsoft.github.io/debug-adapter-protocol/specification#Requests
- https://microsoft.github.io/debug-adapter-protocol/specification#Events

For example:

>lua
  local dap = require('dap')
  dap.listeners.before['event_terminated']['my-plugin'] = function(session, body)
    print('Session terminated', vim.inspect(session), vim.inspect(body))
  end
<

Currently when I subscribe to event_stopped this is what I get for the body:

{
  reason = "step",
  threadId = 1
}

It looks like that message you are referring to is generated as part of Debugger.jl in https://github.com/JuliaDebug/Debugger.jl/blob/c0972c986a5cc0a335dad9888c4ac5eff1c848ce/src/printing.jl#L84

But DebugAdapter.jl to my understanding doesn't use Debugger.jl at all. If there's a similar event generated from DebugAdapter.jl we can set it up easily to subscribe to that event and print out a message in neovim.

fredrikekre commented 4 months ago

But DebugAdapter.jl to my understanding doesn't use Debugger.jl at all.

No it doesn't but they both use JuliaInterpreter as the backend. We would have to copy the logic from Debugger to DebugAdapter.

I guess it is this type: https://microsoft.github.io/debug-adapter-protocol/specification#Events_Stopped in that case we can probably add this information as the description field or text field?

kdheepak commented 4 months ago

Yes, I think the events_stopped is the right place for this. I guess we should open an issue on DebugAdapter.jl, I won't get a chance to do it until later this week though.