This commit is contained in:
Jaroslaw Konik 2026-05-11 10:03:30 +02:00
parent 22937e4023
commit 46c9390696

110
init.lua
View file

@ -117,61 +117,61 @@ require("lazy").setup({
vim.g.molten_output_win_max_height = 12 vim.g.molten_output_win_max_height = 12
end, end,
}, },
{ -- {
'rmagatti/auto-session', -- 'rmagatti/auto-session',
lazy = false, -- lazy = false,
opts = { -- opts = {
save_extra_data = function(_) -- save_extra_data = function(_)
local ok, breakpoints = pcall(require, "dap.breakpoints") -- local ok, breakpoints = pcall(require, "dap.breakpoints")
if not ok or not breakpoints then -- if not ok or not breakpoints then
return -- return
end -- end
--
local bps = {} -- local bps = {}
local breakpoints_by_buf = breakpoints.get() -- local breakpoints_by_buf = breakpoints.get()
for buf, buf_bps in pairs(breakpoints_by_buf) do -- for buf, buf_bps in pairs(breakpoints_by_buf) do
bps[vim.api.nvim_buf_get_name(buf)] = buf_bps -- bps[vim.api.nvim_buf_get_name(buf)] = buf_bps
end -- end
if vim.tbl_isempty(bps) then -- if vim.tbl_isempty(bps) then
return -- return
end -- end
local extra_data = { -- local extra_data = {
breakpoints = bps, -- breakpoints = bps,
} -- }
return vim.fn.json_encode(extra_data) -- return vim.fn.json_encode(extra_data)
end, -- end,
--
restore_extra_data = function(_, extra_data) -- restore_extra_data = function(_, extra_data)
local json = vim.fn.json_decode(extra_data) -- local json = vim.fn.json_decode(extra_data)
--
if json.breakpoints then -- if json.breakpoints then
local ok, breakpoints = pcall(require, "dap.breakpoints") -- local ok, breakpoints = pcall(require, "dap.breakpoints")
--
if not ok or not breakpoints then -- if not ok or not breakpoints then
return -- return
end -- end
vim.notify("restoring breakpoints") -- vim.notify("restoring breakpoints")
for buf_name, buf_bps in pairs(json.breakpoints) do -- for buf_name, buf_bps in pairs(json.breakpoints) do
for _, bp in pairs(buf_bps) do -- for _, bp in pairs(buf_bps) do
local line = bp.line -- local line = bp.line
local opts = { -- local opts = {
condition = bp.condition, -- condition = bp.condition,
log_message = bp.logMessage, -- log_message = bp.logMessage,
hit_condition = bp.hitCondition, -- hit_condition = bp.hitCondition,
} -- }
--
local bufnr = vim.fn.bufnr(buf_name, true) -- local bufnr = vim.fn.bufnr(buf_name, true)
if vim.fn.bufloaded(bufnr) == 0 then -- if vim.fn.bufloaded(bufnr) == 0 then
vim.api.nvim_buf_call(bufnr, vim.cmd.edit) -- vim.api.nvim_buf_call(bufnr, vim.cmd.edit)
end -- end
--
breakpoints.set(opts, bufnr, line) -- breakpoints.set(opts, bufnr, line)
end -- end
end -- end
end -- end
end, -- end,
} -- }
}, -- },
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = {} opts = {}