116 lines
2.8 KiB
Lua
116 lines
2.8 KiB
Lua
local dap = require("dap")
|
|
local dapui = require("dapui")
|
|
|
|
local function resolve_codelldb()
|
|
local is_windows = vim.fn.has("win32") == 1
|
|
local mason_codelldb = vim.fn.stdpath("data")
|
|
.. (is_windows and "/mason/bin/codelldb.cmd" or "/mason/bin/codelldb")
|
|
if vim.fn.executable(mason_codelldb) == 1 then
|
|
return mason_codelldb
|
|
end
|
|
|
|
local system_codelldb = vim.fn.exepath("codelldb")
|
|
if system_codelldb ~= "" then
|
|
return system_codelldb
|
|
end
|
|
|
|
return is_windows and "codelldb.cmd" or "codelldb"
|
|
end
|
|
|
|
require("nvim-dap-virtual-text").setup({
|
|
commented = true,
|
|
})
|
|
|
|
dap.adapters.codelldb = {
|
|
type = "server",
|
|
port = "${port}",
|
|
executable = {
|
|
command = resolve_codelldb(),
|
|
args = { "--port", "${port}" },
|
|
},
|
|
}
|
|
|
|
dap.configurations.cpp = {
|
|
{
|
|
name = "Launch file",
|
|
type = "codelldb",
|
|
request = "launch",
|
|
program = function()
|
|
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/build/", "file")
|
|
end,
|
|
cwd = "${workspaceFolder}",
|
|
stopOnEntry = false,
|
|
args = function()
|
|
local input = vim.fn.input("Program args: ")
|
|
if input == "" then
|
|
return {}
|
|
end
|
|
return vim.split(input, " ")
|
|
end,
|
|
runInTerminal = false,
|
|
},
|
|
}
|
|
dap.configurations.c = dap.configurations.cpp
|
|
|
|
vim.fn.sign_define("DapBreakpoint", {
|
|
text = "●",
|
|
texthl = "DiagnosticError",
|
|
linehl = "",
|
|
numhl = "",
|
|
})
|
|
vim.fn.sign_define("DapBreakpointCondition", {
|
|
text = "◆",
|
|
texthl = "DiagnosticWarn",
|
|
linehl = "",
|
|
numhl = "",
|
|
})
|
|
vim.fn.sign_define("DapLogPoint", {
|
|
text = "◉",
|
|
texthl = "DiagnosticInfo",
|
|
linehl = "",
|
|
numhl = "",
|
|
})
|
|
vim.fn.sign_define("DapStopped", {
|
|
text = "▶",
|
|
texthl = "DiagnosticOk",
|
|
linehl = "Visual",
|
|
numhl = "DiagnosticOk",
|
|
})
|
|
|
|
dapui.setup({
|
|
layouts = {
|
|
{
|
|
elements = {
|
|
{ id = "scopes", size = 0.30 },
|
|
{ id = "breakpoints", size = 0.20 },
|
|
{ id = "stacks", size = 0.25 },
|
|
{ id = "watches", size = 0.25 },
|
|
},
|
|
size = 45,
|
|
position = "left",
|
|
},
|
|
{
|
|
elements = {
|
|
{ id = "repl", size = 0.50 },
|
|
{ id = "console", size = 0.50 },
|
|
},
|
|
size = 12,
|
|
position = "bottom",
|
|
},
|
|
},
|
|
})
|
|
|
|
dap.listeners.after.event_initialized["dapui_config"] = function()
|
|
dapui.open()
|
|
end
|
|
dap.listeners.before.event_terminated["dapui_config"] = function()
|
|
dapui.close()
|
|
end
|
|
dap.listeners.before.event_exited["dapui_config"] = function()
|
|
dapui.close()
|
|
end
|
|
|
|
pcall(function()
|
|
require("telescope").load_extension("dap")
|
|
end)
|