return { { 'mfussenegger/nvim-dap', dependencies = { 'mfussenegger/nvim-dap-python', 'rcarriga/nvim-dap-ui', 'nvim-neotest/nvim-nio', { 'nvim-neotest/neotest', dependencies = { 'nvim-neotest/neotest-python', } }, }, keys = { { "br", require('dap').toggle_breakpoint, "Toggle breakpoint" }, { "cn", require('dap').continue, "Debug start/continue" }, { "si", require('dap').step_into, "Debug step into" }, { "so", require('dap').step_over, "Debug step over" }, }, ft = { "python" }, config = function() local dap = require 'dap' vim.fn.sign_define('DapBreakpoint', { text = '⬤', texthl = 'ErrorMsg', linehl = '', numhl = 'ErrorMsg' }) vim.fn.sign_define('DapBreakpointCondition', { text = '⬤', texthl = 'ErrorMsg', linehl = '', numhl = 'SpellBad' }) local pythonPath = function() local cwd = vim.loop.cwd() if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then return cwd .. '/venv/bin/python' else return '/Users/michael/.pyenv/shims/python3' end end local set_python_dap = function() require('dap-python').setup() -- earlier so setup the various defaults ready to be replaced dap.configurations.python = { { type = 'python', request = 'launch', name = "Launch file", program = "${file}", pythonPath = pythonPath() }, { type = 'python', request = 'launch', name = 'DAP Django', program = vim.loop.cwd() .. '/manage.py', args = { 'runserver', '--noreload' }, justMyCode = true, django = true, console = "integratedTerminal", }, { type = 'python', request = 'attach', name = 'Attach remote', connect = function() return { host = '127.0.0.1', port = 5678 } end, }, { type = 'python', request = 'launch', name = 'Launch file with arguments', program = '${file}', args = function() local args_string = vim.fn.input('Arguments: ') return vim.split(args_string, " +") end, console = "integratedTerminal", pythonPath = pythonPath() } } dap.adapters.python = { type = 'executable', command = pythonPath(), args = { '-m', 'debugpy.adapter' } } end set_python_dap() vim.api.nvim_create_autocmd({ "DirChanged" }, { callback = function() set_python_dap() end, }) require("dapui").setup() require("neotest").setup({ adapters = { require("neotest-python")({ dap = { django = true }, }), } }) end, }, }