nix.nvim/nvim/plugin/dap.lua
jiriks74 e256516fe7
feat(plugins): Add nvim-dap and overseer
Added:
  - [nvim-dap](https://github.com/mfussenegger/nvim-dap)
  - [nvim-dap-ui](https://github.com/rcarriga/nvim-dap-ui)
  - [overseer.nvim](https://github.com/stevearc/overseer.nvim)
Removed:
  - NeoTree `<leader>o` keymap (it's now used for overseer)
2024-09-24 21:41:05 +02:00

80 lines
3.8 KiB
Lua

if vim.g.did_load_dap_plugin then
return
end
vim.g.did_load_dap_plugin = true
local dap, dapui = require("dap"), require("dapui")
-- UI hooks
dap.listeners.before.attach.dapui_config = function()
dapui.open()
end
dap.listeners.before.launch.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
require('which-key').add({
{ "<F5>", function() require("dap").continue() end, desc = "debugger: Start" },
{ "<F6>", function() require("dap").pause() end, desc = "debugger: pause" },
{ "<F9>", function() require("dap").toggle_breakpoint() end, desc = "debugger: toggle breakpoint" },
{ "<F10>", function() require("dap").step_over() end, desc = "debugger: step over" },
{ "<F11>", function() require("dap").step_into() end, desc = "debugger: step into" },
{ "<F17>", function() require("dap").terminate() end, desc = "debugger: Stop" }, -- Shift+F
{ "<F23>", function() require("dap").step_out() end, desc = "debugger: step out" }, -- Shift+F11
{ "<F21>", -- Shift+F9
function()
vim.ui.input({ prompt = "Condition: " }, function(condition)
if condition then require("dap").set_breakpoint(condition) end
end)
end,
desc = "debugger: Conditional Breakpoint" },
{ "<F29>", function() require("dap").restart_frame() end, desc = "debugger: restart" }, -- Control+F5
{ "<leader>d", group = "[d]ebug", icon="" },
{ "<leader>db", function() require("dap").toggle_breakpoint() end, desc = "[d]ebugger: toggle [b]reakpoint (F9)" },
{ "<leader>dB", function() require("dap").clear_breakpoints() end, desc = "[d]ebugger: clear [B]reakpoints" },
{ "<leader>dc", function() require("dap").continue() end, desc = "[d]ebugger: start/[c]ontinue (F5)" },
{ "<leader>dC",
function()
vim.ui.input({ prompt = "Condition: " }, function(condition)
if condition then require("dap").set_breakpoint(condition) end
end)
end,
desc = "[d]ebugger: [C]onditional breakpoint (S-F9)" },
{ "<leader>di", function() require("dap").step_into() end, desc = "[d]ebugger: step [i]nto (F11)" },
{ "<leader>do", function() require("dap").step_over() end, desc = "[d]ebugger: step [o]ver (F10)" },
{ "<leader>dO", function() require("dap").step_out() end, desc = "[d]ebugger: step [O]ut (S-F11)" },
{ "<leader>dq", function() require("dap").close() end, desc = "[d]ebugger: [q]uit" },
{ "<leader>dQ", function() require("dap").terminate() end, desc = "[d]ebugger: force [Q]uit(S-F5)" },
{ "<leader>dp", function() require("dap").pause() end, desc = "[d]ebugger: [p]ause (F6)" },
{ "<leader>dr", function() require("dap").restart_frame() end, desc = "[d]ebugger: [r]estart (C-F5)" },
{ "<leader>dR", function() require("dap").repl.toggle() end, desc = "[d]ebugger: toggle [R]EPL" },
{ "<leader>ds", function() require("dap").run_to_cursor() end, desc = "[d]ebugger: run to cur[s]or" },
{ "<leader>dE",
function()
vim.ui.input({ prompt = "Expression: " }, function(expr)
if expr then require("dapui").eval(expr, { enter = true }) end
end)
end,
desc = "[d]ebugger: [E]valuate input",
},
-- DapUI
{ "<leader>du", function() require("dapui").toggle() end, desc = "[d]ebugger: toggle [u]i" },
{ "<leader>dh", function() require("dap.ui.widgets").hover() end, desc = "[d]ebugger: [h]over" },
{ mode = "v", "<leader>dE", function() require("dapui").eval() end, desc = "[d]ebugger: [E]valuate input" },
})
vim.fn.sign_define('DapBreakpoint', { text="", texthl="white" })
vim.fn.sign_define('DapBreakpointCondition', { text='', texthl="white" })
vim.fn.sign_define('DapBreakpointRejected', { text='', texthl="bright_red" })
vim.fn.sign_define('DapLogPoint', { text='󰛿', texthl="white" })
vim.fn.sign_define('DapStopped', { text='󰁕', texthl="orange" })