From 402aac41d0777137bb35f499111551a3b2458a70 Mon Sep 17 00:00:00 2001 From: Michal Date: Fri, 5 Sep 2025 13:05:55 +0200 Subject: [PATCH] Add Auto Session plugin Helps with managing previous sessions --- lua/custom/plugins/auto-session.lua | 57 +++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 lua/custom/plugins/auto-session.lua diff --git a/lua/custom/plugins/auto-session.lua b/lua/custom/plugins/auto-session.lua new file mode 100644 index 00000000..c1e2b75d --- /dev/null +++ b/lua/custom/plugins/auto-session.lua @@ -0,0 +1,57 @@ +return { + 'rmagatti/auto-session', + lazy = false, + keys = { + -- Will use Telescope if installed or a vim.ui.select picker otherwise + { 'wr', 'AutoSession search', desc = 'Session search' }, + { 'ws', 'AutoSession save', desc = 'Save session' }, + { 'wa', 'AutoSession toggle', desc = 'Toggle autosave' }, + }, + + ---enables autocomplete for opts + ---@module "auto-session" + ---@type AutoSession.Config + opts = { + -- The following are already the default values, no need to provide them if these are already the settings you want. + session_lens = { + picker = nil, -- "telescope"|"snacks"|"fzf"|"select"|nil Pickers are detected automatically but you can also manually choose one. Falls back to vim.ui.select + mappings = { + -- Mode can be a string or a table, e.g. {"i", "n"} for both insert and normal mode + delete_session = { 'i', '' }, + alternate_session = { 'i', '' }, + copy_session = { 'i', '' }, + }, + + picker_opts = { + -- For Telescope, you can set theme options here, see: + -- https://github.com/nvim-telescope/telescope.nvim/blob/master/doc/telescope.txt#L112 + -- https://github.com/nvim-telescope/telescope.nvim/blob/master/lua/telescope/themes.lua + -- + -- border = true, + -- layout_config = { + -- width = 0.8, -- Can set width and height as percent of window + -- height = 0.5, + -- }, + + -- For Snacks, you can set layout options here, see: + -- https://github.com/folke/snacks.nvim/blob/main/docs/picker.md#%EF%B8%8F-layouts + -- + -- preset = "dropdown", + -- preview = false, + -- layout = { + -- width = 0.4, + -- height = 0.4, + -- }, + + -- For Fzf-Lua, picker_opts just turns into winopts, see: + -- https://github.com/ibhagwan/fzf-lua#customization + -- + -- height = 0.8, + -- width = 0.50, + }, + + -- Telescope only: If load_on_setup is false, make sure you use `:AutoSession search` to open the picker as it will initialize everything first + load_on_setup = true, + }, + }, +}