nvim/lua/configs/dap.lua
2024-10-20 16:57:27 +02:00

60 lines
1.4 KiB
Lua

local dap = require("dap")
-- dap.configurations.c = {
-- {
-- name = "Launch",
-- type = "gdb",
-- request = "launch",
-- program = function()
-- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
-- end,
-- cwd = "${workspaceFolder}",
-- },
-- }
dap.adapters.cppdbg = {
type = "executable",
command = "gdb",
args = { "-i", "dap" },
-- console = 'externalTerminal',
-- terminal_win_cmd = "tabnew",
}
dap.adapters.lldb = {
type = 'executable',
command = 'lldb-dap', -- adjust as needed, must be absolute path
name = 'lldb'
}
dap.adapters.debugpy = function(cb, config)
if config.request == 'attach' then
---@diagnostic disable-next-line: undefined-field
local port = (config.connect or config).port
---@diagnostic disable-next-line: undefined-field
local host = (config.connect or config).host or '127.0.0.1'
cb({
type = 'server',
port = assert(port, '`connect.port` is required for a python `attach` configuration'),
host = host,
options = {
source_filetype = 'python',
},
})
else
cb({
type = 'executable',
command = 'python',
args = { '-m', 'debugpy.adapter' },
options = {
source_filetype = 'python',
},
})
end
end
require('dap.ext.vscode').load_launchjs("dap_config.json", {
cppdbg = { 'c', 'cpp' },
lldb = { 'c', 'cpp' },
debugpy = { 'python' }
})
dap.set_log_level("TRACE")