fix(ftplugin/c): Setup debugger only if the executable exists
Removed redundant `load_launchjs` as the plugin loads it automatically
This commit is contained in:
parent
b09c001954
commit
b2f592d529
1 changed files with 46 additions and 40 deletions
|
@ -28,47 +28,53 @@ local conf = require("telescope.config").values
|
||||||
local actions = require("telescope.actions")
|
local actions = require("telescope.actions")
|
||||||
local action_state = require("telescope.actions.state")
|
local action_state = require("telescope.actions.state")
|
||||||
|
|
||||||
if require('user.file_exists').file_exists(vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]) .. "/.vscode/launch.json") then
|
if vim.fn.executable('gdb') == 1 then
|
||||||
require("dap.ext.vscode").load_launchjs(nil, { cppdbg = { "c", "cpp", "asm" } })
|
dap.adapters.gdb = {
|
||||||
|
type = "executable",
|
||||||
|
command = "gdb",
|
||||||
|
args = { "-i", "dap" }
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
dap.adapters.gdb = {
|
-- DAP loads this automatically as of now. May be needed to load the debugger for asm?
|
||||||
type = "executable",
|
-- if require('user.file_exists').file_exists(vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]) .. "/.vscode/launch.json") then
|
||||||
command = "gdb",
|
-- require("dap.ext.vscode").load_launchjs(nil, { cppdbg = { "c", "cpp", "asm" } })
|
||||||
args = { "-i", "dap" }
|
-- require("dap.ext.vscode").load_launchjs(nil, { gdb = { "c", "cpp", "asm" } })
|
||||||
}
|
-- end
|
||||||
|
|
||||||
dap.adapters.cppdbg = {
|
if vim.fn.executable('OpenDebugAD7') == 1 then
|
||||||
id = 'cppdbg',
|
dap.adapters.cppdbg = {
|
||||||
type = 'executable',
|
id = 'cppdbg',
|
||||||
command = 'OpenDebugAD7',
|
type = 'executable',
|
||||||
}
|
command = 'OpenDebugAD7',
|
||||||
|
}
|
||||||
|
|
||||||
dap.configurations.c = {
|
dap.configurations.c = {
|
||||||
{
|
{
|
||||||
name = "Launch an executable",
|
name = "Launch an executable",
|
||||||
type = "cppdbg",
|
type = "cppdbg",
|
||||||
request = "launch",
|
request = "launch",
|
||||||
cwd = "${workspaceFolder}",
|
cwd = "${workspaceFolder}",
|
||||||
program = function()
|
program = function()
|
||||||
return coroutine.create(function(coro)
|
return coroutine.create(function(coro)
|
||||||
local opts = {}
|
local opts = {}
|
||||||
pickers
|
pickers
|
||||||
.new(opts, {
|
.new(opts, {
|
||||||
prompt_title = "Path to executable",
|
prompt_title = "Path to executable",
|
||||||
finder = finders.new_oneshot_job({ "fd", "--hidden", "--no-ignore", "--type", "x" }, {}),
|
finder = finders.new_oneshot_job({ "fd", "--hidden", "--no-ignore", "--type", "x" }, {}),
|
||||||
sorter = conf.generic_sorter(opts),
|
sorter = conf.generic_sorter(opts),
|
||||||
attach_mappings = function(buffer_number)
|
attach_mappings = function(buffer_number)
|
||||||
actions.select_default:replace(function()
|
actions.select_default:replace(function()
|
||||||
actions.close(buffer_number)
|
actions.close(buffer_number)
|
||||||
coroutine.resume(coro, action_state.get_selected_entry()[1])
|
coroutine.resume(coro, action_state.get_selected_entry()[1])
|
||||||
end)
|
end)
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
:find()
|
:find()
|
||||||
end)
|
end)
|
||||||
end,
|
end,
|
||||||
stopAtBeginningOfMainSubprogram = true,
|
stopAtBeginningOfMainSubprogram = true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue