trying stuff
parent
e69c014833
commit
ccc6bc20e2
|
|
@ -110,6 +110,11 @@ function M.stop()
|
|||
M.fire("Stop")
|
||||
end
|
||||
|
||||
---Save the session
|
||||
---@param opts? { force?: boolean, session?: string }
|
||||
function M.save(opts)
|
||||
opts = opts or {}
|
||||
|
||||
vim.api.nvim_create_autocmd("SessionWritePost", {
|
||||
callback = function()
|
||||
if type(config.save_post) == "function" then
|
||||
|
|
@ -119,12 +124,6 @@ vim.api.nvim_create_autocmd("SessionWritePost", {
|
|||
-- return true -- returning true deletes autocmd after fired
|
||||
end,
|
||||
})
|
||||
|
||||
---Save the session
|
||||
---@param opts? { force?: boolean, session?: string }
|
||||
function M.save(opts)
|
||||
opts = opts or {}
|
||||
|
||||
-- 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")
|
||||
|
|
@ -135,7 +134,10 @@ function M.save(opts)
|
|||
if type(config.save_pre) == "function" then
|
||||
config.save_pre()
|
||||
end
|
||||
local oldconfirm = vim.o.confirm
|
||||
vim.o.confirm = false
|
||||
pcall(vim.api.nvim_command, "wa")
|
||||
vim.o.confirm = oldconfirm
|
||||
vim.api.nvim_command("mksession! " .. e(opts.session or vim.g.persisting_session or M.current()))
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue