63 lines
2.0 KiB
Lua
63 lines
2.0 KiB
Lua
return {
|
|
"mfussenegger/nvim-dap",
|
|
dependencies = {
|
|
"rcarriga/nvim-dap-ui",
|
|
"theHamsta/nvim-dap-virtual-text",
|
|
"nvim-neotest/nvim-nio",
|
|
"williamboman/mason.nvim",
|
|
"jay-babu/mason-nvim-dap.nvim",
|
|
},
|
|
config = function()
|
|
local dap = require("dap")
|
|
local dapui = require("dapui")
|
|
|
|
-- Initialize UI and virtual text components
|
|
dapui.setup()
|
|
require("nvim-dap-virtual-text").setup()
|
|
|
|
-- Automatically manage debugger installations via Mason
|
|
require("mason-nvim-dap").setup({
|
|
ensure_installed = { "codelldb" }, -- Auto-installs CodeLLDB
|
|
automatic_installation = true,
|
|
})
|
|
|
|
-- Automatically open/close DAP UI panels
|
|
dap.listeners.after.event_initialized["dapui_config"] = function() dapui.open() end
|
|
dap.listeners.before.event_terminated["dapui_config"] = function() dapui.close() end
|
|
dap.listeners.before.event_exited["dapui_config"] = function() dapui.close() end
|
|
|
|
-- Step 2 & 3 configurations will go here...
|
|
-- Define the adapter connection
|
|
dap.adapters.codelldb = {
|
|
type = 'server',
|
|
port = "${port}",
|
|
executable = {
|
|
-- Adjust this path if Mason uses a different default location on your OS
|
|
command = vim.fn.stdpath("data") .. "/mason/bin/codelldb",
|
|
args = {"--port", "${port}"},
|
|
}
|
|
}
|
|
|
|
-- Configure C++ configurations
|
|
dap.configurations.cpp = {
|
|
{
|
|
name = "Launch file",
|
|
type = "codelldb",
|
|
request = "launch",
|
|
program = function()
|
|
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
|
end,
|
|
cwd = '${workspaceFolder}',
|
|
stopOnEntry = false,
|
|
args = {},
|
|
},
|
|
}
|
|
|
|
-- Re-use C++ configuration for C language
|
|
dap.configurations.c = dap.configurations.cpp
|
|
|
|
|
|
end
|
|
}
|
|
|