nvim/lua/plugins/nvim-dap.lua

146 lines
3.4 KiB
Lua
Raw Normal View History

2023-01-17 15:05:13 +01:00
local M = {
'mfussenegger/nvim-dap',
dependencies = {
{
'rcarriga/nvim-dap-ui',
},
},
}
function M.init()
vim.keymap.set('n', '<leader>db', function()
require('dap').toggle_breakpoint()
end, { desc = 'Toggle Breakpoint' })
vim.keymap.set('n', '<leader>dc', function()
require('dap').continue()
end, { desc = 'Continue' })
2023-01-17 17:49:52 +01:00
vim.keymap.set('n', '<leader>dC', function()
require('dap').close()
end, { desc = 'Close' })
2023-01-17 15:05:13 +01:00
vim.keymap.set('n', '<leader>do', function()
require('dap').step_over()
end, { desc = 'Step Over' })
vim.keymap.set('n', '<leader>di', function()
require('dap').step_into()
end, { desc = 'Step Into' })
vim.keymap.set('n', '<leader>dw', function()
require('dap.ui.widgets').hover()
end, { desc = 'Widgets' })
vim.keymap.set('n', '<leader>dr', function()
require('dap').repl.open()
end, { desc = 'Repl' })
vim.keymap.set('n', '<leader>du', function()
require('dapui').toggle {}
end, { desc = 'Dap UI' })
2023-01-17 17:49:52 +01:00
vim.keymap.set('n', '<leader>dfb', function()
require('dapui').float_element('breakpoints', { enter = true })
end, { desc = 'Dap UI' })
vim.keymap.set('n', '<leader>dfS', function()
require('dapui').float_element('stacks', { enter = true })
end, { desc = 'Dap UI' })
vim.keymap.set('n', '<leader>dfw', function()
require('dapui').float_element('watches', { enter = true })
end, { desc = 'Dap UI' })
vim.keymap.set('n', '<leader>dfs', function()
require('dapui').float_element('scopes', { enter = true })
end, { desc = 'Dap UI' })
2023-01-17 15:05:13 +01:00
end
function M.config()
local dap = require 'dap'
local dapui = require 'dapui'
2023-01-17 17:49:52 +01:00
dapui.setup {
mapping = {
edit = 'l',
},
element_mappings = {
scopes = {
edit = 'l',
},
breakpoints = {
edit = 'l',
},
stacks = {
edit = 'l',
},
watches = {
edit = 'l',
},
},
layouts = {
{
elements = {
-- Elements can be strings or table with id and size keys.
{ id = 'scopes', size = 0.25 },
'breakpoints',
'stacks',
-- "watches",
},
size = 50,
position = 'right',
},
{
elements = {
'repl',
'console',
},
size = 0.25, -- 25% of total lines
position = 'bottom',
},
},
floating = {
max_height = nil, -- These can be integers or a float between 0 and 1.
max_width = nil, -- Floats will be treated as percentage of your screen.
border = 'rounded', -- Border style. Can be "single", "double" or "rounded"
mappings = {
close = { 'q', '<Esc>' },
edit = 'l',
},
},
windows = { indent = 1 },
render = {
max_type_length = nil, -- Can be integer or nil.
},
}
-- dap.listeners.after.event_initialized['dapui_config'] = function()
-- dapui.open {}
-- end
2023-01-17 15:05:13 +01:00
dap.listeners.before.event_terminated['dapui_config'] = function()
dapui.close {}
end
dap.listeners.before.event_exited['dapui_config'] = function()
dapui.close {}
end
require 'mason-nvim-dap'
end
-- - `DapBreakpoint` for breakpoints (default: `B`)
-- - `DapBreakpointCondition` for conditional breakpoints (default: `C`)
-- - `DapLogPoint` for log points (default: `L`)
-- - `DapStopped` to indicate where the debugee is stopped (default: `→`)
-- - `DapBreakpointRejected` to indicate breakpoints rejected by the debug
-- adapter (default: `R`)
--
-- You can customize the signs by setting them with the |sign_define()| function.
-- For example:
--
-- >
-- lua << EOF
-- vim.fn.sign_define('DapBreakpoint', {text='🛑', texthl='', linehl='', numhl=''})
-- EOF
-- <
return M