local ok_dap, dap = pcall(require, "dap") if not ok_dap then return end -- netcoredbg adapter (installed via Mason) local mason_path = vim.fn.stdpath("data") .. "/mason" local netcoredbg_path = mason_path .. "/packages/netcoredbg/netcoredbg" dap.adapters.coreclr = { type = "executable", command = netcoredbg_path, args = { "--interpreter=vscode" }, } local function dotnet_build_and_get_dll() local cwd = vim.fn.getcwd() vim.fn.system("dotnet build " .. cwd) -- Heuristic: pick first dll in bin/Debug local dll = vim.fn.glob(cwd .. "/**/bin/Debug/**/**.dll", 1, 1)[1] return dll end dap.configurations.cs = { { type = "coreclr", name = "Debug (netcoredbg)", request = "launch", program = function() local dll = dotnet_build_and_get_dll() return vim.fn.input("Path to dll: ", dll or (vim.fn.getcwd() .. "/bin/Debug/"), "file") end, }, } local function dotnet_to_quickfix(cmd) local output = vim.fn.systemlist(cmd) vim.fn.setqflist({}, " ", { title = cmd, lines = output }) vim.cmd("copen") end vim.keymap.set("n", "nr", function() dotnet_to_quickfix("dotnet run") end, { desc = "dotnet run" }) vim.keymap.set("n", "nb", function() dotnet_to_quickfix("dotnet build") end, { desc = "dotnet build" }) vim.keymap.set("n", "nt", function() dotnet_to_quickfix("dotnet test") end, { desc = "dotnet test" })