add nvim-dap

This commit is contained in:
fiplox 2023-01-17 15:05:13 +01:00
parent 4e2fe68551
commit f0388ec5e0
2 changed files with 129 additions and 0 deletions

View File

@ -0,0 +1,17 @@
local M = {
'jay-babu/mason-nvim-dap.nvim',
dependencies = {
'williamboman/mason.nvim',
'mfussenegger/nvim-dap',
},
cmd = { 'DapInstall', 'DapUninstall' },
}
function M.config()
require('mason-nvim-dap').setup {
automatic_setup = true,
}
require('mason-nvim-dap').setup_handlers()
end
return M

112
lua/plugins/nvim-dap.lua Normal file
View File

@ -0,0 +1,112 @@
local M = {
'mfussenegger/nvim-dap',
dependencies = {
{
'rcarriga/nvim-dap-ui',
config = function()
require('dapui').setup {
mapping = {
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 = 'single', -- Border style. Can be "single", "double" or "rounded"
mappings = {
close = { 'q', '<Esc>' },
},
},
windows = { indent = 1 },
render = {
max_type_length = nil, -- Can be integer or nil.
},
}
end,
},
},
}
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' })
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' })
end
function M.config()
local dap = require 'dap'
local dapui = require 'dapui'
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
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