diff --git a/README.md b/README.md index e3d5854..3fed92e 100644 --- a/README.md +++ b/README.md @@ -301,6 +301,7 @@ The plugin fires events at various points during its lifecycle which users can h - `PersistedDeletePre` - For _before_ a session is deleted - `PersistedDeletePost` - For _after_ a session is deleted - `PersistedStateChange` - For when a session is _started_ or _stopped_ +- `PersistedToggled` - For when a session is toggled For example, to ensure that the excellent [minimap](https://github.com/wfxr/minimap.vim) plugin is not saved into a session, an autocmd can be created to hook into the `PersistedSavePre` event: diff --git a/lua/persisted/init.lua b/lua/persisted/init.lua index 4eec5cd..add28f3 100644 --- a/lua/persisted/init.lua +++ b/lua/persisted/init.lua @@ -194,6 +194,8 @@ end ---Determines whether to load, start or stop a session ---@return nil function M.toggle() + vim.api.nvim_exec_autocmds("User", { pattern = "PersistedToggled" }) + if vim.g.persisting == nil then return M.load() end