feat: add before and after callbacks
parent
831caa7261
commit
ac24493128
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue