Add nvim-dap

This commit is contained in:
ItsDrike 2021-12-06 13:19:16 +01:00
parent dce7dd58d0
commit a4ad2c7026
No known key found for this signature in database
GPG key ID: FB8CA11A2CF3A843
2 changed files with 29 additions and 0 deletions

View file

@ -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", "<F5>", prefix .. "continue()<CR>")
Keymap("n", "<F10>", prefix .. "step_over()<CR>")
Keymap("n", "<F11>", prefix .. "step_into()<CR>")
Keymap("n", "<leader><F11>", prefix .. "step_out()<CR>")
Keymap("n", "<F9>", prefix .. "toggle_breakpoint()<CR>")
Keymap("n", "<leader><F9>", prefix .. "set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>")
Keymap("n", "<F8>", prefix .. "set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>")
Keymap("n", "<leader>di", prefix .. "repl.open()<CR>")
Keymap("n", "<leader>dl", prefix .. "run_last()<CR>")
-- 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", "<leader>dptm", pyprefix .. "test_method()<CR>")
Keymap("n", "<leader>dptc", pyprefix .. "test_class()<CR>")
Keymap("v", "<leader>ds", "<ESC>" .. pyprefix .. "debug_selection()<CR>")

View file

@ -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,