2021-07-12 10:47:09 +02:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
---@class PersistenceOptions
|
2023-02-28 09:05:58 +00:00
|
|
|
---@field pre_save? fun()
|
2024-05-16 20:03:16 +03:00
|
|
|
---@field post_save? fun()
|
|
|
|
---@field pre_load? fun()
|
|
|
|
---@field post_load? fun()
|
2021-07-12 10:47:09 +02:00
|
|
|
local defaults = {
|
2024-06-11 20:53:08 -07:00
|
|
|
dir = vim.fn.stdpath("state") .. "/sessions/", -- directory where session files are saved
|
2023-10-13 07:57:09 +02:00
|
|
|
options = { "buffers", "curdir", "tabpages", "winsize", "skiprtp" }, -- sessionoptions used for saving
|
|
|
|
save_empty = false, -- don't save if there are no open file buffers
|
2021-07-12 10:47:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
---@type PersistenceOptions
|
|
|
|
M.options = {}
|
|
|
|
|
|
|
|
function M.setup(opts)
|
|
|
|
M.options = vim.tbl_deep_extend("force", {}, defaults, opts or {})
|
|
|
|
vim.fn.mkdir(M.options.dir, "p")
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|