From 6c2df0572b0730d3bcbfdbc09009a513f262a2a4 Mon Sep 17 00:00:00 2001 From: mace Date: Fri, 27 Dec 2024 14:17:13 +0100 Subject: [PATCH] optimize session handling --- lua/custom/plugins/init.lua | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index e390460..2e15d08 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -131,9 +131,21 @@ return { -- Lua sesion manager { "olimorris/persisted.nvim", - lazy = false, -- make sure the plugin is always loaded at startup - config = true - }, + lazy = false, + opts = { + autoload = false, + autosave = true, + use_git_branch = true, + }, + config = function(_, opts) + local persisted = require("persisted") + persisted.branch = function() + local branch = vim.fn.systemlist("git branch --show-current")[1] + return vim.v.shell_error == 0 and branch or nil + end + persisted.setup(opts) + end, + } -- { -- "folke/persistence.nvim", -- event = "BufReadPre", -- this will only start session saving when an actual file was opened