Skip to content

Commit

Permalink
Merge pull request #286 from ldelossa/add-session-exists-cwd-func
Browse files Browse the repository at this point in the history
add AutoSession.session_exists_for_cwd() function
  • Loading branch information
rmagatti authored Apr 14, 2024
2 parents 667df30 + a39ce39 commit 9e0a169
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lua/auto-session/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ local function auto_save_conditions_met()
return is_enabled() and auto_save() and not suppress_session() and is_allowed_dir() and not bypass_save_by_filetype()
end

-- Quickly checks if a session file exists for the current working directory.
-- This is useful for starter plugins which don't want to display 'restore session'
-- unless a session for the current working directory exists.
function AutoSession.session_exists_for_cwd()
session_file = get_session_file_name(vim.fn.getcwd())
return Lib.is_readable(session_file)
end

---AutoSaveSession
---Function called by auto_session to trigger auto_saving sessions, for example on VimExit events.
---@param sessions_dir? string the session directory to auto_save a session for. If empty this function will end up using the cwd to infer what session to save for.
Expand Down

0 comments on commit 9e0a169

Please sign in to comment.