122 lines
2.4 KiB
Lua
122 lines
2.4 KiB
Lua
local dap = require('dap')
|
|
|
|
--
|
|
-- go
|
|
--
|
|
|
|
-- dap.adapters.go = function(callback, config)
|
|
-- local stdout = vim.loop.new_pipe(false)
|
|
-- local handle local pid_or_err local port = 38697
|
|
-- local opts = {
|
|
-- stdio = {nil, stdout},
|
|
-- args = {"dap", "-l", "127.0.0.1:" .. port},
|
|
-- detached = true
|
|
-- }
|
|
-- handle, pid_or_err = vim.loop.spawn("dlv", opts, function(code)
|
|
-- stdout:close()
|
|
-- handle:close()
|
|
-- if code ~= 0 then
|
|
-- print('dlv exited with code', code)
|
|
-- end
|
|
-- end)
|
|
-- assert(handle, 'Error running dlv: ' .. tostring(pid_or_err))
|
|
-- stdout:read_start(function(err, chunk)
|
|
-- assert(not err, err)
|
|
-- if chunk then
|
|
-- vim.schedule(function()
|
|
-- require('dap.repl').append(chunk)
|
|
-- end)
|
|
-- end
|
|
-- end)
|
|
-- vim.defer_fn(
|
|
-- function()
|
|
-- callback({type = "server", host = "127.0.0.1", port = port})
|
|
-- end,
|
|
-- 100)
|
|
-- end
|
|
dap.adapters.go = {
|
|
type = "server",
|
|
host = "127.0.0.1",
|
|
port = 38697,
|
|
}
|
|
-- https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_dap.md
|
|
dap.configurations.go = {
|
|
{
|
|
type = "go",
|
|
name = "Debug",
|
|
request = "launch",
|
|
program = "${fileDirname}"
|
|
},
|
|
{
|
|
type = "go",
|
|
name = "Debug test", -- configuration for debugging test files
|
|
request = "launch",
|
|
mode = "test",
|
|
program = "${file}"
|
|
},
|
|
-- works with go.mod packages and sub packages
|
|
{
|
|
type = "go",
|
|
name = "Debug test (go.mod)",
|
|
request = "launch",
|
|
mode = "test",
|
|
program = "./${relativeFileDirname}"
|
|
}
|
|
}
|
|
|
|
--
|
|
-- python
|
|
--
|
|
|
|
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 cwd = vim.fn.getcwd()
|
|
if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then
|
|
return cwd .. '/venv/bin/python'
|
|
elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then
|
|
return cwd .. '/.venv/bin/python'
|
|
else
|
|
return '/usr/bin/python'
|
|
end
|
|
end;
|
|
},
|
|
}
|
|
|
|
--
|
|
-- C
|
|
--
|
|
|
|
dap.adapters.lldb = {
|
|
type = 'executable',
|
|
command = '/usr/bin/lldb-vscode',
|
|
name = "lldb"
|
|
}
|
|
|
|
dap.configurations.c = {
|
|
{
|
|
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,
|
|
},
|
|
}
|