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

67 lines
2.0 KiB
Lua
Raw Normal View History

return {
2024-01-10 13:59:59 +00:00
'mfussenegger/nvim-dap',
dependencies = {
-- Creates a beautiful debugger UI
'rcarriga/nvim-dap-ui',
2024-01-10 13:59:59 +00:00
-- Installs the debug adapters for you
'williamboman/mason.nvim',
'jay-babu/mason-nvim-dap.nvim',
2024-01-10 13:59:59 +00:00
-- Debugger dependencies
'leoluz/nvim-dap-go',
},
config = function()
local dap = require 'dap'
local dapui = require 'dapui'
2024-01-10 13:59:59 +00:00
require('mason-nvim-dap').setup {
2024-02-15 10:19:41 +00:00
automatic_setup = false,
2024-01-10 13:59:59 +00:00
handlers = {},
-- Installed language debuggers
ensure_installed = {
2024-02-15 10:19:41 +00:00
'node-debug2-adapter',
2024-01-10 13:59:59 +00:00
},
}
2024-01-10 13:59:59 +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' })
vim.keymap.set('n', '<leader>b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' })
vim.keymap.set('n', '<leader>B', function()
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
end, { desc = 'Debug: Set Breakpoint' })
2024-01-10 13:59:59 +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-01-10 13:59:59 +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-01-10 13:59:59 +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-01-10 13:59:59 +00:00
-- Install golang specific config
2024-02-15 10:19:41 +00:00
-- require('dap-go').setup()
2024-01-10 13:59:59 +00:00
end,
}