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
|
local status_ok, dap = pcall(require, "dap")
if not status_ok then
return
end
-- Debugpy
dap.adapters.python = {
type = 'executable',
command = 'python',
args = { '-m', 'debugpy.adapter' },
}
dap.configurations.python = {
{
type = 'python',
request = 'launch',
name = 'Launch file',
program = '${file}',
pythonPath = function()
local venv_path = vim.fn.getenv 'VIRTUAL_ENVIRONMENT'
if venv_path ~= vim.NIL and venv_path ~= '' then
return venv_path .. '/bin/python'
else
return '/usr/bin/python'
end
end,
},
}
-- Neovim Lua
dap.adapters.nlua = function(callback, config)
callback { type = 'server', host = config.host, port = config.port }
end
dap.configurations.lua = {
{
type = 'nlua',
request = 'attach',
name = 'Attach to running Neovim instance',
host = function()
local value = vim.fn.input 'Host [127.0.0.1]: '
if value ~= '' then
return value
end
return '127.0.0.1'
end,
port = function()
local val = tonumber(vim.fn.input 'Port: ')
assert(val, 'Please provide a port number')
return val
end,
},
}
-- lldb
dap.adapters.lldb = {
type = 'executable',
command = '/usr/bin/lldb-vscode',
name = 'lldb',
}
dap.configurations.cpp = {
{
name = 'Launch',
type = 'lldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
args = {},
runInTerminal = false,
},
}
dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp
vim.cmd [[command! BreakpointToggle lua require('dap').toggle_breakpoint()]]
vim.cmd [[command! Debug lua require('dap').continue()]]
vim.cmd [[command! DapREPL lua require('dap').repl.open()]]
local tele_status_ok, telescope = pcall(require, "telescope")
if not tele_status_ok then
return
end
telescope.load_extension('dap')
|