using dlv no output fix (#25)

This commit is contained in:
schwartx 2021-08-25 20:37:22 +08:00 committed by GitHub
parent 28bbafeeb9
commit 7de6a600f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 = {