feat(nvim): improved dap integration

This commit is contained in:
Price Hiller 2022-09-18 16:50:32 -05:00
parent 2e7cc78aa0
commit 8fa347dcf9
2 changed files with 48 additions and 5 deletions

View File

@ -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

View File

@ -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"