Seshi.nvim is a Git-aware session manager for Neovim with Telescope integration.
-
Git-aware Session Management
- Creates and manages sessions based on the current Git branch
- Automatically switches working directory and Git branch when loading a session
-
Telescope Integration
- Quick session switching using Telescope
- Delete sessions using Telescope
-
Autoload Functionality
- Option to automatically load a session based on the current working directory and active Git branch
-
Event Hooks
- Trigger events before and after loading/saving sessions.
SeshiLoadPre
SeshiLoadPost
SeshiSavePre
SeshiSavePost
-- Lua
{
"sebajun9/seshi.nvim",
lazy = false, -- Required only if autoloading.
opt = {}
}
-- Lua
{
"sebajun9/seshi.nvim",
lazy = false, -- Required only if autoloading.
opt = {
save_dir = vim.fn.expand(vim.fn.stdpath('data') .. '/sessions/'),
autoload = true,
use_git_root = true,
silent = false,
telescope = {
mappings = {
delete_session = '<C-d>',
},
},
}
}
}
-
save_dir
Session files will be saved to and loaded fromsave_dir
. -
autoload
Ifautoload
is set totrue
, upon loadingnvim
without any arguments, will attempt to load an existing session file for the current working directory and Git branch. -
use_git_root
Ifuse_git_root
is set to false, session files are associated with the working directory:SeshiSave
was run in. If set to true, session files are associated with the root directory of the repository. -
silent
Ifsilent
is set totrue
, it will suppress print statements out of seshi.nvim. -
telescope.mappings.delete-session
Key map for deleting a session file while inside of Telescope.
- Start Neovim in your project
- Open your buffers and windows
- Run
:SeshiSave
- Your buffers and windows are now saved for the current directory and branch
- Start Neovim
- Run
:SeshiList
to bring up a Telescope picker with available sessions - Select the session you want
- Start coding!
- Start Neovim
seshi.nvim
will try to load a session file for the current project and branch- Start coding!
For switching sessions, it is recommended to use an autocmd to perform any clean up tasks before switching projects. Here is a basic autocmd to get started:
local seshi_group = vim.api.nvim_create_augroup('SeshiEvents', {})
vim.api.nvim_create_autocmd({ 'User' }, {
pattern = 'SeshiLoadPre',
group = seshi_group,
callback = function()
-- Uncomment this if you want to save the current session before cleaning up.
-- local seshi = require 'seshi'
-- if seshi.current_session_exists() then
-- seshi.save_session()
-- end
-- Note that I've occasionally had strange interactions with other plugins
-- that create special buffers. My solution was to disable the offending
-- plugins before running `%bd!` and then enabling them after.
vim.cmd '%bd!'
end,
})
- Run
:SeshiList
- Highlight the session to delete
- Press the delete_session keymap (default
<C-d>
)
:SeshiSave
Saves the session for the current directory and Git branch.
:SeshiList
Opens a Telescope picket with a list of sessions. Making a selection loads the
session. You can also delete a session by pressing the delete_session
keymap (default <C-d>
).
:SeshiLoadCurrent
Tries to load a session for the current directory and branch.
:SeshiDeleteCurrent
Tries to delete an existing session for the current directory and branch.