feat: add before_source callback
parent
4fe0e3aeab
commit
b70eb5317d
|
|
@ -220,10 +220,13 @@ require("persisted").setup({
|
|||
|
||||
> **Note:** The author uses a *before* callback to ensure that [minimap.vim](https://github.com/wfxr/minimap.vim) is not written into the session. Its presence prevents the exact buffer and cursor position from being restored when loading a session
|
||||
|
||||
The plugin allows for an *after* callback to be executed in relation to a session being sourced:
|
||||
The plugin allows for *before* and *after* callbacks to be executed in relation to a session being sourced:
|
||||
|
||||
```lua
|
||||
require("persisted").setup({
|
||||
before_source = function()
|
||||
print("Sourcing...")
|
||||
end,
|
||||
after_source = function()
|
||||
-- Reload the LSP servers
|
||||
vim.lsp.stop_client(vim.lsp.get_active_clients())
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ local defaults = {
|
|||
ignored_dirs = nil, -- table of dirs that are ignored for auto-saving and auto-loading
|
||||
before_save = nil, -- function to run before the session is saved to disk
|
||||
after_save = nil, -- function to run after the session is saved to disk
|
||||
before_source = nil, -- function to run before the session is sourced
|
||||
after_source = nil, -- function to run after the session is sourced
|
||||
telescope = { -- options for the telescope extension
|
||||
before_source = nil, -- function to run before the session is sourced via telescope
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ function M.load(opt)
|
|||
local session = opt.last and get_last() or get_current()
|
||||
|
||||
if session and vim.fn.filereadable(session) ~= 0 then
|
||||
utils.load_session(session, _, config.options.after_source)
|
||||
utils.load_session(session, config.options.before_source, config.options.after_source)
|
||||
end
|
||||
|
||||
if config.options.autosave and (allow_dir() and not ignore_dir()) then
|
||||
|
|
|
|||
Loading…
Reference in New Issue