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()
|
config.load_post()
|
||||||
end
|
end
|
||||||
M.fire("LoadPost")
|
M.fire("LoadPost")
|
||||||
|
vim.api.nvim_notify("Session Loaded\n" .. session, vim.log.levels.OFF, {})
|
||||||
return true -- returning deletes autocmd after fired
|
return true -- returning deletes autocmd after fired
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
@ -117,6 +118,7 @@ function M.save(opts)
|
||||||
|
|
||||||
-- Do not save the session if should_save evals to false...unless it's forced
|
-- 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
|
if type(config.should_save) == "function" and not config.should_save() and not opts.force then
|
||||||
|
M.fire("SavePost")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -125,6 +127,7 @@ function M.save(opts)
|
||||||
if type(config.save_post) == "function" then
|
if type(config.save_post) == "function" then
|
||||||
config.save_post()
|
config.save_post()
|
||||||
end
|
end
|
||||||
|
vim.api.nvim_notify("Session Saved", vim.log.levels.OFF, {})
|
||||||
M.fire("SavePost")
|
M.fire("SavePost")
|
||||||
return true -- returning true deletes autocmd after fired
|
return true -- returning true deletes autocmd after fired
|
||||||
end,
|
end,
|
||||||
|
|
@ -169,7 +172,6 @@ function M.switch(session_file_path)
|
||||||
vim.api.nvim_create_autocmd("User", {
|
vim.api.nvim_create_autocmd("User", {
|
||||||
pattern = "PersistedSavePost",
|
pattern = "PersistedSavePost",
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.print("delete and load")
|
|
||||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||||
if vim.api.nvim_buf_is_loaded(buf) then
|
if vim.api.nvim_buf_is_loaded(buf) then
|
||||||
vim.api.nvim_buf_delete(buf, {})
|
vim.api.nvim_buf_delete(buf, {})
|
||||||
|
|
|
||||||
|
|
@ -32,22 +32,6 @@ function M.load_session(session)
|
||||||
return true -- returning deletes autocmd after fired
|
return true -- returning deletes autocmd after fired
|
||||||
end,
|
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)
|
persisted.switch(session.file_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue