Skip to content

Commit

Permalink
feat: fixes #394 option for auto-restore notif
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronr committed Nov 17, 2024
1 parent e3d96ac commit 6ebd713
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lua/auto-session/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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).

Expand Down
4 changes: 2 additions & 2 deletions lua/auto-session/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6ebd713

Please sign in to comment.