diff --git a/lua/rustaceanvim/commands/debuggables.lua b/lua/rustaceanvim/commands/debuggables.lua index 4d6c6b58..018b27ea 100644 --- a/lua/rustaceanvim/commands/debuggables.lua +++ b/lua/rustaceanvim/commands/debuggables.lua @@ -137,6 +137,12 @@ local function add_debuggables_to_nvim_dap(debuggables) local name = 'Cargo: ' .. build_label(debuggable.args) if not _dap_configuration_added[name] then configuration.name = name + if configuration.initCommands == nil then + configuration.initCommands = {} + end + if config.dap.init_commands ~= nil then + table.insert(configuration.initCommands, config.dap.init_commands) + end table.insert(dap.configurations.rust, configuration) _dap_configuration_added[name] = true end diff --git a/lua/rustaceanvim/config/init.lua b/lua/rustaceanvim/config/init.lua index 61c3d3ca..02a2017a 100644 --- a/lua/rustaceanvim/config/init.lua +++ b/lua/rustaceanvim/config/init.lua @@ -261,6 +261,9 @@ vim.g.rustaceanvim = vim.g.rustaceanvim ---Whether to get Rust types via initCommands (rustlib/etc/lldb_commands, lldb only). ---Default: `true`. ---@field load_rust_types? fun():boolean | boolean +--- +---Extra initCommand to apply to all debuggable targets +---@field init_commands? string ---@alias rustaceanvim.dap.Command string diff --git a/lua/rustaceanvim/config/internal.lua b/lua/rustaceanvim/config/internal.lua index fdb96cdf..22c16bce 100644 --- a/lua/rustaceanvim/config/internal.lua +++ b/lua/rustaceanvim/config/internal.lua @@ -409,6 +409,8 @@ local RustaceanDefaultConfig = { local type = is_codelldb_adapter(adapter) and 'codelldb' or 'lldb' return load_dap_configuration(type) end, + ---@type string? + init_commands = nil, }, -- debug info was_g_rustaceanvim_sourced = vim.g.rustaceanvim ~= nil,