183 lines
3.8 KiB
Lua
183 lines
3.8 KiB
Lua
local function get_all_daps()
|
|
local enabled_daps = {}
|
|
for _, lang in pairs(Languages) do
|
|
if not lang.dap then
|
|
goto continue
|
|
end
|
|
for _, name in pairs(lang.dap) do
|
|
table.insert(enabled_daps, name)
|
|
end
|
|
::continue::
|
|
end
|
|
return enabled_daps
|
|
end
|
|
|
|
return {
|
|
{
|
|
"mfussenegger/nvim-dap",
|
|
init = function()
|
|
if require("core.util").is_available("which-key") then
|
|
require("which-key").add({ "<localleader>d", group = "debug" })
|
|
end
|
|
end,
|
|
dependencies = {
|
|
{
|
|
"LiadOz/nvim-dap-repl-highlights",
|
|
opts = {},
|
|
build = ":TSInstall dap_repl",
|
|
dependencies = { "nvim-treesitter/nvim-treesitter" },
|
|
},
|
|
{
|
|
"igorlfs/nvim-dap-view",
|
|
opts = { winbar = { controls = { enabled = true } } },
|
|
keys = {
|
|
{
|
|
"<leader>sb",
|
|
function()
|
|
require("dap-view").toggle()
|
|
end,
|
|
desc = "Dap UI",
|
|
},
|
|
},
|
|
},
|
|
{ "jay-babu/mason-nvim-dap.nvim", opts = { ensure_installed = get_all_daps() } },
|
|
},
|
|
config = function()
|
|
local dap, dv = require("dap"), require("dap-view")
|
|
dap.listeners.before.attach["dap-view-config"] = function()
|
|
dv.open()
|
|
end
|
|
dap.listeners.before.launch["dap-view-config"] = function()
|
|
dv.open()
|
|
end
|
|
dap.listeners.before.event_terminated["dap-view-config"] = function()
|
|
dv.close()
|
|
end
|
|
dap.listeners.before.event_exited["dap-view-config"] = function()
|
|
dv.close()
|
|
end
|
|
-- Signs
|
|
for _, group in pairs({
|
|
"DapBreakpoint",
|
|
"DapBreakpointCondition",
|
|
"DapBreakpointRejected",
|
|
"DapLogPoint",
|
|
}) do
|
|
vim.fn.sign_define(group, { text = "●", texthl = group })
|
|
end
|
|
vim.fn.sign_define("DapStopped", { text = "", texthl = "DapStopped", numhl = "debugPC" })
|
|
-- jump to stopped-at breakpoint if it is visible in a tab or open a new tab
|
|
require("dap").defaults.fallback.switchbuf = "usevisible,usetab,newtab"
|
|
end,
|
|
keys = {
|
|
{
|
|
"<localleader>dc",
|
|
function()
|
|
require("dap").continue()
|
|
end,
|
|
desc = "continue",
|
|
},
|
|
{
|
|
"<localleader>dt",
|
|
function()
|
|
require("dap").terminate()
|
|
end,
|
|
desc = "terminate",
|
|
},
|
|
{
|
|
"<localleader>dr",
|
|
function()
|
|
require("dap").run_to_cursor()
|
|
end,
|
|
desc = "run to cursor",
|
|
},
|
|
{
|
|
"<localleader>dj",
|
|
function()
|
|
require("dap").step_over()
|
|
end,
|
|
desc = "step over",
|
|
},
|
|
{
|
|
"<localleader>dl",
|
|
function()
|
|
require("dap").step_into()
|
|
end,
|
|
desc = "step into",
|
|
},
|
|
{
|
|
"<localleader>dh",
|
|
function()
|
|
require("dap").step_out()
|
|
end,
|
|
desc = "step out",
|
|
},
|
|
{
|
|
"<localleader>[d",
|
|
function()
|
|
require("dap").up()
|
|
end,
|
|
desc = "DAP up",
|
|
},
|
|
{
|
|
"<localleader>]d",
|
|
function()
|
|
require("dap").down()
|
|
end,
|
|
desc = "DAP down",
|
|
},
|
|
|
|
{
|
|
"<localleader>db",
|
|
function()
|
|
require("dap").toggle_breakpoint()
|
|
end,
|
|
desc = "toggle breakpoint",
|
|
},
|
|
{
|
|
"<localleader>dB",
|
|
function()
|
|
vim.ui.input({ prompt = "Breakpoint condition: " }, function(input)
|
|
require("dap").set_breakpoint(input)
|
|
end)
|
|
end,
|
|
desc = "set logpoint",
|
|
},
|
|
{
|
|
"<localleader>dL",
|
|
function()
|
|
vim.ui.input({ prompt = "Log point message: " }, function(input)
|
|
require("dap").set_breakpoint(nil, nil, input)
|
|
end)
|
|
end,
|
|
desc = "set logpoint",
|
|
},
|
|
|
|
{
|
|
"<localleader>dk",
|
|
function()
|
|
require("dap.ui.widgets").hover()
|
|
end,
|
|
desc = "hover",
|
|
},
|
|
},
|
|
},
|
|
|
|
{
|
|
"mfussenegger/nvim-dap-python",
|
|
dependencies = { { "mfussenegger/nvim-dap", optional = true } },
|
|
ft = { "python" },
|
|
config = function()
|
|
require("dap-python").setup("debugpy-adapter")
|
|
end,
|
|
},
|
|
|
|
{
|
|
"leoluz/nvim-dap-go",
|
|
dependencies = { { "mfussenegger/nvim-dap", optional = true } },
|
|
ft = { "go" },
|
|
config = function()
|
|
require("dap-go").setup()
|
|
end,
|
|
},
|
|
}
|