Remove delays around load and save, create pre/post callbacks instead
parent
1bcfe10f2a
commit
28e72fb1ff
|
|
@ -67,13 +67,16 @@ function M.load(opts)
|
|||
if session and vim.fn.filereadable(session) ~= 0 then
|
||||
vim.g.persisting_session = not config.follow_cwd and session or nil
|
||||
vim.g.persisted_loaded_session = session
|
||||
|
||||
M.fire("LoadPre")
|
||||
vim.defer_fn(function()
|
||||
if config.load_pre and vim.is_callable(config.load_pre) then
|
||||
config.load_pre()
|
||||
end
|
||||
vim.cmd("silent! source " .. e(session))
|
||||
vim.defer_fn(function()
|
||||
if config.load_post and vim.is_callable(config.load_post) then
|
||||
config.load_post()
|
||||
end
|
||||
M.fire("LoadPost")
|
||||
end, 15)
|
||||
end, 15)
|
||||
elseif opts.autoload and type(config.on_autoload_no_session) == "function" then
|
||||
config.on_autoload_no_session()
|
||||
end
|
||||
|
|
@ -114,12 +117,14 @@ function M.save(opts)
|
|||
end
|
||||
|
||||
M.fire("SavePre")
|
||||
vim.defer_fn(function()
|
||||
if config.save_pre and vim.is_callable(config.save_pre) then
|
||||
config.save_pre()
|
||||
end
|
||||
vim.cmd("mks! " .. e(opts.session or vim.g.persisting_session or M.current()))
|
||||
vim.defer_fn(function()
|
||||
if config.save_post and vim.is_callable(config.save_post) then
|
||||
config.save_post()
|
||||
end
|
||||
M.fire("SavePost")
|
||||
end, 15)
|
||||
end, 15)
|
||||
end
|
||||
|
||||
---Delete the current session
|
||||
|
|
|
|||
Loading…
Reference in New Issue