overseer.nvim
overseer.nvim copied to clipboard
preLaunchTask not working when using require("dap").continue()
Hi, I have the following in my launch.json
"name": "Remote GDB",
"type":"cppdbg",
"request": "launch",
"preLaunchTask": "gdb_server",
and this is part of a task in task.json
"taskName": "gdb_server",
"label": "Run remote gdb server",
"type": "shell",
"command": "launch_ssh_gdb_server.sh"
but when I launch the require("dap").continue() do not start the gdb_server task
Is there any reason why this config should not work?
https://github.com/microsoft/vscode/commit/18ca3040b1b42391501a080aef5766b2124aee7e taskName is deprecated. Use the "label" field instead in the preLaunchTask
Sorry but still no luck. Changed to
"name": "Remote GDB",
"type":"cppdbg",
"request": "launch",
"preLaunchTask": "Run remote gdb server",
and removed the label field from tasks.json but I still don't see any task running in Overseer pane
Apologies, I've been off the grid for a bit. The launch.json
file looks correct, but in your tasks.json
you should keep the label field, and remove the taskName
. You'll know it's correct if you do :OverseerRun
and "Run remote gdb server" shows up in the list of available tasks
Did exactly what you said but the preLaunchTask doesn't spawn when running nvim-dap configuration. I can see the "Run remote gdb server" item in OverseerRun list and it works if I select it, but it doesn't start automatically when I run "Remote GDB" configuration. When I call require("dap").continue(), the nvim-dap menu shows up, I select "Remote GDB" but Overseer doesn't start the preLaunchTask. How can I help you to address the problem?
This is how the tasks.json looks now:
{
"version": "2.0.0",
"tasks": [
{
"label": "Run remote gdb server",
"type": "shell",
"command": "launch_ssh_gdb_server.sh",
}
]
}
I just added a bit more logging here 2784f668c4eb2b77a002f3a4408d2a6600965662
Set the log level to TRACE and see what the output is when you run require("dap").continue()
and select "Remote GDB".
overseer.setup({
log = {
{
type = "file",
filename = "overseer.log",
level = vim.log.levels.TRACE,
},
},
})
By default the log file should be under .cache/nvim/overseer.log
. You should see a line that indicates that it's starting the preLaunchTask. If you don't, then that indicates something going wrong with the hook.
Hi, I've tried to log to a file like you suggested, but the file is empty when if I start nvim-dap with require("dap").continue()
. The logging works because I can see the logs if I start overseer task manually. It seems the preLaunchTask is not called when starting nvim-dap debug session
Are you trying to do any sort of lazy-loading for overseer? Have you called overseer.setup()
before the call to require("dap").continue()
?
Yes, I call setup() before calling require("dap").continue()
and Overseer is not lazy loaded. I have also tried to start the debug session after a start & stop of the task to be sure, but the preLaunchTask is not called.
I'm using it with NvChad, don't know if it is a useful information. Anyway, this is how I load the plugin in the "NvChad way":
["stevearc/overseer.nvim"] = {
config = function ()
require('overseer').setup({
dap = true,
log = {
{
type = "file",
filename = "overseer.log",
level = vim.log.levels.TRACE,
},
},
})
end
},
As I said, the plugin is working well on its own. I can run the task manually, but would be very helpful to me to be able to start the task when debug session starts. How can I help to understand where is the problem?
Hmmm...the fact that you're using NvChad makes me think that this is a lazy-loading or initialization-order issue. My current suspicion is that nvim-dap
isn't loaded at the time that overseer.setup()
is run.
https://github.com/stevearc/overseer.nvim/blob/2784f668c4eb2b77a002f3a4408d2a6600965662/lua/overseer/init.lua#L216-L219
Add some logs both at the top of that function and inside the early return to see if it's getting triggered.
Ok, you was right, I changed the order of the plugins and now the task starts correctly. Anyway, I have another problem now. The task starts but the debug sessions doesn't. The task stays in the "RUNNING" state because it is a gdb server that listen on a port. Does overseer waits for the task to go in "SUCCESS" state before starting the debug session?
Ah, the good news is that this works the same way as it does in VS Code. The bad news is that it's annoying in VS Code.
Basically, if you want to run a task in the background while you're debugging, the task has to be defined as isBackground
and it needs to have a problem matcher with a background property that defines when the task is "sort of complete". You can read more about this stack overflow or the discussion on this vscode issue.
The launch json looks correct, but you need to keep the "label" in tasks.json. "taskName" was deprecated to be replaced by "label".
On Thu, Aug 18, 2022, 12:09 AM redirect11 @.***> wrote:
Sorry but still no luck. Changed to
"name": "Remote GDB","type":"cppdbg","request": "launch","preLaunchTask": "Run remote gdb server",
and removed the label field from tasks.json but I still don't see any task running in Overseer pane
— Reply to this email directly, view it on GitHub https://github.com/stevearc/overseer.nvim/issues/17#issuecomment-1219076243, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD3XJ42GEAXBYQFW2VG5FLVZXHTJANCNFSM56YNIKGQ . You are receiving this because you commented.Message ID: @.***>