dap options for time out issue #263 🎄🎆

pull/274/head
ray-x 1 year ago
parent 0f72dbdd87
commit b53dfd4fdb

@ -104,7 +104,9 @@ _GO_NVIM_CFG = {
dap_debug_keymap = true, -- true: use keymap for debugger defined in go/dap.lua
-- false: do not use keymap in go/dap.lua. you must define your own.
dap_vt = true, -- false, true and 'all frames'
dap_port = 38697, -- can be set to a number or `-1` so go.nvim will pickup a random port
dap_port = 38697, -- can be set to a number or -1 so go.nvim will pickup a random port
dap_timeout = 15, -- see dap option initialize_timeout_sec = 15,
dap_retries = 20, -- see dap option max_retries
build_tags = "", --- you can provide extra build tags for tests or debugger
textobjects = true, -- treesitter binding for text objects
test_runner = "go", -- one of {`go`, `richgo`, `dlv`, `ginkgo`, `gotestsum`}

@ -353,11 +353,16 @@ M.run = function(...)
end
local port = _GO_NVIM_CFG.dap_port
if _GO_NVIM_CFG.dap_port == nil or _GO_NVIM_CFG.dap_port == -1 then
if _GO_NVIM_CFG.dap_port == -1 then
math.randomseed(os.time())
port = 38000 + math.random(1, 1000)
end
local dap = require('dap')
local con_options = {
max_retries = _GO_NVIM_CFG.dap_retries,
initialize_timeout_sec = _GO_NVIM_CFG.dap_timeout,
}
dap.adapters.go = function(callback, config)
stdout = vim.loop.new_pipe(false)
stderr = vim.loop.new_pipe(false)
@ -390,15 +395,14 @@ M.run = function(...)
handle, pid_or_err = vim.loop.spawn('dlv', {
stdio = { nil, stdout, stderr },
args = { 'dap', '-l', addr },
initialize_timeout_sec = con_options.initialize_timeout_sec,
detached = true,
}, function(code)
if code ~= 0 then
vim.schedule(function()
log('Dlv exited', code)
vim.notify(string.format('Delve exited with exit code: %d', code), vim.lsp.log_levels.WARN)
if _GO_NVIM_CFG.dap_port ~= nil then
_GO_NVIM_CFG.dap_port = _GO_NVIM_CFG.dap_port + 1
end
_GO_NVIM_CFG.dap_port = _GO_NVIM_CFG.dap_port + 1
end)
end
@ -417,7 +421,7 @@ M.run = function(...)
dap.repl.open()
end
vim.defer_fn(function()
callback({ type = 'server', host = host, port = port })
callback({ type = 'server', host = host, port = port, options = con_options })
end, 1000)
end
@ -428,6 +432,7 @@ M.run = function(...)
request = 'launch',
dlvToolPath = vim.fn.exepath('dlv'),
buildFlags = get_test_build_tags(),
options = con_options,
}
local empty = utils.empty

Loading…
Cancel
Save