Skip to content

Commit

Permalink
Add Attach remote option
Browse files Browse the repository at this point in the history
  • Loading branch information
cousine committed Jan 15, 2024
1 parent a5cc8dc commit 965886e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions lua/dap-go.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ local M = {
last_testname = "",
last_testpath = "",
test_buildflags = "",

hostname = "localhost",
port = "40000",
}

local default_config = {
Expand Down Expand Up @@ -32,6 +35,31 @@ local function get_arguments()
end)
end

local function get_dlv_uri()
return coroutine.create(function(dap_run_co)
local args = {}
local connect = {
hostname = M.hostname,
port = M.port,
}

vim.ui.input({ prompt = "Delve Uri: ", default = M.hostname .. ":" .. M.port }, function(input)
args = vim.split(input or "", ":")

if args[1] ~= nil and args[2] ~= nil then
M.hostname = args[1]
connect["hostname"] = args[1]
connect["port"] = args[2]

local dap = load_module("dap")
dap.adapters.go["port"] = args[2] or dap.adapters.go["port"]
M.port = args[2]
coroutine.resume(dap_run_co, connect)
end
end)
end)
end

local function filtered_pick_process()
local opts = {}
vim.ui.input(
Expand Down Expand Up @@ -92,6 +120,14 @@ local function setup_go_configuration(dap, configs)
processId = filtered_pick_process,
buildFlags = configs.delve.build_flags,
},
{
type = "go",
name = "Attach remote",
mode = "remote",
request = "attach",
connect = get_dlv_uri,
buildFlags = configs.delve.build_flags,
},
{
type = "go",
name = "Debug test",
Expand Down

0 comments on commit 965886e

Please sign in to comment.