diff --git a/lua/plugins/nvim-dap.lua b/lua/plugins/nvim-dap.lua index 89610ba..27269c3 100644 --- a/lua/plugins/nvim-dap.lua +++ b/lua/plugins/nvim-dap.lua @@ -3,46 +3,6 @@ local M = { 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, }, }, } @@ -56,6 +16,10 @@ function M.init() require('dap').continue() end, { desc = 'Continue' }) + vim.keymap.set('n', 'dC', function() + require('dap').close() + end, { desc = 'Close' }) + vim.keymap.set('n', 'do', function() require('dap').step_over() end, { desc = 'Step Over' }) @@ -75,15 +39,84 @@ function M.init() vim.keymap.set('n', 'du', function() require('dapui').toggle {} end, { desc = 'Dap UI' }) + + vim.keymap.set('n', 'dfb', function() + require('dapui').float_element('breakpoints', { enter = true }) + end, { desc = 'Dap UI' }) + + vim.keymap.set('n', 'dfS', function() + require('dapui').float_element('stacks', { enter = true }) + end, { desc = 'Dap UI' }) + + vim.keymap.set('n', 'dfw', function() + require('dapui').float_element('watches', { enter = true }) + end, { desc = 'Dap UI' }) + + vim.keymap.set('n', 'dfs', function() + require('dapui').float_element('scopes', { enter = true }) + 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 + 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', '' }, + 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 dap.listeners.before.event_terminated['dapui_config'] = function() dapui.close {} end