From ce43f2eb2a52492157d7742e5f684b9a42bb3e5c Mon Sep 17 00:00:00 2001 From: cdmill <115658917+cdmill@users.noreply.github.com> Date: Tue, 8 Oct 2024 15:40:52 -0600 Subject: [PATCH] Add func to check if a session in cwd exists (#143) --- lua/session_manager/init.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/session_manager/init.lua b/lua/session_manager/init.lua index df52fc6..d31c75f 100644 --- a/lua/session_manager/init.lua +++ b/lua/session_manager/init.lua @@ -67,6 +67,17 @@ function session_manager.load_current_dir_session(discard_current) return false end +--- Checks if a session for the current working directory exists. +---@return boolean: `true` if session was found, `false` otherwise. +function session_manager.current_dir_session_exists() + local cwd = vim.uv.cwd() + if cwd then + local session = config.dir_to_session_filename(cwd) + return session:exists() + end + return false +end + --- If in a git repo, tries to load a session for the repo's root directory ---@return boolean: `true` if session was loaded, `false` otherwise. function session_manager.load_git_session(discard_current)