Skip to content

Commit

Permalink
Add support for C and C++
Browse files Browse the repository at this point in the history
Basic configurations that requires binaries to be manually build first
and then point where they are to start debugging.
  • Loading branch information
julianolf committed Mar 3, 2024
1 parent 51d84f7 commit 49a54f6
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lua/dap-lldb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ local function find_codelldb()
return nil
end

local function read_target()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. sep, "file")
end

local function list_targets(build_selection)
local selection = build_selection or "bins"
local command = { "cargo", "build", "--" .. selection, "--quiet", "--message-format", "json" }
Expand Down Expand Up @@ -68,7 +72,7 @@ local function select_target(build_selection)
end

if #targets == 0 then
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. sep, "file")
return read_target()
end

if #targets == 1 then
Expand Down Expand Up @@ -98,7 +102,7 @@ local base_conf = {
type = "codelldb",
request = "launch",
cwd = "${workspaceFolder}",
program = select_target,
program = read_target,
stopOnEntry = false,
}

Expand All @@ -116,10 +120,18 @@ function M.setup(opts)
},
}

dap.configurations.rust = {
dap.configurations.c = {
base_conf,
vim.tbl_extend("force", base_conf, { name = "Debug (+args)", args = read_args }),
}
dap.configurations.cpp = dap.configurations.c
dap.configurations.rust = {
vim.tbl_extend("force", base_conf, {
program = select_target,
}),
vim.tbl_extend("force", base_conf, {
name = "Debug (+args)",
program = select_target,
args = read_args,
}),
vim.tbl_extend("force", base_conf, {
Expand Down

0 comments on commit 49a54f6

Please sign in to comment.