Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(readme): make auto_create section clearer #384

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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