refactor(debug): inline C/C++ DAP setup into debug plugin spec
dap_cpp.lua was a separate module used in exactly one place. Inlined setup_cpp_dap() directly into debug.lua to remove the unnecessary indirection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cbfd797e56
commit
0db92a7f4b
|
|
@ -1,43 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
local function has_configuration(configurations, name, adapter)
|
||||
for _, configuration in ipairs(configurations or {}) do
|
||||
if configuration.name == name and configuration.type == adapter then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function M.setup(dap)
|
||||
dap = dap or require 'dap'
|
||||
|
||||
dap.adapters.codelldb = dap.adapters.codelldb or {
|
||||
type = 'executable',
|
||||
command = 'codelldb',
|
||||
}
|
||||
|
||||
local launch_name = 'Launch current file (codelldb)'
|
||||
local launch_configuration = {
|
||||
name = launch_name,
|
||||
type = 'codelldb',
|
||||
request = 'launch',
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = '${workspaceFolder}',
|
||||
stopOnEntry = false,
|
||||
args = {},
|
||||
}
|
||||
|
||||
for _, language in ipairs { 'c', 'cpp' } do
|
||||
dap.configurations[language] = dap.configurations[language] or {}
|
||||
|
||||
if not has_configuration(dap.configurations[language], launch_name, 'codelldb') then
|
||||
table.insert(dap.configurations[language], vim.deepcopy(launch_configuration))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -6,6 +6,44 @@
|
|||
-- be extended to other languages as well. That's why it's called
|
||||
-- kickstart.nvim and not kitchen-sink.nvim ;)
|
||||
|
||||
local function has_configuration(configurations, name, adapter)
|
||||
for _, configuration in ipairs(configurations or {}) do
|
||||
if configuration.name == name and configuration.type == adapter then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
local function setup_cpp_dap(dap)
|
||||
dap.adapters.codelldb = dap.adapters.codelldb or {
|
||||
type = 'executable',
|
||||
command = 'codelldb',
|
||||
}
|
||||
|
||||
local launch_name = 'Launch current file (codelldb)'
|
||||
local launch_configuration = {
|
||||
name = launch_name,
|
||||
type = 'codelldb',
|
||||
request = 'launch',
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = '${workspaceFolder}',
|
||||
stopOnEntry = false,
|
||||
args = {},
|
||||
}
|
||||
|
||||
for _, language in ipairs { 'c', 'cpp' } do
|
||||
dap.configurations[language] = dap.configurations[language] or {}
|
||||
|
||||
if not has_configuration(dap.configurations[language], launch_name, 'codelldb') then
|
||||
table.insert(dap.configurations[language], vim.deepcopy(launch_configuration))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
-- NOTE: Yes, you can install new plugins here!
|
||||
'mfussenegger/nvim-dap',
|
||||
|
|
@ -146,6 +184,6 @@ return {
|
|||
},
|
||||
}
|
||||
|
||||
require('custom.dap_cpp').setup(dap)
|
||||
setup_cpp_dap(dap)
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue