Skip to content

Commit

Permalink
Add func to check if a session in cwd exists (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdmill authored Oct 8, 2024
1 parent cbaebd9 commit ce43f2e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lua/session_manager/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ce43f2e

Please sign in to comment.