feat: don't save the session when no files are open (save_empty = false)

This commit is contained in:
Folke Lemaitre 2023-10-13 07:57:09 +02:00
parent 4b8051c01f
commit e9afeaf3a7
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 15 additions and 1 deletions

View file

@ -34,6 +34,18 @@ function M.start()
Config.options.pre_save()
end
if not Config.options.save_empty then
local bufs = vim.tbl_filter(function(b)
if vim.bo[b].buftype ~= "" then
return false
end
return vim.api.nvim_buf_get_name(b) ~= ""
end, vim.api.nvim_list_bufs())
if #bufs == 0 then
return
end
end
M.save()
end,
})