vim-test
vim-test copied to clipboard
Question: How to configure so nvim-dap is used ?
I would like to debug when I write unit tests. Is there some documentation on this ?
@DanielCardonaRojas In which language? Java?
@codeinabox Hello, I need some help/thoughts about how to make this in (Java/Maven), I have requirements in mind:
- The test command needs to start a remote debug server, to wait connection in java, must use
suspend=y
for ex:mvn test -Dmaven.surefire.debug=true
will stop waiting the attach using default port 5005 and timeout 3 minutes. - Something external of the
vim-test
(can bynvim-dap
or anything else) must attach in the correctly port. - If nothing attached to the port, the command will be stucked for 3 minutes and raise an error (that's normal).
Obs: it's ok to modify the port and timeout:
mvn -Dmaven.surefire.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y, timeout={timeout},address=*:{port}" test
port
: number
timeout
: number
milliseconds.
About maventest, may I add a a:type
like :DebugTestFile
or :DebugTestNearest
?
Or, to use an autocommand
in filetype java
to create something like:
command! -nargs=* -bar DebugTestNearest call test#run('debug_nearest', split(<q-args>))
command! -nargs=* -bar DebugTestFile call test#run('debug_file', split(<q-args>))
Propose
If the type
is debug_file or debug_nearest
, the test with maven can use the commands mentioned before, but a configuration of nvim-dap
, viminspector
or anything else to attach to it still needed.
nvim-dap
For java, it's pretty simple:
-- nvim dap - java configs
local dap = require("dap")
-- java
dap.configurations.java = {
{
type = 'java';
request = 'attach';
name = "Debug (Attach) - Remote";
hostName = "127.0.0.1";
port = 5005;
},
}
["<F5>"] = { dap.continue, 'Debug continue or attach' }
Notes that port used in nvim-dap
must match the port used in the remote debug protocol in the maven command in vim-test
.
In summary, it's not a "full integration with nvim-dap", it's a simple use of the remote debug protocol interface.
In this approach, the user must trigger dap.continue
after :DebugTestFile or DebugTestNearest
.
I don't feel right, vim-test
to call dap.continue
, it's like a sort of coupling
of plugins, and the attach can be triggered by any other plugin or external debugger interface, not just nvim-dap
.
I will raise a draft PR with the minimal implementation.
@codeinabox @DanielCardonaRojas #744
As per my comment in the PR, I think it's best to pass the debug option using TestFile -Dmaven.surefire.debug=true
instead of introducing new commands.