From 6ebd713b90634878a601eeef3ffc0eb6961937a5 Mon Sep 17 00:00:00 2001 From: Cameron Ring Date: Sat, 16 Nov 2024 20:12:21 -0800 Subject: [PATCH] feat: fixes #394 option for auto-restore notif --- lua/auto-session/config.lua | 2 ++ lua/auto-session/init.lua | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/auto-session/config.lua b/lua/auto-session/config.lua index 4ec6a3f..175d50b 100644 --- a/lua/auto-session/config.lua +++ b/lua/auto-session/config.lua @@ -23,6 +23,7 @@ local M = {} ---@field args_allow_single_directory? boolean Follow normal sesion save/load logic if launched with a single directory as the only argument ---@field args_allow_files_auto_save? boolean|function Allow saving a session even when launched with a file argument (or multiple files/dirs). It does not load any existing session first. While you can just set this to true, you probably want to set it to a function that decides when to save a session when launched with file args. See documentation for more detail ---@field continue_restore_on_error? boolean Keep loading the session even if there's an error. Set to false to get the line number of an error when loading a session +---@field show_auto_restore_notif? boolean Whether to show a notification when auto-restoring ---@field log_level? string|integer "debug", "info", "warn", "error" or vim.log.levels.DEBUG, vim.log.levels.INFO, vim.log.levels.WARN, vim.log.levels.ERROR ---@field cwd_change_handling? boolean Follow cwd changes, saving a session before change and restoring after ---@field session_lens? SessionLens Session lens configuration options @@ -76,6 +77,7 @@ local defaults = { args_allow_single_directory = true, -- Follow normal sesion save/load logic if launched with a single directory as the only argument args_allow_files_auto_save = false, -- Allow saving a session even when launched with a file argument (or multiple files/dirs). It does not load any existing session first. While you can just set this to true, you probably want to set it to a function that decides when to save a session when launched with file args. See documentation for more detail continue_restore_on_error = true, -- Keep loading the session even if there's an error + show_auto_restore_notif = false, -- Whether to show a notification when auto-restoring cwd_change_handling = false, -- Follow cwd changes, saving a session before change and restoring after log_level = "error", -- Sets the log level of the plugin (debug, info, warn, error). diff --git a/lua/auto-session/init.lua b/lua/auto-session/init.lua index d959196..baeec0f 100644 --- a/lua/auto-session/init.lua +++ b/lua/auto-session/init.lua @@ -445,7 +445,7 @@ function AutoSession.AutoRestoreSession(session_name) return false end - return AutoSession.RestoreSession(session_name, false) + return AutoSession.RestoreSession(session_name, Config.show_auto_restore_notif) end ---@private @@ -493,7 +493,7 @@ function AutoSession.auto_restore_session_at_vim_enter() local last_session_name = Lib.get_latest_session(AutoSession.get_root_dir()) if last_session_name then Lib.logger.debug("Found last session: " .. last_session_name) - if AutoSession.RestoreSession(last_session_name, false) then + if AutoSession.RestoreSession(last_session_name, Config.show_auto_restore_notif) then return true end end