1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
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 = {
{ "<leader>br", require('dap').toggle_breakpoint, "Toggle breakpoint" },
{ "<leader>cn", require('dap').continue, "Debug start/continue" },
{ "<leader>si", require('dap').step_into, "Debug step into" },
{ "<leader>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,
},
}
|