From 9b0dcc66bab92152274c236b668f3fcabbee30e3 Mon Sep 17 00:00:00 2001 From: fiplox Date: Tue, 17 Jan 2023 17:49:52 +0100 Subject: [PATCH] configure dapui, add bindings --- lua/plugins/nvim-dap.lua | 119 +++++++++++++++++++++++++-------------- 1 file changed, 76 insertions(+), 43 deletions(-) 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