Update session save and restore behavior
This commit is contained in:
parent
19c453974f
commit
0578a3dede
@ -10,11 +10,14 @@ local function session_name()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function started_without_args()
|
||||||
|
return vim.fn.argc(-1) == 0
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Only restore and save session if NeoVim was started without any arguments
|
||||||
vim.api.nvim_create_autocmd("VimEnter", {
|
vim.api.nvim_create_autocmd("VimEnter", {
|
||||||
callback = function()
|
callback = function()
|
||||||
local started_without_args = vim.fn.argc(-1) == 0
|
if started_without_args() then
|
||||||
|
|
||||||
if started_without_args then
|
|
||||||
resession.load(session_name(), { dir = "dirsession", silence_errors = true })
|
resession.load(session_name(), { dir = "dirsession", silence_errors = true })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -22,7 +25,9 @@ vim.api.nvim_create_autocmd("VimEnter", {
|
|||||||
|
|
||||||
vim.api.nvim_create_autocmd("VimLeavePre", {
|
vim.api.nvim_create_autocmd("VimLeavePre", {
|
||||||
callback = function()
|
callback = function()
|
||||||
resession.save(session_name(), { dir = "dirsession", notify = false })
|
if started_without_args() then
|
||||||
|
resession.save(session_name(), { dir = "dirsession", notify = false })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user