Metals implements the Debug Adapter Protocol, which can be used by the editor to communicate with JVM to run and debug code.
How to add support for debugging in my editor?
The editor needs to handle two commands in its language client extension:
Those commands should get executed automatically by the lsp client once the user
activates a code lens. The difference between them is that the former ignores
all breakpoints being set while the latter respects them. The procedure of
starting the run/debug session is as follows:
- Request the debug adapter uri from metals server using the
- Connect the debug adapter extension specific to you editor using the aforementioned uri and let it drive the run/debug session. For reference, take a look at the vscode implementation and how it is wired up together
Create the following trace files to spy on incoming/outgoing JSON communication between the debug server and editor.
server.trace.json touch ~/Library/Caches/org.scalameta.metals/dap-client.trace.json touch ~/.cache/metals/dap-server.trace.json touch ~/.cache/metals/dap-client.trace.jsontouch ~/Library/Caches/org.scalameta.metals/dap-