From a4ad2c7026be9f5faa0471c9f91fca2c3e76c35e Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 13:19:16 +0100 Subject: [PATCH] Add nvim-dap --- home/.config/nvim/lua/pluginconf/nvim-dap.lua | 24 +++++++++++++++++++ home/.config/nvim/lua/plugins.lua | 5 ++++ 2 files changed, 29 insertions(+) create mode 100644 home/.config/nvim/lua/pluginconf/nvim-dap.lua diff --git a/home/.config/nvim/lua/pluginconf/nvim-dap.lua b/home/.config/nvim/lua/pluginconf/nvim-dap.lua new file mode 100644 index 0000000..84f8167 --- /dev/null +++ b/home/.config/nvim/lua/pluginconf/nvim-dap.lua @@ -0,0 +1,24 @@ +local vim = require("vim") +local cmd = vim.cmd + +-- Define dap mappings (:help dap-mapping) +local prefix = ":lua require('dap')." +Keymap("n", "", prefix .. "continue()") +Keymap("n", "", prefix .. "step_over()") +Keymap("n", "", prefix .. "step_into()") +Keymap("n", "", prefix .. "step_out()") +Keymap("n", "", prefix .. "toggle_breakpoint()") +Keymap("n", "", prefix .. "set_breakpoint(vim.fn.input('Breakpoint condition: '))") +Keymap("n", "", prefix .. "set_breakpoint(nil, nil, vim.fn.input('Log point message: '))") +Keymap("n", "di", prefix .. "repl.open()") +Keymap("n", "dl", prefix .. "run_last()") + +-- Setup dap for python (requires nvim-dap-python plugin) +require('dap-python').setup('/usr/bin/python') -- Path to python with `debugpy` library installed +require('dap-python').test_runner = 'pytest' -- Use pytest to run unit tests + +-- Python mappings +local pyprefix = ":lua require('dap-python')." +Keymap("n", "dptm", pyprefix .. "test_method()") +Keymap("n", "dptc", pyprefix .. "test_class()") +Keymap("v", "ds", "" .. pyprefix .. "debug_selection()") diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 06e0e06..db505b3 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -85,6 +85,11 @@ return require("packer").startup({ "tpope/vim-commentary", config = get_plugin_file("commentary.lua") }) + use({ + "mfussenegger/nvim-dap", + config = get_plugin_file("nvim-dap.lua"), + requires = { "mfussenegger/nvim-dap-python", opt = true }, + }) use({ "junegunn/fzf", run = function() fn['fzf#install']() end,