Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set cwd for dlv based on program #99

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lua/dap-go.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ local function setup_delve_adapter(dap, config)
}

dap.adapters.go = function(callback, client_config)
if client_config.program ~= nil then
local program = client_config.program
local path = require("plenary.path")
leoluz marked this conversation as resolved.
Show resolved Hide resolved
local program_path = path:new(program)
local program_absolute = program_path:absolute()

client_config.program = program_absolute

if program_path:is_dir() then
delve_config.executable.cwd = program_absolute
elseif program:match("^.+(%..+)$") == ".go" then -- file extension is '.go'
delve_config.executable.cwd = tostring(program_path:parent())
end
end

if client_config.port == nil then
callback(delve_config)
return
Expand Down
Loading