You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| log_level | 'debug', 'info', 'error' | 'info' | Sets the log level of the plugin |
120
+
| auto_session_enable_last_session | false, true | false | Loads the last loaded session if session for cwd does not exist |
121
+
| auto_session_root_dir | "/some/path/you/want" | vim.fn.stdpath('data').."/sessions/" | Changes the root dir for sessions |
122
+
| auto_session_enabled | false, true | true | Enables/disables the plugin's auto save _and_ restore features |
123
+
| 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_create_enabled` can take a function that returns if a session should be created or not as part of auto saving. As one example, you could
272
+
use this to only create sessions for git projects:
273
+
274
+
```lua
275
+
276
+
config=function()
277
+
require('auto-session').setup({
278
+
auto_save_enabled=true,
279
+
auto_restore_enabled=true,
280
+
281
+
auto_session_create_enabled=function()
282
+
localcmd='git rev-parse --is-inside-work-tree'
283
+
returnvim.fn.system(cmd) =='true\n'
284
+
end,
285
+
})
286
+
end
287
+
288
+
```
289
+
269
290
## Argument Handling
270
291
271
292
By default, when `nvim` is run with a single directory argument, auto-session will try to restore the session for that directory. If `nvim` is run with multiple directories or any file arguments, auto-session won't try to restore a session and won't auto-save a session on exit (if enabled). Those behaviors can be changed with these config parameters:
---@fieldauto_session_root_dir? string root directory for session files, by default is `vim.fn.stdpath('data')/sessions/`
40
40
---@fieldauto_session_enabled? boolean enable auto session
41
-
---@fieldauto_session_create_enabledboolean|nil Enables/disables auto creating new sessions
41
+
---@fieldauto_session_create_enabledboolean|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
42
42
---@fieldauto_save_enabled? boolean Enables/disables auto saving session
43
43
---@fieldauto_restore_enabled? boolean Enables/disables auto restoring session
44
44
---@fieldauto_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
@@ -53,7 +53,7 @@ local defaultConf = {
53
53
auto_session_enable_last_session=vim.g.auto_session_enable_last_sessionorfalse, -- Enables/disables the "last session" feature
54
54
auto_session_root_dir=vim.fn.stdpath"data" .."/sessions/", -- Root dir where sessions will be stored
55
55
auto_session_enabled=true, -- Enables/disables auto creating, saving and restoring
56
-
auto_session_create_enabled=nil, -- Enables/disables auto creating new sessions
56
+
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
57
57
auto_save_enabled=nil, -- Enables/disables auto save feature
58
58
auto_restore_enabled=nil, -- Enables/disables auto restore feature
0 commit comments