using dlv no output fix (#25)
This commit is contained in:
parent
28bbafeeb9
commit
7de6a600f2
@ -73,22 +73,35 @@ M.run = function(...)
|
||||
end
|
||||
local dap = require "dap"
|
||||
dap.adapters.go = function(callback, config)
|
||||
local stdout = vim.loop.new_pipe(false)
|
||||
local handle
|
||||
local pid_or_err
|
||||
local port = 38697
|
||||
handle, pid_or_err = vim.loop.spawn("dlv", {
|
||||
stdio = {nil, stdout},
|
||||
args = {"dap", "-l", "127.0.0.1:" .. port},
|
||||
detached = true
|
||||
}, function(code)
|
||||
stdout:close()
|
||||
handle:close()
|
||||
print("Delve exited with exit code: " .. code)
|
||||
if code ~= 0 then
|
||||
print("Delve exited with exit code: ", code)
|
||||
end
|
||||
end)
|
||||
assert(handle, "Error running dlv: " .. tostring(pid_or_err))
|
||||
stdout:read_start(function (err, chunk)
|
||||
assert(not err, err)
|
||||
if chunk then
|
||||
vim.schedule(function ()
|
||||
require("dap.repl").append(chunk)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
-- Wait 100ms for delve to start
|
||||
vim.defer_fn(function()
|
||||
dap.repl.open()
|
||||
callback({type = "server", host = "127.0.0.1", port = port})
|
||||
end, 100)
|
||||
|
||||
end
|
||||
|
||||
local dap_cfg = {
|
||||
|
Loading…
Reference in New Issue
Block a user