nvim-config/lua/kickstart/plugins/debug.lua

66 lines
2.1 KiB
Lua
Raw Normal View History

return {
2024-03-01 12:42:09 +00:00
'mfussenegger/nvim-dap',
dependencies = {
-- Async IO library
'nvim-neotest/nvim-nio',
2024-03-01 12:42:09 +00:00
-- Creates a beautiful debugger UI
'rcarriga/nvim-dap-ui',
2024-03-01 12:42:09 +00:00
-- Installs the debug adapters for you
'williamboman/mason.nvim',
'jay-babu/mason-nvim-dap.nvim',
2024-03-01 12:42:09 +00:00
-- Debugger dependencies
'leoluz/nvim-dap-go',
},
config = function()
local dap = require 'dap'
local dapui = require 'dapui'
2024-03-01 12:42:09 +00:00
require('mason-nvim-dap').setup {
automatic_setup = true,
2024-03-01 12:42:09 +00:00
handlers = {},
}
2024-03-01 12:42:09 +00:00
-- Basic debugging keymaps, feel free to change to your liking!
vim.keymap.set('n', '<F5>', dap.continue, { desc = 'Debug: Start/Continue' })
vim.keymap.set('n', '<F1>', dap.step_into, { desc = 'Debug: Step Into' })
vim.keymap.set('n', '<F2>', dap.step_over, { desc = 'Debug: Step Over' })
vim.keymap.set('n', '<F3>', dap.step_out, { desc = 'Debug: Step Out' })
2024-03-08 08:19:12 +00:00
vim.keymap.set('n', '<leader>B', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' })
vim.keymap.set('n', '<leader>bs', function()
2024-03-01 12:42:09 +00:00
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
2024-03-08 08:19:12 +00:00
end, { desc = 'Debug: [B]reakpoint [S]et' })
2024-03-01 12:42:09 +00:00
-- Dap UI setup
dapui.setup {
-- Set icons to characters that are more likely to work in every terminal.
icons = { expanded = '', collapsed = '', current_frame = '*' },
controls = {
icons = {
pause = '',
play = '',
step_into = '',
step_over = '',
step_out = '',
step_back = 'b',
run_last = '▶▶',
terminate = '',
disconnect = '',
},
},
}
2024-03-01 12:42:09 +00:00
-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
vim.keymap.set('n', '<F7>', dapui.toggle, { desc = 'Debug: See last session result.' })
2024-03-01 12:42:09 +00:00
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
dap.listeners.before.event_exited['dapui_config'] = dapui.close
2024-03-01 12:42:09 +00:00
-- Install golang specific config
-- require('dap-go').setup()
end,
}