---@type LazySpec
return {
	"rmagatti/auto-session",
	lazy = false,
	priority = 100,
	---@module "auto-session"
	---@type AutoSession.Config
	opts = {
		enabled = true,
		auto_save = true,
		auto_create = true,
		auto_restore = true,
		auto_restore_last_session = false,
		cwd_change_handling = true,
		single_session_mode = false,
		close_unsupported_windows = true,
		suppressed_dirs = { '~/', '~/software/', '~/downloads/', '~/desktop/', '/etc/' },
		close_filetypes_on_save = { 'checkhealth', 'man', 'oil' },
		bypass_save_filetypes = { 'netrw', 'oil' },

		auto_delete_empty_sessions = true,
		purge_after_minutes = 14 * 24 * 60,

		lazy_support = true,
		legacy_cmds = false,
		args_allow_single_directory = true,
		args_allow_files_auto_save = false,

		-- log_level = 'debug',
		show_auto_restore_notif = true,
	},
	init = function()
		local path = vim.fn.argv(0)
		if not path or type(path) ~= 'string' then return end

		local realpath = vim.uv.fs_realpath(path)
		if not realpath then return end

		if vim.fn.isdirectory(realpath) ~= 1 then return end
		vim.fn.chdir(realpath)

		vim.notify("loaded directory: '" .. realpath .. "'", vim.log.levels.INFO)
	end,
}
