mirror of
https://github.com/folke/persistence.nvim.git
synced 2025-07-24 20:54:52 +02:00
feat(persistence): add pre-
and post-
load hooks (#24)
* Add optional hook typings to config object * Add optional hooks conditional calls * Add hooks description to main readme
This commit is contained in:
parent
4982499c16
commit
3d443bd0a7
3 changed files with 18 additions and 0 deletions
|
@ -56,6 +56,10 @@ function M.start()
|
|||
end
|
||||
|
||||
M.save()
|
||||
|
||||
if type(Config.options.post_save) == "function" then
|
||||
Config.options.post_save()
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
@ -76,7 +80,15 @@ function M.load(opt)
|
|||
opt = opt or {}
|
||||
local sfile = opt.last and M.get_last() or M.get_current()
|
||||
if sfile and vim.fn.filereadable(sfile) ~= 0 then
|
||||
if type(Config.options.pre_load) == "function" then
|
||||
Config.options.pre_load()
|
||||
end
|
||||
|
||||
vim.cmd("silent! source " .. e(sfile))
|
||||
|
||||
if type(Config.options.post_load) == "function" then
|
||||
Config.options.post_load()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue