Telescope is optional but is recommended
{"Trouble-Truffle/sesh.nvim", dependencies = {"nvim-telescope/telescope.nvim"}}
use {"Trouble-Truffle/sesh.nvim", requires = {"nvim-telescope/telescope.nvim"}}"}
require("sesh").setup({
autosave = {
enable = false -- Autosave on writes and exit
autocmds = {} -- Save on additional autocmds
}
autoload = false -- Load a session if `cwd` matches
autoswitch {
enable = false -- Close buffers in current session before loading
exclude_ft = {} -- Disable certain buffers from being closed
}
sessions_info = vim.fn.stdpath('data') .. "/session-info.json"
-- Location of the json file containing session infos
session_path = vim.fn.stdpath('data') .. "/sesions"
-- Location of stored session files
post_load_hook = function() end
-- Run functions on load
exclude_name = {} -- Automatically remove buffers with this name, see ## Exclude Name
-- ^ USE THIS OPTION WITH CAUTION
})
the exclude_name
option automatically removes buffers of that name from created session files.
-
This option is highly dangerous as it simply removes all lines containing names listed. When a name consisting of a vim command i.e.
bufadd
,edit
, etc. is passed then loading them may be fail or be broken. -
This option does not close the windows of the deleted buffers. When loading you may see multiple blank windows.
-
This is a hacky solution but it can be used to automatically close all empty buffers on load
post_load_hook = function()
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
if ("" == vim.api.nvim_buf_get_option(buf, "filetype")) then
vim.api.nvim_buf_delete(buf, {})
end
end
end
- When using nvim-tree.lua and symbols-outline.nvim you can use
exclude_name = {'NvimTree_1', 'OUTLINE'}
as well as the post_load_hook
defined above.
require("telescope").load_extension('sesh')
From there you can call Telescope sesh
or via lua require('telescope').extensions.sesh.sesh()
mode | bind | action |
---|---|---|
n |
x |
calls sesh.delete() on selection |
i |
<A-x> |
calls sesh.delete() on selection |
* |
<CR> |
calls sesh.load() on selection |
Saves a session from the current working directory. When not in a session it Calls vim.ui.input
to get the name. Otherwise it launches a y/n prompt
Deletes the provided session. If called without arguments it launches vim.ui.select
to choose.
Loads the provided session. If called without arguments it launches vim.ui.select
to choose. If autoswitch
is enabled it calls upon sesh.switch()
Simillar to sesh.load
but instead it requires an argument. Switching closes all current buffers before sourcing a session.
Returns the contents of session-info.json
Returns the current sourced session
Returns current configuration
Returns a list of all sessions in session_path
Updates session-info.json
- leap.nvim for their
make.py