allow switching session even if we are not currently in a session.\n add notifications when saving and loading
parent
144e9caf9d
commit
abeb001d5f
|
|
@ -58,6 +58,7 @@ function M.load(opts)
|
|||
config.load_post()
|
||||
end
|
||||
M.fire("LoadPost")
|
||||
vim.api.nvim_notify("Session Loaded\n" .. session, vim.log.levels.OFF, {})
|
||||
return true -- returning deletes autocmd after fired
|
||||
end,
|
||||
})
|
||||
|
|
@ -117,6 +118,7 @@ function M.save(opts)
|
|||
|
||||
-- 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
|
||||
|
||||
|
|
@ -125,6 +127,7 @@ function M.save(opts)
|
|||
if type(config.save_post) == "function" then
|
||||
config.save_post()
|
||||
end
|
||||
vim.api.nvim_notify("Session Saved", vim.log.levels.OFF, {})
|
||||
M.fire("SavePost")
|
||||
return true -- returning true deletes autocmd after fired
|
||||
end,
|
||||
|
|
@ -169,7 +172,6 @@ function M.switch(session_file_path)
|
|||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "PersistedSavePost",
|
||||
callback = function()
|
||||
vim.print("delete and load")
|
||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.api.nvim_buf_is_loaded(buf) then
|
||||
vim.api.nvim_buf_delete(buf, {})
|
||||
|
|
|
|||
|
|
@ -32,22 +32,6 @@ function M.load_session(session)
|
|||
return true -- returning deletes autocmd after fired
|
||||
end,
|
||||
})
|
||||
|
||||
-- vim.api.nvim_create_autocmd("User", {
|
||||
-- pattern = "PersistedSavePost",
|
||||
-- callback = function()
|
||||
-- vim.print("delete and load")
|
||||
-- for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||
-- if vim.api.nvim_buf_is_loaded(buf) then
|
||||
-- vim.api.nvim_buf_delete(buf, {})
|
||||
-- end
|
||||
-- end
|
||||
-- persisted.load({ session = session.file_path })
|
||||
-- return true
|
||||
-- end,
|
||||
-- })
|
||||
--
|
||||
-- persisted.save({ session = vim.g.persisted_loaded_session })
|
||||
persisted.switch(session.file_path)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue