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 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
|
||||
require("dap.ext.vscode").load_launchjs(nil, { cppdbg = { "c", "cpp", "asm" } })
|
||||
if vim.fn.executable('gdb') == 1 then
|
||||
dap.adapters.gdb = {
|
||||
type = "executable",
|
||||
command = "gdb",
|
||||
args = { "-i", "dap" }
|
||||
}
|
||||
end
|
||||
|
||||
dap.adapters.gdb = {
|
||||
type = "executable",
|
||||
command = "gdb",
|
||||
args = { "-i", "dap" }
|
||||
}
|
||||
-- DAP loads this automatically as of now. May be needed to load the debugger for asm?
|
||||
-- if require('user.file_exists').file_exists(vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]) .. "/.vscode/launch.json") then
|
||||
-- require("dap.ext.vscode").load_launchjs(nil, { cppdbg = { "c", "cpp", "asm" } })
|
||||
-- require("dap.ext.vscode").load_launchjs(nil, { gdb = { "c", "cpp", "asm" } })
|
||||
-- end
|
||||
|
||||
dap.adapters.cppdbg = {
|
||||
id = 'cppdbg',
|
||||
type = 'executable',
|
||||
command = 'OpenDebugAD7',
|
||||
}
|
||||
if vim.fn.executable('OpenDebugAD7') == 1 then
|
||||
dap.adapters.cppdbg = {
|
||||
id = 'cppdbg',
|
||||
type = 'executable',
|
||||
command = 'OpenDebugAD7',
|
||||
}
|
||||
|
||||
dap.configurations.c = {
|
||||
{
|
||||
name = "Launch an executable",
|
||||
type = "cppdbg",
|
||||
request = "launch",
|
||||
cwd = "${workspaceFolder}",
|
||||
program = function()
|
||||
return coroutine.create(function(coro)
|
||||
local opts = {}
|
||||
pickers
|
||||
.new(opts, {
|
||||
prompt_title = "Path to executable",
|
||||
finder = finders.new_oneshot_job({ "fd", "--hidden", "--no-ignore", "--type", "x" }, {}),
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(buffer_number)
|
||||
actions.select_default:replace(function()
|
||||
actions.close(buffer_number)
|
||||
coroutine.resume(coro, action_state.get_selected_entry()[1])
|
||||
end)
|
||||
return true
|
||||
end,
|
||||
})
|
||||
:find()
|
||||
end)
|
||||
end,
|
||||
stopAtBeginningOfMainSubprogram = true,
|
||||
},
|
||||
}
|
||||
dap.configurations.c = {
|
||||
{
|
||||
name = "Launch an executable",
|
||||
type = "cppdbg",
|
||||
request = "launch",
|
||||
cwd = "${workspaceFolder}",
|
||||
program = function()
|
||||
return coroutine.create(function(coro)
|
||||
local opts = {}
|
||||
pickers
|
||||
.new(opts, {
|
||||
prompt_title = "Path to executable",
|
||||
finder = finders.new_oneshot_job({ "fd", "--hidden", "--no-ignore", "--type", "x" }, {}),
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(buffer_number)
|
||||
actions.select_default:replace(function()
|
||||
actions.close(buffer_number)
|
||||
coroutine.resume(coro, action_state.get_selected_entry()[1])
|
||||
end)
|
||||
return true
|
||||
end,
|
||||
})
|
||||
:find()
|
||||
end)
|
||||
end,
|
||||
stopAtBeginningOfMainSubprogram = true,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue