Skip to content

Commit

Permalink
Add silent option for utils.get_sessions (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengrc19 authored May 11, 2024
1 parent 892c55f commit a0b9d25
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lua/session_manager/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ function utils.delete_session(filename)
end
end

---@param opts table?: Additional arguments. Currently only `silent` is supported.
---@return table
function utils.get_sessions()
function utils.get_sessions(opts)
local sessions = {}
for _, session_filename in ipairs(scandir.scan_dir(tostring(config.sessions_dir))) do
for _, session_filename in ipairs(scandir.scan_dir(tostring(config.sessions_dir), opts)) do
local dir = config.session_filename_to_dir(session_filename)
if dir:is_dir() then
table.insert(sessions, { timestamp = vim.fn.getftime(session_filename), filename = session_filename, dir = dir })
Expand All @@ -122,7 +123,7 @@ function utils.get_sessions()
end

-- If no sessions to list, send a notification.
if #sessions == 0 then
if not (opts and opts.silent) and #sessions == 0 then
vim.notify('The only available session is your current session. Nothing to select from.', vim.log.levels.INFO)
end

Expand Down

0 comments on commit a0b9d25

Please sign in to comment.