From 569e384a34e287a021fe7ab5b52c3415e51ec8a1 Mon Sep 17 00:00:00 2001 From: "Alexandre Cavalheiro S. Tiago da Silva" Date: Wed, 23 Apr 2025 23:10:02 -0300 Subject: [PATCH] fix(neovim): adjust csharp ftplugin to correctly debug projects --- modules/neovim/ftplugin/cs.lua | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/neovim/ftplugin/cs.lua b/modules/neovim/ftplugin/cs.lua index d42cbef..f7b5880 100644 --- a/modules/neovim/ftplugin/cs.lua +++ b/modules/neovim/ftplugin/cs.lua @@ -5,7 +5,7 @@ ---@field target_framework string ---@class CSFTPlugin.LaunchOptions: dap.Configuration ----@field cwd string +---@field cwd string? ---@field program (fun(): thread)? ---@class CSFTPlugin @@ -14,7 +14,6 @@ local M = { dotnet_cmd = vim.fn.exepath "dotnet", launch_options = { - cwd = "${env:CSPROJ_LOCATION}", name = "Launch project DLL", request = "launch", type = "netcoredbg", @@ -60,14 +59,14 @@ function M.find_projects() local sub_start, sub_end = string.find(file_path, "%w+%" .. csproj_extension) local project_name = string.sub(file_path, sub_start or 1, sub_end - #csproj_extension) - local project_location = string.sub(file_path, 1, sub_start - 1) + local project_path = vim.fn.simplify(vim.fn.getcwd() .. "/" .. string.sub(file_path, 1, sub_start - 1)) local target_framework = M.cmd("rg -e 'TargetFramework>(.*)<' -r '$1' -o " .. file_path)[1] projects[#projects + 1] = { - dll_path = "bin/Debug/" .. target_framework .. "/" .. project_name .. ".dll", + dll_path = project_path .. "bin/Debug/" .. target_framework .. "/" .. project_name .. ".dll", name = project_name, - project_path = vim.fn.simplify(vim.fn.getcwd() .. "/" .. project_location), + project_path = project_path, target_framework = target_framework, } end @@ -116,10 +115,9 @@ function M:choose_dll() if path ~= dap.ABORT then self:run "build" + self.launch_options.cwd = item.project_path end - vim.fn.setenv("CSPROJ_LOCATION", item.project_path) - coroutine.resume(search_coroutine, path) end )