diff --git a/lua/plugins/mason-nvim-dap.lua b/lua/plugins/mason-nvim-dap.lua new file mode 100644 index 0000000..beddd3c --- /dev/null +++ b/lua/plugins/mason-nvim-dap.lua @@ -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 diff --git a/lua/plugins/nvim-dap.lua b/lua/plugins/nvim-dap.lua new file mode 100644 index 0000000..89610ba --- /dev/null +++ b/lua/plugins/nvim-dap.lua @@ -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', '' }, + }, + }, + windows = { indent = 1 }, + render = { + max_type_length = nil, -- Can be integer or nil. + }, + } + end, + }, + }, +} + +function M.init() + vim.keymap.set('n', 'db', function() + require('dap').toggle_breakpoint() + end, { desc = 'Toggle Breakpoint' }) + + vim.keymap.set('n', 'dc', function() + require('dap').continue() + end, { desc = 'Continue' }) + + vim.keymap.set('n', 'do', function() + require('dap').step_over() + end, { desc = 'Step Over' }) + + vim.keymap.set('n', 'di', function() + require('dap').step_into() + end, { desc = 'Step Into' }) + + vim.keymap.set('n', 'dw', function() + require('dap.ui.widgets').hover() + end, { desc = 'Widgets' }) + + vim.keymap.set('n', 'dr', function() + require('dap').repl.open() + end, { desc = 'Repl' }) + + vim.keymap.set('n', '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