Change where session post save autocommand is defined

main
Bryan 2024-11-11 05:57:15 -06:00
parent 88f5508d46
commit a8a0bfd2f1
1 changed files with 11 additions and 11 deletions

View File

@ -95,7 +95,7 @@ function M.start()
vim.api.nvim_create_autocmd("VimLeavePre", { vim.api.nvim_create_autocmd("VimLeavePre", {
group = vim.api.nvim_create_augroup("Persisted", { clear = true }), group = vim.api.nvim_create_augroup("Persisted", { clear = true }),
callback = function() callback = function()
-- M.save() M.save()
end, end,
}) })
@ -110,6 +110,16 @@ function M.stop()
M.fire("Stop") M.fire("Stop")
end end
vim.api.nvim_create_autocmd("SessionWritePost", {
callback = function()
if type(config.save_post) == "function" then
config.save_post()
end
M.fire("SavePost")
-- return true -- returning true deletes autocmd after fired
end,
})
---Save the session ---Save the session
---@param opts? { force?: boolean, session?: string } ---@param opts? { force?: boolean, session?: string }
function M.save(opts) function M.save(opts)
@ -122,16 +132,6 @@ function M.save(opts)
return return
end end
vim.api.nvim_create_autocmd("SessionWritePost", {
callback = function()
if type(config.save_post) == "function" then
config.save_post()
end
M.fire("SavePost")
return true -- returning true deletes autocmd after fired
end,
})
M.fire("SavePre") M.fire("SavePre")
if type(config.save_pre) == "function" then if type(config.save_pre) == "function" then
config.save_pre() config.save_pre()