Closed Amleto closed 9 months ago
You could set both program
and cwd
in the __call
as it allows you to return a new configuration table.
I tried doing that, in conjunction with async calls with a telescope picker - described at the end of of the report. The value that is set is lost
I've been looking for the same. Although not 100% what you want, I came up with this solution. It still need some tweaking but it at least allows you to pick a dll from your obj/Debug
folders. Note: I haven't gotten it to work, due to an unrelated problem with netcoredbg (DAP Failed command 'configurationDone' : 0x80070005).
program = function()
local function get_recursive_dll_files(skip_count)
local target_folder = "obj/Debug"
local find_command = 'find . -path "*/' .. target_folder .. '/*.dll" -not -regex ".*\\/(ref|refint)/.*"'
local files = {}
local file_map = {}
for line in io.popen(find_command):lines() do
local clean_line = string.gsub(line, target_folder .. "/", "")
local parts = {}
local count = 0
local filename = string.match(clean_line, "([^/]+)$")
for part in string.gmatch(clean_line, "([^/]+)") do
if not string.find(part, "^net[0-9\\.]+$") then
count = count + 1
if count <= skip_count or part == filename then
table.insert(parts, part)
else
table.insert(parts, string.sub(part, 1, 1))
end
end
end
local display_name = table.concat(parts, "/")
file_map[display_name] = line
table.insert(files, display_name)
end
return files, file_map
end
local function get_file_sync()
local co = coroutine.running()
local selected_file = nil
local files, file_map = get_recursive_dll_files(3)
vim.ui.select(files, {}, function(short_filename)
selected_file = file_map[short_filename]
coroutine.resume(co)
end)
coroutine.yield()
return selected_file
end
local file = get_file_sync()
print(file)
return file
end
I tried doing that, in conjunction with async calls with a telescope picker - described at the end of of the report. The value that is set is lost
Then there's probably something wrong with how you use it.
See also https://github.com/mfussenegger/nvim-dap/discussions/597#discussioncomment-3098086 for another alternative
Problem Statement
dotnet debugging should have the cwd of the debug target set to be the same directory that contains the dotnet dll. This is especially important for asp.net core where an appsettings.json file is expected to be located in the cwd when the server is launched.
This is difficult to configure 'automatically' since the
config.program
needs to be set dynamically and, as far as I understand, the order of evaluation of cwd.program() and config.cwd() is unspecified. Using the metatable + __call also doesn't help for the same reason.Possible Solutions
Considered Alternatives
I tried using metatable and __call in the config that would inject the config instance into a function for
program
, and once the value forprogram
was determined it would assign the parent dir toconfig.cwd
, but that config instance is lost somewhere around lineconfig = vim.tbl_map(expand_config_variables, config)
in dap.lua.