try to fix nvim hanging when it exits
parent
1934279d0b
commit
cf4c944b21
|
|
@ -113,29 +113,29 @@ end
|
||||||
---Save the session
|
---Save the session
|
||||||
---@param opts? { force?: boolean, session?: string }
|
---@param opts? { force?: boolean, session?: string }
|
||||||
function M.save(opts)
|
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")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("SessionWritePost", {
|
|
||||||
callback = function()
|
|
||||||
if type(config.save_post) == "function" then
|
|
||||||
config.save_post()
|
|
||||||
end
|
|
||||||
M.fire("SavePost")
|
|
||||||
return true -- returning true deletes autocmd after fired
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
M.fire("SavePre")
|
|
||||||
if type(config.save_pre) == "function" then
|
|
||||||
config.save_pre()
|
|
||||||
end
|
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
|
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")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("SessionWritePost", {
|
||||||
|
callback = function()
|
||||||
|
if type(config.save_post) == "function" then
|
||||||
|
config.save_post()
|
||||||
|
end
|
||||||
|
M.fire("SavePost")
|
||||||
|
return true -- returning true deletes autocmd after fired
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
M.fire("SavePre")
|
||||||
|
if type(config.save_pre) == "function" then
|
||||||
|
config.save_pre()
|
||||||
|
end
|
||||||
vim.api.nvim_command("wa")
|
vim.api.nvim_command("wa")
|
||||||
vim.api.nvim_command("mksession! " .. e(opts.session or vim.g.persisting_session or M.current()))
|
vim.api.nvim_command("mksession! " .. e(opts.session or vim.g.persisting_session or M.current()))
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue