feat: add before and after callbacks

main
olimorris 2022-03-05 15:22:13 +00:00
parent 831caa7261
commit ac24493128
2 changed files with 6 additions and 0 deletions

View File

@ -6,6 +6,8 @@ local defaults = {
use_git_branch = false, -- create session files based on the branch of the git enabled repository
autosave = true, -- automatically save session files
options = { "buffers", "curdir", "tabpages", "winsize" }, -- session options used for saving
before_save = function() end, -- function to run before the session is saved to disk
after_save = function() end, -- function to run after the session is saved to disk
}
---@type PersistedOptions

View File

@ -64,11 +64,15 @@ function M.stop()
end
function M.save()
config.options.before_save()
local tmp = vim.o.sessionoptions
vim.o.sessionoptions = table.concat(config.options.options, ",")
vim.cmd("mks! " .. e(M.get_current()))
vim.o.sessionoptions = tmp
vim.g.persisting = true
config.options.after_save()
end
function M.delete()