Using packer.nvim
use {
"AbaoFromCUG/session.nvim"
}
Using lazy.nvim
{
"AbaoFromCUG/session.nvim"
}
Default configuration
---@type session.Configuration
local config = {
enabled = true,
silent_restore = true, -- silent restore session, maybe cause confusion if you log in autocmd(e.g. BufWinEnter)
hooks = {
pre_save = {},
extra_save = {},
post_save = {},
pre_restore = {},
post_restore = {},
},
}
require("sesion").setup(config)
pre_save
will called before save sessionextra_save
will called after save session. Hook can return vim cmd which will be called when last reopen session automaticallypost_save
will called afterextra_save
pre_restore
will called before restore sessionpost_restore
will called after restore session
You can use hook ability via two methods, setup
and register
, they are same
---@type session.Configuration
local config = {
enabled = true,
hooks = {
pre_save = {
my_pre_save = function()
--some code
end
},
extra_save = {
my_extra_save = function()
return [[lua vim.notify("hello")]]
end,
},
post_save = {},
pre_restore = {},
post_restore = {},
},
}
require("sesion").setup(config)
local session = require("session")
session.register_hook("extra_save", "my_extra_save", function()
return [[lua vim.notify("hello")]]
end)
session.register_hook("post_restore", "my_post_restore", function()
vim.notify("world")
end)
session.nvim
support integrate with telescop.nvim
, use :Telescope session
to list session
local telescope = require("telescope")
telescope.load_extension("session")
- auto-sesion: a powerful and rich with features session manager