From 52eec6900698ec49d54c3d66110e183ac1352313 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Thu, 22 Aug 2024 16:12:57 -0600 Subject: [PATCH] fix: do not add executable to adapter when remote mode is used This prevents the executable from being added to the adapter when remote mode is used. This allows the plugin to attach to already running instances that are run through `dlv exec` to perform remote debugging. --- lua/dap-go.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lua/dap-go.lua b/lua/dap-go.lua index 6e125a9..ce39843 100644 --- a/lua/dap-go.lua +++ b/lua/dap-go.lua @@ -14,8 +14,8 @@ local default_config = { port = "${port}", args = {}, build_flags = "", - -- Automativally handle the issue on Windows where delve needs - -- to be run in attched mode or it will fail (actually crashes). + -- Automatically handle the issue on Windows where delve needs + -- to be run in attached mode or it will fail (actually crashes). detached = vim.fn.has("win32") == 0, }, tests = { @@ -91,6 +91,12 @@ local function setup_delve_adapter(dap, config) host = "127.0.0.1" end + -- Remove the executable if used in remote mode. + -- This will prevent the executable from being launched. + if client_config.mode == "remote" then + delve_config.executable = nil + end + local listener_addr = host .. ":" .. client_config.port delve_config.port = client_config.port delve_config.executable.args = { "dap", "-l", listener_addr }