231 lines
8.2 KiB
Lua
231 lines
8.2 KiB
Lua
return {
|
|
{
|
|
"mfussenegger/nvim-dap",
|
|
dependencies = {
|
|
"leoluz/nvim-dap-go",
|
|
"mfussenegger/nvim-dap-python",
|
|
"rcarriga/nvim-dap-ui",
|
|
"theHamsta/nvim-dap-virtual-text",
|
|
"nvim-neotest/nvim-nio",
|
|
"williamboman/mason.nvim",
|
|
},
|
|
config = function()
|
|
local dap = require "dap"
|
|
local ui = require "dapui"
|
|
|
|
require("dapui").setup()
|
|
require("dap-go").setup()
|
|
require("dap-python").setup()
|
|
|
|
vim.fn.sign_define('DapBreakpoint', { text='', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl='DapBreakpoint' })
|
|
vim.fn.sign_define('DapBreakpointCondition', { text='ﳁ', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl='DapBreakpoint' })
|
|
vim.fn.sign_define('DapBreakpointRejected', { text='', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl= 'DapBreakpoint' })
|
|
vim.fn.sign_define('DapLogPoint', { text='', texthl='DapLogPoint', linehl='DapLogPoint', numhl= 'DapLogPoint' })
|
|
vim.fn.sign_define('DapStopped', { text='', texthl='DapStopped', linehl='DapStopped', numhl= 'DapStopped' })
|
|
|
|
require('dap-go').setup {
|
|
-- Additional dap configurations can be added.
|
|
-- dap_configurations accepts a list of tables where each entry
|
|
-- represents a dap configuration. For more details do:
|
|
-- :help dap-configuration
|
|
dap_configurations = {
|
|
{
|
|
-- Must be "go" or it will be ignored by the plugin
|
|
type = "go",
|
|
name = "Attach remote",
|
|
mode = "remote",
|
|
request = "attach",
|
|
},
|
|
{
|
|
type = "go",
|
|
name = "Debug (Backend)",
|
|
request = "launch",
|
|
program = "./cmd", -- "${file}",
|
|
buildFlags = require("dap-go").get_build_flags,
|
|
},
|
|
|
|
},
|
|
|
|
-- delve configurations
|
|
delve = {
|
|
-- the path to the executable dlv which will be used for debugging.
|
|
-- by default, this is the "dlv" executable on your PATH.
|
|
path = "dlv",
|
|
-- time to wait for delve to initialize the debug session.
|
|
-- default to 20 seconds
|
|
initialize_timeout_sec = 20,
|
|
-- a string that defines the port to start delve debugger.
|
|
-- default to string "${port}" which instructs nvim-dap
|
|
-- to start the process in a random available port.
|
|
-- if you set a port in your debug configuration, its value will be
|
|
-- assigned dynamically.
|
|
port = "${port}",
|
|
-- additional args to pass to dlv
|
|
args = {},
|
|
-- the build flags that are passed to delve.
|
|
-- defaults to empty string, but can be used to provide flags
|
|
-- such as "-tags=unit" to make sure the test suite is
|
|
-- compiled during debugging, for example.
|
|
-- passing build flags using args is ineffective, as those are
|
|
-- ignored by delve in dap mode.
|
|
-- avaliable ui interactive function to prompt for arguments get_arguments
|
|
build_flags = {},
|
|
-- whether the dlv process to be created detached or not. there is
|
|
-- an issue on delve versions < 1.24.0 for Windows where this needs to be
|
|
-- set to false, otherwise the dlv server creation will fail.
|
|
-- avaliable ui interactive function to prompt for build flags: get_build_flags
|
|
detached = vim.fn.has("win32") == 0,
|
|
-- the current working directory to run dlv from, if other than
|
|
-- the current working directory.
|
|
cwd = nil,
|
|
},
|
|
-- options related to running closest test
|
|
tests = {
|
|
-- enables verbosity when running the test.
|
|
verbose = false,
|
|
},
|
|
}
|
|
|
|
require("nvim-dap-virtual-text").setup {
|
|
-- This just tries to mitigate the chance that I leak tokens here. Probably won't stop it from happening...
|
|
display_callback = function(variable)
|
|
local name = string.lower(variable.name)
|
|
local value = string.lower(variable.value)
|
|
if name:match "secret" or name:match "api" or value:match "secret" or value:match "api" then
|
|
return "*****"
|
|
end
|
|
|
|
if #variable.value > 15 then
|
|
return " " .. string.sub(variable.value, 1, 15) .. "... "
|
|
end
|
|
|
|
return " " .. variable.value
|
|
end,
|
|
}
|
|
|
|
dap.configurations.python = {
|
|
{
|
|
type = 'python';
|
|
request = 'launch';
|
|
name = "Launch file";
|
|
console = "integratedTerminal",
|
|
program = "${file}";
|
|
pythonPath = function()
|
|
return 'python'
|
|
end;
|
|
},
|
|
}
|
|
|
|
dap.adapters.coreclr = {
|
|
type = 'executable',
|
|
command = '/home/greg/.netcoredbg/netcoredbg',
|
|
args = {'--interpreter=vscode'}
|
|
}
|
|
|
|
dap.configurations.cs = {
|
|
{
|
|
type = "coreclr",
|
|
name = "launch - netcoredbg",
|
|
request = "launch",
|
|
program = function()
|
|
local path = vim.fn.getcwd() .. '/bin/Debug/net9.0/'
|
|
local dllFiles = vim.fn.glob(path .. '*.dll', false, true)
|
|
if #dllFiles == 0 then
|
|
return vim.fn.input('Path to dll', vim.fn.getcwd() .. '/bin/Debug/', 'file')
|
|
end
|
|
-- Sort files by modification time (newest first)
|
|
table.sort(dllFiles, function(a, b)
|
|
return vim.fn.getftime(b) < vim.fn.getftime(a)
|
|
end)
|
|
return dllFiles[1] -- Return the most recent DLL file
|
|
end,
|
|
},
|
|
}
|
|
|
|
dap.adapters.lldb = {
|
|
type = "executable",
|
|
command = "/usr/bin/lldb", -- adjust as needed
|
|
name = "lldb",
|
|
}
|
|
|
|
dap.configurations.rust = {
|
|
{
|
|
name = "hello-world",
|
|
type = "lldb",
|
|
request = "launch",
|
|
program = function()
|
|
return vim.fn.getcwd() .. "/target/debug/hello-world"
|
|
end,
|
|
cwd = "${workspaceFolder}",
|
|
stopOnEntry = false,
|
|
},
|
|
{
|
|
name = "hello-dap",
|
|
type = "lldb",
|
|
request = "launch",
|
|
program = function()
|
|
return vim.fn.getcwd() .. "/target/debug/hello-dap"
|
|
end,
|
|
cwd = "${workspaceFolder}",
|
|
stopOnEntry = false,
|
|
},
|
|
}
|
|
|
|
local elixir_ls_debugger = vim.fn.exepath "elixir-ls-debugger"
|
|
if elixir_ls_debugger ~= "" then
|
|
dap.adapters.mix_task = {
|
|
type = "executable",
|
|
command = elixir_ls_debugger,
|
|
}
|
|
|
|
dap.configurations.elixir = {
|
|
{
|
|
type = "mix_task",
|
|
name = "phoenix server",
|
|
task = "phx.server",
|
|
request = "launch",
|
|
projectDir = "${workspaceFolder}",
|
|
exitAfterTaskReturns = false,
|
|
debugAutoInterpretAllModules = false,
|
|
},
|
|
}
|
|
end
|
|
|
|
vim.keymap.set("n", "<space>pb", dap.toggle_breakpoint)
|
|
vim.keymap.set("n", "<space>gb", dap.run_to_cursor)
|
|
|
|
-- Eval var under cursor
|
|
vim.keymap.set("n", "<space>?", function()
|
|
require("dapui").eval(nil, { enter = true })
|
|
end)
|
|
|
|
-- Close nvimtree if it's open and start debugging
|
|
vim.keymap.set("n", "<F1>", function()
|
|
vim.cmd('NvimTreeClose')
|
|
dap.continue()
|
|
end)
|
|
vim.keymap.set("n", "<F2>", dap.step_into, { desc = "Dap Step into" })
|
|
vim.keymap.set("n", "<F3>", dap.step_over, { desc = "Dap Step over" })
|
|
vim.keymap.set("n", "<F4>", dap.step_out, { desc = "Dap Step out" })
|
|
vim.keymap.set("n", "<F5>", dap.step_back, { desc = "Dap Step back" })
|
|
vim.keymap.set("n", "<F6>", dap.restart, { desc = "Dap Restart" })
|
|
vim.keymap.set("n", "<space>pb", dap.toggle_breakpoint, { desc = "Dap Toggle breakpoint" })
|
|
vim.keymap.set("n", "<space>gb", dap.run_to_cursor, { desc = "Dap Run to cursor" })
|
|
|
|
|
|
dap.listeners.before.attach.dapui_config = function()
|
|
ui.open()
|
|
end
|
|
dap.listeners.before.launch.dapui_config = function()
|
|
ui.open()
|
|
end
|
|
dap.listeners.before.event_terminated.dapui_config = function()
|
|
ui.close()
|
|
end
|
|
dap.listeners.before.event_exited.dapui_config = function()
|
|
ui.close()
|
|
end
|
|
end,
|
|
},
|
|
}
|