Add support for "hot-code replace"
Describe the feature
In Metals v1.3.0 there is now support for socalled hot-code replace, see https://scalameta.org/metals/blog/2024/04/15/thalium/#debugger-improvements.
It would be very nice to have this available in Neovim with nvim-metals!
See also: https://discord.com/channels/632642981228314653/632841743435563028/1277531516821311560
Potential ways to implement
No response
I've reported both @WSA1k and @llowvxe for phishing.
So finally getting around to look at this @lervag I'm not actually seeing this as part of the DAP spec. So this may be VS Code specific behavior. I don't see any mention of it in nvim-dap as well.
Ah, I see. Perhaps we should ask for more information on the Discord channel for metals on this particular feature?
So I'm not sure Metals is actually the correct place for the discussion. I'd do the following:
- Double check the DAP spec to see if it's part of it
- If it is, then nvim-dap would need to add support for it
- If it's not, then nvim-dap would still need to build it from scratch to mimic VS Code
I'm trying to find a specification for this. It's hard! It seems to be a custom DAP extension, or something like that.
I've found a few relevant references:
- https://github.com/scalacenter/scala-debug-adapter/pull/553
- https://github.com/puremourning/vimspector/issues/252
Perhaps you are right that this is something that should be added to nvim-dap?
But it seems like this may be a more relevant reference in case we want to implement this into nvim-metals directly.
I asked for some more in one of the related issues and got a reply there. For convenience, I'm quoting it:
@levarg Our implementation is the same as https://github.com/microsoft/vscode-java-debug which does not seem to be documented anywhere.
Here is a basic description:
- recompile the project
- collect all classes that changed
- in each thread, if there is a frame in a changed class, unstack it (and all frames on top)
- ask the JVM to reload the changed classes: the spec of this depend on your JVM, most JVMs don't accept new methods in a class
- step into once