first version of dap

This commit is contained in:
Oliver Hartmann 2022-07-31 13:32:14 +02:00
parent 8953d89f3c
commit d019626efb
2 changed files with 49 additions and 0 deletions

View File

@ -211,6 +211,11 @@ return require('packer').startup(function()
requires = {'tpope/vim-repeat'}, requires = {'tpope/vim-repeat'},
config = get_setup('my_leap') config = get_setup('my_leap')
} }
use {
'mfussenegger/nvim-dap',
requires = {'mfussenegger/nvim-dap-python'},
config = get_setup('my_dap')
}
if packer_bootstrap then if packer_bootstrap then
require('packer').sync() require('packer').sync()
end end

44
lua/setup/my_dap.lua Normal file
View File

@ -0,0 +1,44 @@
dap = require('dap')
local opts = { noremap = true, silent = false }
-- vim.keymap.set('n', '<F5>', dap.continue(), opts)
vim.keymap.set('n', '<F5>', ":lua require('dap').continue()<CR>", opts)
vim.keymap.set('n', '<F9>', ":lua require('dap').toggle_breakpoint()<CR>", opts)
vim.keymap.set('n', '<F10>', ":lua require('dap').step_over()<CR>", opts)
vim.keymap.set('n', '<F11>', ":lua require('dap').step_into()<CR>", opts)
vim.keymap.set('n', '<S-F11>', ":lua require('dap').step_out()<CR>", opts)
-- vim.keymap.set('n', '<F10>', dap.step_over(), opts)
-- vim.keymap.set('n', '<F11>', dap.step_into(), opts)
-- vim.keymap.set('n', '<S-F11>', dap.step_out(), opts)
dap.adapters.python = {
type = 'executable';
command = 'C:/Users/oli/AppData/Local/nvim-data/mason/packages/debugpy/venv/Scripts/python.exe';
args = { '-m', 'debugpy.adapter' };
}
dap.configurations.python = {
{
-- The first three options are required by nvim-dap
type = 'python'; -- the type here established the link to the adapter definition: `dap.adapters.python`
request = 'launch';
name = "Launch file";
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
program = "${file}"; -- This configuration will launch the current file if used.
pythonPath = function()
-- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
-- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
-- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
local cwd = vim.fn.getcwd()
if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then
return cwd .. '/venv/bin/python'
elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then
return cwd .. '/.venv/bin/python'
else
return '/usr/bin/python'
end
end;
},
}
-- require('dap-python').setup('C:/Users/oli/AppData/Local/nvim-data/mason/packages/debugpy/venv/Scripts/python.exe')