Skip to content

Commit

Permalink
Merge pull request rmagatti#384 from cameronr/main
Browse files Browse the repository at this point in the history
docs(readme): make auto_create section clearer
  • Loading branch information
cameronr authored Oct 5, 2024
2 parents 21e3385 + 6551fc0 commit 9d02776
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ Both options are a table of directories, with support for globs:

With those options, sessions would only be auto-saved for `/some/dir` and any direct child of `/projects` (e.g. `/projects/myproject` but not `/projects/myproject/submodule`) except `/projects/secret`

If you want even more fine-grained control, you can instead set `auto_create` to a function to [conditionally create a session](#conditionally-creating-a-session).

## 🚶 Current Working Directory

AutoSession can track `cwd` changes!
Expand Down Expand Up @@ -380,7 +382,9 @@ Now last session will be restored only when Neovim is launched in the home direc

## Conditionally creating a session

`auto_create` doesn't just have to be a boolean, it can also take a function that returns if a session should be created or not as part of auto saving. As one example, you could use this to only create new session files for git projects:
With `auto_create = false`, AutoSession won't create a session automatically. If you manually save a session via `:SessionSave`, though, it will automatically update it whenever you exit `nvim`. You can use that to manually control where sessions are created.

`auto_create` doesn't just have to be a boolean, it can also take a function that returns if a session should be created or not as part of auto saving. As one example, you could use this to only automatically create new session files inside of git projects:

```lua

Expand All @@ -393,6 +397,8 @@ require('auto-session').setup({

```

With the above, AutoSession will allow automatically creating a session inside of a git project but won't automatically create a session in any other directory. If you manually save a session in a directory, though, it will then update that session automatically whenever you exit `nvim`.

## 🗃️ Argument Handling

By default, when `nvim` is run with a single directory argument, AutoSession will try to restore the session for that directory. If `nvim` is run with multiple directories or any file arguments, AutoSession 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:
Expand Down

0 comments on commit 9d02776

Please sign in to comment.