Skip to content

Commit 4a7cbc3

Browse files
feat: autosave will save session on exit
1 parent f1374dc commit 4a7cbc3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lua/resession/config.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,16 @@ M.setup = function(config)
8282
autosave_timer:close()
8383
autosave_timer = nil
8484
end
85+
local autosave_group = vim.api.nvim_create_augroup("ResessionAutosave", { clear = true })
8586
if M.autosave.enabled then
87+
vim.api.nvim_create_autocmd("VimLeavePre", {
88+
group = autosave_group,
89+
callback = function()
90+
if resession.get_current() then
91+
resession.save(nil, { notify = false })
92+
end
93+
end,
94+
})
8695
autosave_timer = vim.loop.new_timer()
8796
timer = vim.loop.new_timer()
8897
timer:start(

0 commit comments

Comments
 (0)