From 78eb9262ecf5ea778bc744676c291008c897baaa Mon Sep 17 00:00:00 2001 From: Warren Hood Date: Tue, 15 Nov 2022 01:36:57 +0200 Subject: [PATCH] Add debugging and test runners --- .../.config/nvim/lua/warrenhood/keybinds.lua | 36 +++++++++++++ .../nvim/lua/warrenhood/plugins-config.lua | 50 +++++++++++++++++++ .../.config/nvim/lua/warrenhood/plugins.lua | 45 +++++++++++++++-- 3 files changed, 127 insertions(+), 4 deletions(-) diff --git a/neovim/.config/nvim/lua/warrenhood/keybinds.lua b/neovim/.config/nvim/lua/warrenhood/keybinds.lua index 0715e79..973cfe4 100644 --- a/neovim/.config/nvim/lua/warrenhood/keybinds.lua +++ b/neovim/.config/nvim/lua/warrenhood/keybinds.lua @@ -45,6 +45,42 @@ map('n', 'sv', ':vsplit', { desc = 'Split Vertical' }) map('n', 'sh', ':split', { desc = 'Split Horizontal' }) +-- Debugging +map("n", "", ":lua require('dapui').toggle()") +map("n", "", ":lua require('dap').toggle_breakpoint()") +map("n", "", ":lua require('dap').continue()") + +map("n", "", ":lua require('dap').step_over()") +map("n", "", ":lua require('dap').step_into()") +map("n", "", ":lua require('dap').step_out()") + + +map("n", "dsc", ":lua require('dap').continue()") +map("n", "dsv", ":lua require('dap').step_over()") +map("n", "dsi", ":lua require('dap').step_into()") +map("n", "dso", ":lua require('dap').step_out()") + + +map("n", "dhh", ":lua require('dap.ui.variables').hover()") +map("v", "dhv", ":lua require('dap.ui.variables').visual_hover()") + + +map("n", "duh", ":lua require('dap.ui.widgets').hover()") +map("n", "duf", ":lua local widgets=require('dap.ui.widgets');widgets.centered_float(widgets.scopes)") + + +map("n", "dro", ":lua require('dap').repl.open()") +map("n", "drl", ":lua require('dap').repl.run_last()") + +map("n", "dbc", ":lua require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))") +map("n", "dbm", ":lua require('dap').set_breakpoint({ nil, nil, vim.fn.input('Log point message: '))") +map("n", "dbt", ":lua require('dap').toggle_breakpoint()") + + +map("n", "dc", ":lua require('dap.ui.variables').scopes()") +map("n", "di", ":lua require('dapui').toggle()") + + -- luasnip vim.cmd[[ " Use Tab to expand and jump through snippets diff --git a/neovim/.config/nvim/lua/warrenhood/plugins-config.lua b/neovim/.config/nvim/lua/warrenhood/plugins-config.lua index 49eb397..b45cc37 100644 --- a/neovim/.config/nvim/lua/warrenhood/plugins-config.lua +++ b/neovim/.config/nvim/lua/warrenhood/plugins-config.lua @@ -35,3 +35,53 @@ require("luasnip").config.set_config({ -- Setting LuaSnip config }) require("luasnip.loaders.from_lua").load({paths = "~/.config/nvim/LuaSnip/"}) + + +-- Which-key config +require('which-key').setup() +require('which-key').register({ + d = { + name = "Debug", + s = { + name = "Step", + c = { "lua require('dap').continue()", "Continue" }, + + v = { "lua require('dap').step_over()", "Step Over" }, + i = { "lua require('dap').step_into()", "Step Into" }, + o = { "lua require('dap').step_out()", "Step Out" }, + }, + h = { + name = "Hover", + h = { "lua require('dap.ui.variables').hover()", "Hover" }, + v = { "lua require('dap.ui.variables').visual_hover()", "Visual Hover" }, + }, + u = { + name = "UI", + + h = { "lua require('dap.ui.widgets').hover()", "Hover" }, + f = { "local widgets=require('dap.ui.widgets');widgets.centered_float(widgets.scopes)", "Float" }, + }, + r = { + name = "Repl", + o = { "lua require('dap').repl.open()", "Open" }, + + l = { "lua require('dap').repl.run_last()", "Run Last" }, + }, + b = { + name = "Breakpoints", + c = { + + "lua require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))", + "Breakpoint Condition", + }, + m = { + "lua require('dap').set_breakpoint({ nil, nil, vim.fn.input('Log point message: ') })", + "Log Point Message", + }, + t = { "lua require('dap').toggle_breakpoint()", "Create" }, + }, + c = { "lua require('dap').scopes()", "Scopes" }, + i = { "lua require('dap').toggle()", "Toggle" }, + }, + +}, { prefix = "" }) diff --git a/neovim/.config/nvim/lua/warrenhood/plugins.lua b/neovim/.config/nvim/lua/warrenhood/plugins.lua index 713ee1b..b5afd95 100644 --- a/neovim/.config/nvim/lua/warrenhood/plugins.lua +++ b/neovim/.config/nvim/lua/warrenhood/plugins.lua @@ -66,9 +66,6 @@ require("packer").startup(function() -- Which key for command suggestions use { "folke/which-key.nvim", - config = function() - require("which-key").setup() - end } -- Comments @@ -102,13 +99,53 @@ require("packer").startup(function() use { 'nvim-lualine/lualine.nvim', requires = { 'kyazdani42/nvim-web-devicons', opt = true }, - config = function () + config = function() require("lualine").setup { } end } + -- Test runner Stuff + use { + "nvim-neotest/neotest", + requires = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + "nvim-neotest/neotest-python", + }, + config = function() + require('neotest').setup { + adapters = { + require("neotest-python")({ + dap = { justMyCode = false }, + }), + }, + } + end + + } + + -- Debugging + use('mfussenegger/nvim-dap') -- Main debugging plugin + use { + 'rcarriga/nvim-dap-ui', + requires = { "mfussenegger/nvim-dap" }, + config = function() + require('dapui').setup() + end + } -- Better debugging UI + + use { + 'theHamsta/nvim-dap-virtual-text', + config = function() + require("nvim-dap-virtual-text").setup() + end + } -- Virtual text for nvim-dap + + + + -- Automatically set up configuration after cloning packer.nvim if packer_bootstrap then require("packer").sync()