Move post load/save event creation to setup func
parent
07fd86682f
commit
0f07bade0c
|
|
@ -52,15 +52,6 @@ function M.load(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local session
|
local session
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("SessionLoadPost", {
|
|
||||||
callback = function()
|
|
||||||
if type(config.load_post) == "function" then
|
|
||||||
config.load_post()
|
|
||||||
end
|
|
||||||
M.fire("LoadPost")
|
|
||||||
return true -- returning deletes autocmd after fired
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
if opts.last then
|
if opts.last then
|
||||||
session = M.last()
|
session = M.last()
|
||||||
elseif opts.session then
|
elseif opts.session then
|
||||||
|
|
@ -120,16 +111,6 @@ function M.save(opts)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("SessionSavePost", {
|
|
||||||
callback = function()
|
|
||||||
if type(config.save_post) == "function" then
|
|
||||||
config.save_post()
|
|
||||||
end
|
|
||||||
M.fire("SavePost")
|
|
||||||
return true -- returning deletes autocmd after fired
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
M.fire("SavePre")
|
M.fire("SavePre")
|
||||||
if type(config.save_pre) == "function" then
|
if type(config.save_pre) == "function" then
|
||||||
config.save_pre()
|
config.save_pre()
|
||||||
|
|
@ -247,6 +228,26 @@ function M.setup(opts)
|
||||||
|
|
||||||
vim.fn.mkdir(config.save_dir, "p")
|
vim.fn.mkdir(config.save_dir, "p")
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("SessionSavePost", {
|
||||||
|
callback = function()
|
||||||
|
if type(config.save_post) == "function" then
|
||||||
|
config.save_post()
|
||||||
|
end
|
||||||
|
M.fire("SavePost")
|
||||||
|
return true -- returning deletes autocmd after fired
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("SessionLoadPost", {
|
||||||
|
callback = function()
|
||||||
|
if type(config.load_post) == "function" then
|
||||||
|
config.load_post()
|
||||||
|
end
|
||||||
|
M.fire("LoadPost")
|
||||||
|
return true -- returning deletes autocmd after fired
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
if config.autostart and M.allowed_dir() and vim.g.persisting == nil and not start_args then
|
if config.autostart and M.allowed_dir() and vim.g.persisting == nil and not start_args then
|
||||||
M.start()
|
M.start()
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue