trying stuff
parent
12cdb6d705
commit
e69c014833
|
|
@ -110,35 +110,33 @@ function M.stop()
|
|||
M.fire("Stop")
|
||||
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,
|
||||
-- })
|
||||
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
|
||||
---@param opts? { force?: boolean, session?: string }
|
||||
function M.save(opts)
|
||||
vim.schedule(function()
|
||||
opts = opts or {}
|
||||
opts = opts or {}
|
||||
|
||||
-- Do not save the session if should_save evals to false...unless it's forced
|
||||
if type(config.should_save) == "function" and not config.should_save() and not opts.force then
|
||||
M.fire("SavePost")
|
||||
return
|
||||
end
|
||||
-- Do not save the session if should_save evals to false...unless it's forced
|
||||
if type(config.should_save) == "function" and not config.should_save() and not opts.force then
|
||||
M.fire("SavePost")
|
||||
return
|
||||
end
|
||||
|
||||
M.fire("SavePre")
|
||||
if type(config.save_pre) == "function" then
|
||||
config.save_pre()
|
||||
end
|
||||
pcall(vim.api.nvim_command, "wa")
|
||||
vim.api.nvim_command("mksession! " .. e(opts.session or vim.g.persisting_session or M.current()))
|
||||
end)
|
||||
M.fire("SavePre")
|
||||
if type(config.save_pre) == "function" then
|
||||
config.save_pre()
|
||||
end
|
||||
pcall(vim.api.nvim_command, "wa")
|
||||
vim.api.nvim_command("mksession! " .. e(opts.session or vim.g.persisting_session or M.current()))
|
||||
end
|
||||
|
||||
---Delete the current session
|
||||
|
|
|
|||
Loading…
Reference in New Issue