feat: add additional events
parent
383b5ba6b5
commit
4866194140
|
|
@ -268,6 +268,9 @@ The plugin fires events at various points during its lifecycle which users can h
|
||||||
- `PersistedTelescopeLoadPost` - For _after_ a session is loaded via Telescope
|
- `PersistedTelescopeLoadPost` - For _after_ a session is loaded via Telescope
|
||||||
- `PersistedSavePre` - For _before_ a session is saved
|
- `PersistedSavePre` - For _before_ a session is saved
|
||||||
- `PersistedSavePost` - For _after_ a session is saved
|
- `PersistedSavePost` - For _after_ a session is saved
|
||||||
|
- `PersistedDeletePre` - For _before_ a session is deleted
|
||||||
|
- `PersistedDeletePost` - For _after_ a session is deleted
|
||||||
|
- `PersistedStateChange` - For when a session is _started_ or _stopped_
|
||||||
|
|
||||||
For example, to ensure that the excellent [minimap](https://github.com/wfxr/minimap.vim) plugin is not saved into a session, an autocommand can be created to hook into the `PersistedSavePre` event:
|
For example, to ensure that the excellent [minimap](https://github.com/wfxr/minimap.vim) plugin is not saved into a session, an autocommand can be created to hook into the `PersistedSavePre` event:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ end
|
||||||
---@return nil
|
---@return nil
|
||||||
function M.start()
|
function M.start()
|
||||||
vim.g.persisting = true
|
vim.g.persisting = true
|
||||||
|
vim.api.nvim_exec_autocmds("User", { pattern = "PersistedStateChange" })
|
||||||
end
|
end
|
||||||
|
|
||||||
---Stop recording a session
|
---Stop recording a session
|
||||||
|
|
@ -125,6 +126,7 @@ end
|
||||||
function M.stop()
|
function M.stop()
|
||||||
vim.g.persisting = false
|
vim.g.persisting = false
|
||||||
vim.g.persisting_session = nil
|
vim.g.persisting_session = nil
|
||||||
|
vim.api.nvim_exec_autocmds("User", { pattern = "PersistedStateChange" })
|
||||||
end
|
end
|
||||||
|
|
||||||
---Save the session
|
---Save the session
|
||||||
|
|
@ -172,10 +174,14 @@ end
|
||||||
function M.delete()
|
function M.delete()
|
||||||
local session = get_current()
|
local session = get_current()
|
||||||
if session and vim.loop.fs_stat(session) ~= 0 then
|
if session and vim.loop.fs_stat(session) ~= 0 then
|
||||||
|
vim.api.nvim_exec_autocmds("User", { pattern = "PersistedDeletePre" })
|
||||||
|
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
M.stop()
|
M.stop()
|
||||||
vim.fn.system("rm " .. e(session))
|
vim.fn.system("rm " .. e(session))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
vim.api.nvim_exec_autocmds("User", { pattern = "PersistedDeletePost" })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue