Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add AutoSession.session_exists_for_cwd() function #286

Merged
merged 1 commit into from
Apr 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lua/auto-session/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,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