kickstart.nvim/lua/custom/plugins/dap.lua

68 lines
2 KiB
Lua
Raw Normal View History

2024-09-17 14:23:30 +01:00
return {
{
'mfussenegger/nvim-dap',
dependencies = {
'rcarriga/nvim-dap-ui',
'theHamsta/nvim-dap-virtual-text',
2024-10-28 22:16:06 +00:00
'williamboman/mason.nvim', -- for installing netcoredbg
2024-09-17 14:23:30 +01:00
},
config = function()
local dap = require 'dap'
2024-10-28 22:16:06 +00:00
local dapui = require 'dapui'
2024-09-17 14:23:30 +01:00
2024-10-28 22:16:06 +00:00
-- Setup DAP UI
dapui.setup()
require('nvim-dap-virtual-text').setup()
2024-09-17 14:23:30 +01:00
2024-10-28 22:16:06 +00:00
-- CoreCLR Adapter Configuration for .NET
2024-09-17 14:23:30 +01:00
dap.adapters.coreclr = {
type = 'executable',
2024-10-28 22:16:06 +00:00
command = '/usr/local/bin/netcoredbg/netcoredbg',
2024-09-17 14:23:30 +01:00
args = { '--interpreter=vscode' },
}
2024-10-28 22:16:06 +00:00
-- DAP Configuration for .NET Core
2024-09-17 14:23:30 +01:00
dap.configurations.cs = {
{
type = 'coreclr',
2024-10-28 22:16:06 +00:00
name = 'Launch .NET Core Web API',
2024-09-17 14:23:30 +01:00
request = 'launch',
program = function()
2024-10-28 22:16:06 +00:00
return vim.fn.input('Path to dll: ', vim.fn.getcwd() .. '/bin/Debug/net8.0/linux-x64/MelodyFitnessApi.dll', 'file')
2024-09-17 14:23:30 +01:00
end,
cwd = '${workspaceFolder}',
stopAtEntry = false,
},
{
type = 'coreclr',
2024-10-28 22:16:06 +00:00
name = 'Attach to .NET Core',
2024-09-17 14:23:30 +01:00
request = 'attach',
processId = require('dap.utils').pick_process,
cwd = '${workspaceFolder}',
},
}
2024-10-28 22:16:06 +00:00
-- Key mappings for debugging
vim.keymap.set('n', '<F5>', dap.continue)
vim.keymap.set('n', '<F10>', dap.step_over)
vim.keymap.set('n', '<F11>', dap.step_into)
vim.keymap.set('n', '<F12>', dap.step_out)
vim.keymap.set('n', '<Leader>b', dap.toggle_breakpoint)
vim.keymap.set('n', '<Leader>B', function()
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
2024-09-17 14:23:30 +01:00
end)
2024-10-28 22:16:06 +00:00
-- Automatically open/close DAP UI on start/end
dap.listeners.after.event_initialized['dapui_config'] = function()
dapui.open()
2024-09-17 14:23:30 +01:00
end
2024-10-28 22:16:06 +00:00
dap.listeners.before.event_terminated['dapui_config'] = function()
dapui.close()
2024-09-17 14:23:30 +01:00
end
2024-10-28 22:16:06 +00:00
dap.listeners.before.event_exited['dapui_config'] = function()
dapui.close()
2024-09-17 14:23:30 +01:00
end
end,
},
}