diff --git a/README.md b/README.md index d8052a7..41ee180 100644 --- a/README.md +++ b/README.md @@ -62,16 +62,17 @@ let g:auto_session_root_dir = path/to/my/custom/dir " or use Lua lua << EOF local opts = { - log_level = 'error', - auto_session_enable_last_session = false, - auto_session_root_dir = vim.fn.stdpath('data') .. "/sessions/", auto_session_enabled = true, - auto_save_enabled = nil, - auto_restore_enabled = nil, + auto_session_root_dir = vim.fn.stdpath('data') .. "/sessions/", + auto_save_enabled = true, + auto_restore_enabled = true, auto_session_suppress_dirs = nil, - auto_session_use_git_branch = nil, - -- the configs below are lua only - bypass_session_save_file_types = nil + auto_session_allowed_dirs = nil, + auto_session_create_enabled = true, + auto_session_enable_last_session = false, + auto_session_use_git_branch = false, + auto_restore_lazy_delay_enabled = true, + log_level = 'error', } require('auto-session').setup(opts) @@ -82,17 +83,17 @@ EOF | Config | Options | Default | Description | | -------------------------------- | ------------------------ | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -| log_level | 'debug', 'info', 'error' | 'error' | Sets the log level of the plugin. Set to info for more feedback on what's happening | -| auto_session_enable_last_session | false, true | false | On startup, loads the last loaded session if session for cwd does not exist | -| auto_session_root_dir | "/some/path/you/want" | vim.fn.stdpath('data').."/sessions/" | Changes the root dir for sessions | | auto_session_enabled | false, true | true | Enables/disables the plugin's auto save _and_ restore features | -| auto_session_create_enabled | false, true, function | true | Enables/disables the plugin's session auto creation. Can also be a Lua function that returns true if a session should be created and false otherwise | -| auto_save_enabled | false, true, nil | nil | Enables/disables auto saving | -| auto_restore_enabled | false, true, nil | nil | Enables/disables auto restoring | -| auto_restore_lazy_delay_enabled | false, true, nil | true | Enables/disables delaying auto-restore if Lazy.nvim is used | +| auto_session_root_dir | "/some/path/you/want" | vim.fn.stdpath('data').."/sessions/" | Changes the root dir for sessions | +| auto_save_enabled | false, true | true | Enables/disables auto saving | +| auto_restore_enabled | false, true | true | Enables/disables auto restoring | | auto_session_suppress_dirs | ["list", "of paths"] | nil | Suppress session create/restore if in one of the list of dirs | | auto_session_allowed_dirs | ["list", "of paths"] | nil | Allow session create/restore if in one of the list of dirs | -| auto_session_use_git_branch | false, true, nil | nil | Use the git branch to differentiate the session name | +| auto_session_create_enabled | false, true, function | true | Enables/disables the plugin's session auto creation. Can also be a Lua function that returns true if a session should be created and false otherwise | +| auto_session_enable_last_session | false, true | false | On startup, loads the last loaded session if session for cwd does not exist | +| auto_session_use_git_branch | false, true | false | Use the git branch to differentiate the session name | +| auto_restore_lazy_delay_enabled | false, true | true | Enables/disables delaying auto-restore if Lazy.nvim is used | +| log_level | 'debug', 'info', 'error' | 'error' | Sets the log level of the plugin. Set to info for more feedback on what's happening | #### Notes diff --git a/lua/auto-session/init.lua b/lua/auto-session/init.lua index e454f15..3670f32 100644 --- a/lua/auto-session/init.lua +++ b/lua/auto-session/init.lua @@ -42,32 +42,32 @@ end ---table default config for auto session ---@class defaultConf ----@field log_level? string|integer "debug", "info", "warn", "error" or vim.log.levels.DEBUG, vim.log.levels.INFO, vim.log.levels.WARN, vim.log.levels.ERROR ----@field auto_session_enable_last_session? boolean On startup, loads the last saved session if session for cwd does not exist +---@field auto_session_enabled? boolean Enables/disables auto saving and restoring ---@field auto_session_root_dir? string root directory for session files, by default is `vim.fn.stdpath('data') .. '/sessions/'` ----@field auto_session_enabled? boolean enable auto session ----@field auto_session_create_enabled boolean|function|nil Enables/disables auto creating new sessions. Can take a function that should return true/false if a session should be created or not ----@field auto_save_enabled? boolean Enables/disables auto saving session ----@field auto_restore_enabled? boolean Enables/disables auto restoring session ----@field auto_restore_lazy_delay_enabled? boolean Automatically detect if Lazy.nvim is being used and wait until Lazy is done to make sure session is restored correctly. Does nothing if Lazy isn't being used. Can be disabled if a problem is suspected or for debugging +---@field auto_save_enabled? boolean Enables/disables auto saving session on exit +---@field auto_restore_enabled? boolean Enables/disables auto restoring session on start ---@field auto_session_suppress_dirs? table Suppress auto session for directories ---@field auto_session_allowed_dirs? table Allow auto session for directories, if empty then all directories are allowed except for suppressed ones +---@field auto_session_create_enabled boolean|function Enables/disables auto creating new sessions. Can take a function that should return true/false if a session should be created or not +---@field auto_session_enable_last_session? boolean On startup, loads the last saved session if session for cwd does not exist ---@field auto_session_use_git_branch? boolean Include git branch name in session name to differentiate between sessions for different git branches +---@field auto_restore_lazy_delay_enabled? boolean Automatically detect if Lazy.nvim is being used and wait until Lazy is done to make sure session is restored correctly. Does nothing if Lazy isn't being used. Can be disabled if a problem is suspected or for debugging +---@field log_level? string|integer "debug", "info", "warn", "error" or vim.log.levels.DEBUG, vim.log.levels.INFO, vim.log.levels.WARN, vim.log.levels.ERROR ---Default config for auto session ---@type defaultConf local defaultConf = { - log_level = vim.g.auto_session_log_level or AutoSession.conf.log_level or AutoSession.conf.log_level or "error", -- Sets the log level of the plugin (debug, info, error). camelCase logLevel for compatibility. - auto_session_enable_last_session = vim.g.auto_session_enable_last_session or false, -- Enables/disables the "last session" feature - auto_session_root_dir = vim.fn.stdpath "data" .. "/sessions/", -- Root dir where sessions will be stored auto_session_enabled = true, -- Enables/disables auto creating, saving and restoring - auto_session_create_enabled = nil, -- Enables/disables auto creating new sessions. Can take a function that should return true/false if a session should be created or not + auto_session_root_dir = vim.fn.stdpath "data" .. "/sessions/", -- Root dir where sessions will be stored auto_save_enabled = true, -- Enables/disables auto save feature auto_restore_enabled = true, -- Enables/disables auto restore feature - auto_restore_lazy_delay_enabled = true, -- Enables/disables Lazy delay feature auto_session_suppress_dirs = nil, -- Suppress session restore/create in certain directories auto_session_allowed_dirs = nil, -- Allow session restore/create in certain directories + auto_session_create_enabled = true, -- Enables/disables auto creating new sessions. Can take a function that should return true/false if a session should be created or not + auto_session_enable_last_session = vim.g.auto_session_enable_last_session or false, -- Enables/disables the "last session" feature auto_session_use_git_branch = vim.g.auto_session_use_git_branch or false, -- Include git branch name in session name + auto_restore_lazy_delay_enabled = true, -- Enables/disables Lazy delay feature + log_level = vim.g.auto_session_log_level or AutoSession.conf.log_level or AutoSession.conf.log_level or "error", -- Sets the log level of the plugin (debug, info, error). camelCase logLevel for compatibility. } ---Lua Only Configs for Auto Session