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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
local dap = require('dap')
dap.defaults.fallback.external_terminal = {
command = '/usr/bin/wezterm';
args = {'-e'};
}
--dap.adapters.lldb = {
-- type = 'executable',
-- --command = '/usr/bin/lldb-vscode', -- adjust as needed, must be absolute path
-- --command = '/usr/bin/vscode-lldb', -- adjust as needed, must be absolute path
-- command = 'codelldb',
-- --command = 'lldb',
-- --command = codelldb_root,
-- --command = vim.fn.stdpath("data") .. '/mason/bin/codelldb',
-- name = 'lldb',
-- host = '127.0.0.1',
-- port = 13000
--}
--
--local lldb = {
-- name = "Launch lldb",
-- type = "lldb", -- matches the adapter
-- request = "launch", -- could also attach to a currently running process
-- program = function()
-- return vim.fn.input(
-- "Path to executable: ",
-- vim.fn.getcwd() .. "/",
-- "file"
-- )
-- end,
-- cwd = "${workspaceFolder}",
-- stopOnEntry = false,
-- args = {},
-- runInTerminal = false,
-- --type = 'server',
-- port = "${port}",
-- executable = {
-- --command = vim.fn.stdpath("data") .. '/mason/bin/codelldb',
-- args = { "--port", "${port}" },
-- }
--}
dap.adapters.cppdbg = {
id = 'cppdbg',
type = 'executable',
--command = vim.fn.stdpath('data') .. '/mason/bin/OpenDebugAD7',
command = os.getenv("HOME") .. '/apps/cpptools/extension/debugAdapters/bin/OpenDebugAD7',
}
dap.adapters.codelldb = {
type = 'server',
port = "${port}",
executable = {
command = os.getenv("HOME") .. '/apps/codelldb/extension/adapter/codelldb',
args = {"--port", "${port}"},
}
}
dap.adapters.lldb = {
type = 'executable',
command = '/usr/bin/lldb-vscode',
name = "lldb"
}
dap.configurations.cpp = {
{
name = "Launch file",
type = "cppdbg",
--request = "launch",
request = "Attach",
processId = function()
return tonumber(vim.fn.input({ prompt = "Pid: "}))
end,
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
stopAtEntry = true,
MIMode = 'gdb',
--miDebuggerServerAddress = 'localhost:1234',
miDebuggerPath = 'gdb-oneapi',
--miDebuggerPath = '/usr/bin/gdb',
externalConsole = true,
setupCommands = {
{
text = '-enable-pretty-printing',
description = 'enable pretty printing',
ignoreFailures = false
}
},
cwd = '${workspaceFolder}',
},
}
-- dap.adapters.cppdbg = {
-- name = 'cppdbg',
-- type = 'executable',
-- command = vim.fn.stdpath('data') .. '/mason/bin/OpenDebugAD7',
-- }
-- dap.configurations.cpp = {
-- {
-- name = 'Launch',
-- type = 'cppdbg',
-- request = 'launch',
-- --request = 'attach',
-- MIMode = 'gdb',
-- --cwd = '${workspaceFolder}',
-- -- udb='live',
-- -- miDebuggerPath = 'udb',
-- setupCommands= {
-- {
-- description= "Enable pretty-printing for gdb",
-- text= "-enable-pretty-printing",
-- ignoreFailures= true,
-- }
-- },
-- program = '${file}',
-- cwd = vim.fn.getcwd(),
-- --attach = {
-- -- pidProperty = "processId",
-- -- pidSelect = "ask"
-- --},
-- stopAtEntry = true,
-- --program = 'main',
-- --program = '${workspaceFolder}/main'
-- --program = '${file}',
-- --program = function()
-- -- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
-- --end,
-- },
-- }
--require('dap').configurations.c = {
-- lldb -- different debuggers or more configurations can be used here
--}
-- cpp (c,c++,rust)
--dap.configurations.c = {
-- {
-- name = 'Launch',
-- type = 'lldb',
-- request = 'launch',
-- --program = function()
-- -- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
-- --end,
-- terminal = 'integrated',
-- console = 'integratedTerminal',
-- program = function()
-- return vim.fn.input('program: ', vim.loop.cwd() .. '/', 'file')
-- end,
-- cwd = "${workspaceFolder}",
-- stopOnEntry = false,
-- args = {},
-- },
--}
-- If you want to use this for Rust and C, add something like this:
dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp
-- javascript
--dap.adapters.node2 = {
-- type = 'executable',
-- command = 'node-debug2-adapter',
-- args = {},
--}
--dap.configurations.javascript = {
-- {
-- name = 'Launch',
-- type = 'node2',
-- request = 'attach',
-- program = '${file}',
-- cwd = vim.fn.getcwd(),
-- sourceMaps = true,
-- protocol = 'inspector',
-- console = 'integratedTerminal',
-- },
--}
dap.adapters.python = {
type = 'executable';
command = vim.trim(vim.fn.system('which python'));
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.
stopOnEntry = true,
},
}
local dapui = require('dapui')
-- setup repl
dap.repl.commands = vim.tbl_extend('force', dap.repl.commands, {
exit = { 'q', 'exit' },
custom_commands = {
['.run_to_cursor'] = dap.run_to_cursor,
['.restart'] = dap.run_last
}
})
-- setup dapui
dapui.setup({
mappings = {
expand = "<CR>",
open = "o",
remove = "D",
edit = "e",
repl = "r",
toggle = "t",
},
layouts = {
{ elements = { "scopes", "breakpoints", "stacks" }, size = 0.33, position = "right" },
{ elements = { "repl", "watches" }, size = 0.27, position = "bottom" },
},
icons = { expanded = "-", collapsed = "$" },
--controls = { enabled = false },
floating = { border = "rounded", mappings = { close = { "q", "<esc>", "<c-o>" } } },
})
-- signs
vim.fn.sign_define("DapStopped", { text = '=>', texthl = 'DiagnosticWarn', numhl = 'DiagnosticWarn' })
vim.fn.sign_define("DapBreakpoint", { text = '<>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' })
vim.fn.sign_define("DapBreakpointRejected", { text = '!>', texthl = 'DiagnosticError', numhl = 'DiagnosticError' })
vim.fn.sign_define("DapBreakpointCondition", { text = '?>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' })
vim.fn.sign_define("DapLogPoint", { text = '.>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' })
-- options
dap.defaults.fallback.focus_terminal = false
dap.defaults.fallback.terminal_win_cmd = '10split new'
|