This repository has been archived on 2024-05-02. You can view files and clone it, but cannot push or open issues or pull requests.
neovim-flake/neovim-ide/plugin/dap.lua

99 lines
3.1 KiB
Lua

local dapui = require("dapui")
local dap = require("dap")
require("nvim-dap-virtual-text").setup {}
dapui.setup()
require("dap.ext.vscode").load_launchjs(nil, { rt_lldb = { "rust" } })
dap.listeners.before.attach.dapui_config = function()
dapui.open()
end
dap.listeners.before.launch.dapui_config = function()
dapui.open()
end
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
vim.keymap.set("n", "<leader>db", vim.cmd.DapToggleBreakpoint, { desc = "Toggle Debug Breakpoint" })
vim.keymap.set("n", "<leader>dc", vim.cmd.DapContinue, { desc = "Debug Continue" })
vim.keymap.set("n", "<leader>dC", function() dap.run_last() end, { desc = "Debug Continue" })
vim.keymap.set("n", "<leader>dn", vim.cmd.DapStepOver, { desc = "Debug Step Over" })
vim.keymap.set("n", "<leader>di", vim.cmd.DapStepIn, { desc = "Debug Step In" })
vim.keymap.set("n", "<leader>do", vim.cmd.DapStepOut, { desc = "Debug Step Out" })
vim.keymap.set("n", "<leader>dt", vim.cmd.DapTerminate, { desc = "Debug Terminate" })
vim.keymap.set("n", "<leader>dr", vim.cmd.DapToggleRepl, { desc = "Debug Toggle REPL" })
vim.keymap.set("n", "<leader>du", function()
require("dapui").toggle {}
end, { desc = "Toggle Debug UI" })
vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DapBreakpoint", linehl = "", numhl = "DapBreakpoint" })
vim.fn.sign_define(
"DapBreakpointCondition",
{ text = "", texthl = "DapBreakpoint", linehl = "", numhl = "DapBreakpoint" }
)
vim.fn.sign_define(
"DapBreakpointRejected",
{ text = "", texthl = "DapBreakpoint", linehl = "", numhl = "DapBreakpoint" }
)
vim.fn.sign_define("DapLogPoint", { text = "", texthl = "DapLogPoint", linehl = "", numhl = "DapLogPoint" })
vim.fn.sign_define("DapStopped", { text = "", texthl = "DapStopped", linehl = "", numhl = "DapStopped" })
dap.adapters.gdb = {
type = "executable",
command = "gdb",
args = { "-i", "dap" },
}
dap.adapters.lldb = {
type = "executable",
command = "lldb-vscode", -- adjust as needed, must be absolute path
name = "lldb",
}
local lldb_config = {
name = "Launch",
type = "lldb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
}
local lldb_attach_config = {
name = "Attach to process",
type = "lldb", -- Adjust this to match your adapter name (`dap.adapters.<name>`)
request = "attach",
pid = require("dap.utils").pick_process,
args = {},
}
local rust_config = vim.tbl_deep_extend("force", lldb_config, {
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file")
end,
})
dap.configurations.c = {
lldb_config,
lldb_attach_config
}
dap.configurations.rust = { rust_config, lldb_attach_config }
dap.adapters.delve = {
type = 'server',
port = '${port}',
executable = {
command = 'dlv',
args = {'dap', '-l', '127.0.0.1:${port}'},
}
}