Confusion around cwd #1200
-
Hi @mfussenegger 👋 and thanks for this amazing project! I'm somewhat confused over this line of code: Line 373 in 6ae8a14 The What is the problem?Technically, no problem that I am hitting, but I found this discrepancy while investigating the possibility to implement When I pass in This is poor man's debug prints of the arguments given to -- print(vim.inspect(adapter))
-- This comes from leoluz/nvim-dap-go.
{
executable = {
args = { "dap", "-l", "127.0.0.1:${port}" },
command = "dlv",
cwd = "/Users/fredrik/code/[REDACTED]/projectx", -- NOTE: I'm looking to implement this, it does not exist on nvim-dap-go yet
detached = true
},
options = {
initialize_timeout_sec = 20
},
port = "${port}",
type = "server"
}
-- print(vim.inspect(configuration))
{
args = { "-test.run", "^TestSomething$" },
cwd = "/Users/fredrik/code/[REDACTED]/projectx",
mode = "test",
name = "Neotest-golang Debugger",
program = "/Users/fredrik/code/[REDACTED]/projectx/internal/core",
request = "launch",
type = "go"
}
-- print(vim.inspect(opts))
{
after = <function 1>,
before = <function 2>,
filetype = "go"
} So, it's quite unclear to me if nvim-dap maybe expects the local function run_adapter(adapter, configuration, opts)
local name = configuration.name or '[no name]'
local options = adapter.options or {}
opts = vim.tbl_extend('keep', opts, {
- cwd = options.cwd,
+ cwd = adapter.cwd,
env = options.env
}) To top it all off, all of this was invoked by Anyway, I'm not facing a problem here. I just figured I'd raise a concern around this being a bit confusing. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think you might be mixing up adapters of type For The code to look at is here: Line 1179 in 6ae8a14 |
Beta Was this translation helpful? Give feedback.
I think you might be mixing up adapters of type
executable
with adapters of typeserver
.See
:help dap-adapter
.For
executable
, there is aoptions
table withcwd
.For
server
, there is a optionalexecutable
table withcwd
. Theoptions
refer to the connect option. Strictly speaking for symmetry there would need to beserver.executable.options.cwd
, but I ommitted that extra level.The code to look at is here:
nvim-dap/lua/dap/session.lua
Line 1179 in 6ae8a14