diff --git a/dots/.nvim-environments/primary/config/lua/plugins/configs/_dap.lua b/dots/.nvim-environments/primary/config/lua/plugins/configs/_dap.lua index fcfaa65a..494384fa 100755 --- a/dots/.nvim-environments/primary/config/lua/plugins/configs/_dap.lua +++ b/dots/.nvim-environments/primary/config/lua/plugins/configs/_dap.lua @@ -54,13 +54,56 @@ dap.configurations.cpp = { dap.configurations.c = dap.configurations.cpp dap.configurations.rust = dap.configurations.cpp -dap.configurations.cs = { +vim.g.dotnet_build_project = function() + local default_path = vim.fn.getcwd() .. "/" + if vim.g["dotnet_last_proj_path"] ~= nil then + default_path = vim.g["dotnet_last_proj_path"] + end + local path = vim.fn.input("Path to your *proj file", default_path, "file") + vim.g["dotnet_last_proj_path"] = path + local cmd = "dotnet build -c Debug " .. path .. " > /dev/null" + print("") + print("Cmd to execute: " .. cmd) + local f = os.execute(cmd) + if f == 0 then + print("\nBuild: ✔️ ") + else + print("\nBuild: ❌ (code: " .. f .. ")") + end +end + +vim.g.dotnet_get_dll_path = function() + local request = function() + return vim.fn.input("Path to dll", vim.fn.getcwd() .. "/bin/Debug/", "file") + end + + if vim.g["dotnet_last_dll_path"] == nil then + vim.g["dotnet_last_dll_path"] = request() + else + if + vim.fn.confirm("Do you want to change the path to dll?\n" .. vim.g["dotnet_last_dll_path"], "&yes\n&no", 2) + == 1 + then + vim.g["dotnet_last_dll_path"] = request() + end + end + + return vim.g["dotnet_last_dll_path"] +end + +local config = { { type = "coreclr", name = "launch - netcoredbg", request = "launch", program = function() - return vim.fn.input("Path to dll: ", vim.fn.getcwd() .. "/bin/Debug/", "file") + if vim.fn.confirm("Should I recompile first?", "&yes\n&no", 2) == 1 then + vim.g.dotnet_build_project() + end + return vim.g.dotnet_get_dll_path() end, }, } + +dap.configurations.cs = config +dap.configurations.fsharp = config diff --git a/dots/.nvim-environments/primary/config/lua/plugins/configs/python-dap.lua b/dots/.nvim-environments/primary/config/lua/plugins/configs/python-dap.lua index 93849bfe..2b1f8404 100755 --- a/dots/.nvim-environments/primary/config/lua/plugins/configs/python-dap.lua +++ b/dots/.nvim-environments/primary/config/lua/plugins/configs/python-dap.lua @@ -1,3 +1,3 @@ -local dap_python = require('dap-python') -dap_python.setup('~/.venvs/debugpy/bin/python') -dap_python.test_runner = 'pytest' +local dap_python = require("dap-python") +dap_python.setup(vim.fn.stdpath("data") .. "/mason/packages/debugpy/venv/bin/python3") +dap_python.test_runner = "pytest"