nvim-metals icon indicating copy to clipboard operation
nvim-metals copied to clipboard

Add support for "hot-code replace"

Open lervag opened this issue 1 year ago • 7 comments

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

lervag avatar Aug 26 '24 10:08 lervag

I've reported both @WSA1k and @llowvxe for phishing.

lervag avatar Aug 26 '24 10:08 lervag

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.

ckipp01 avatar Sep 16 '24 13:09 ckipp01

Ah, I see. Perhaps we should ask for more information on the Discord channel for metals on this particular feature?

lervag avatar Sep 17 '24 07:09 lervag

So I'm not sure Metals is actually the correct place for the discussion. I'd do the following:

  1. Double check the DAP spec to see if it's part of it
  2. If it is, then nvim-dap would need to add support for it
  3. If it's not, then nvim-dap would still need to build it from scratch to mimic VS Code

ckipp01 avatar Sep 18 '24 09:09 ckipp01

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?

lervag avatar Sep 18 '24 09:09 lervag

But it seems like this may be a more relevant reference in case we want to implement this into nvim-metals directly.

lervag avatar Sep 18 '24 09:09 lervag

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

lervag avatar Sep 18 '24 10:09 lervag