parent
218fcb7eb9
commit
03f11b519f
|
|
@ -130,8 +130,11 @@ function M.stop()
|
|||
end
|
||||
|
||||
---Save the session
|
||||
---@param opt? table
|
||||
---@return nil
|
||||
function M.save()
|
||||
function M.save(opt)
|
||||
opt = opt or {}
|
||||
|
||||
-- If the user has stopped the session, then do not save
|
||||
if vim.g.persisting == false then
|
||||
return
|
||||
|
|
@ -145,10 +148,12 @@ function M.save()
|
|||
|
||||
vim.api.nvim_exec_autocmds("User", { pattern = "PersistedSavePre" })
|
||||
|
||||
if
|
||||
(config.options.autosave and type(config.options.should_autosave) == "function")
|
||||
and not config.options.should_autosave()
|
||||
then
|
||||
-- Autosave config option takes priority unless it's overriden
|
||||
if not config.options.autosave and not opt.override then
|
||||
return
|
||||
end
|
||||
|
||||
if type(config.options.should_autosave) == "function" and not config.options.should_autosave() then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ local persisted = require("persisted")
|
|||
-- Create the user commands
|
||||
vim.cmd([[command! SessionStart :lua require("persisted").start()]])
|
||||
vim.cmd([[command! SessionStop :lua require("persisted").stop()]])
|
||||
vim.cmd([[command! SessionSave :lua require("persisted").save()]])
|
||||
vim.cmd([[command! SessionSave :lua require("persisted").save({ override = true })]])
|
||||
vim.cmd([[command! SessionLoad :lua require("persisted").load()]])
|
||||
vim.cmd([[command! SessionLoadLast :lua require("persisted").load({ last = true })]])
|
||||
vim.cmd([[command! -nargs=1 SessionLoadFromFile :lua require("persisted").load({ session = <f-args> })]])
|
||||
|
|
|
|||
Loading…
Reference in New Issue