Skip to content

Commit

Permalink
Merge pull request #312 from cameronr/main
Browse files Browse the repository at this point in the history
[chore] Minor documentation cleanup
  • Loading branch information
rmagatti authored Jul 2, 2024
2 parents 879f5b3 + 9e49287 commit 7b1b30d
Showing 1 changed file with 44 additions and 25 deletions.
69 changes: 44 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ Auto Session takes advantage of Neovim's existing session management capabilitie
:warning: Please note that if there are errors in your config, restoring the session might fail, if that happens, auto session will then disable auto saving for the current session.
Manually saving a session can still be done by calling `:SessionSave`.

AutoSession now tracks `cwd` changes!
By default, handling is as follows:
AutoSession can now track `cwd` changes!
By default, `cwd` handling is disabled but when enabled, it works as follows:
DirChangedPre (before the cwd actually changes):
- Save the current session
- Clear all buffers `%bd!`. This guarantees buffers don't bleed to the
next session.
- Clear jumps. Also done so there is no bleeding between sessions.
- Run the `pre_cwd_changed_hook`
- Run the `pre_cwd_changed_hook`/
DirChanged (after the cwd has changed):
- Restore session using new cwd
- Run the `post_cwd_changed_hook`
Expand All @@ -35,7 +35,7 @@ require("auto-session").setup {
log_level = "error",

cwd_change_handling = {
restore_upcoming_session = true, -- already the default, no need to specify like this, only here as an example
restore_upcoming_session = true, -- Disabled by default, set to true to enable
pre_cwd_changed_hook = nil, -- already the default, no need to specify like this, only here as an example
post_cwd_changed_hook = function() -- example refreshing the lualine status line _after_ the cwd changes
require("lualine").refresh() -- refresh lualine so the new session name is displayed in the status bar
Expand All @@ -47,14 +47,32 @@ require("auto-session").setup {

# 📦 Installation

Any plugin manager should do, I use [Packer.nvim](https://github.com/wbthomason/packer.nvim)
[Lazy.nvim](https://github.com/folke/lazy.nvim):

```lua
return {
{
'rmagatti/auto-session',
dependencies = {
'nvim-telescope/telescope.nvim', -- Only needed if you want to use sesssion lens
},
config = function()
require('auto-session').setup({
auto_session_suppress_dirs = { '~/', '~/Projects', '~/Downloads', '/' },
},
})
end,
},
}
```

[Packer.nvim](https://github.com/wbthomason/packer.nvim):

```lua
use {
'rmagatti/auto-session',
config = function()
require("auto-session").setup {
log_level = "error",
auto_session_suppress_dirs = { "~/", "~/Projects", "~/Downloads", "/"},
}
end
Expand Down Expand Up @@ -93,23 +111,6 @@ require('auto-session').setup(opts)
EOF
```

### Statusline

One can show the current session name in the statusline by using an auto-session helper function.

Lualine example config and how it looks

```lua
require('lualine').setup{
options = {
theme = 'tokyonight',
},
sections = {lualine_c = {require('auto-session.lib').current_session_name}}
}
```

<img width="1904" alt="Screen Shot 2021-10-30 at 3 58 57 PM" src="https://user-images.githubusercontent.com/2881382/139559478-8edefdb8-8254-42e7-a0f3-babd3dfd6ff2.png">

### Options

| Config | Options | Default | Description |
Expand Down Expand Up @@ -137,7 +138,7 @@ require("auto-session").setup {
bypass_session_save_file_types = nil, -- table: Bypass auto save when only buffer open is one of these file types
close_unsupported_windows = true, -- boolean: Close windows that aren't backed by normal file
cwd_change_handling = { -- table: Config for handling the DirChangePre and DirChanged autocmds, can be set to nil to disable altogether
restore_upcoming_session = true, -- boolean: restore session for upcoming cwd on cwd change
restore_upcoming_session = false, -- boolean: restore session for upcoming cwd on cwd change
pre_cwd_changed_hook = nil, -- function: This is called after auto_session code runs for the `DirChangedPre` autocmd
post_cwd_changed_hook = nil, -- function: This is called after auto_session code runs for the `DirChanged` autocmd
},
Expand Down Expand Up @@ -205,6 +206,7 @@ Auto Session exposes two commands that can be used or mapped to any keybindings
```

You can use the `Autosession {delete|search}` command to open a picker using `vim.ui.select` this will allow you to either delete or search for a session to restore.
There's also Telescope support, see the [Session Lens](#-session-lens) section below.

## 🪝 Command Hooks

Expand Down Expand Up @@ -284,7 +286,7 @@ For troubleshooting refer to the [wiki page](https://github.com/rmagatti/auto-se

## 🔭 Session Lens

Session Lens has been merged into Auto Session! This means all the functionality of Session Lens is now available in Auto Session. It's enabled by
Session Lens has been merged into Auto Session so now you can see, load, and delete your sessions using Telescope! It's enabled by
default if you have Telescope, but here's the Lazy config that shows the configuration options:

```lua
Expand Down Expand Up @@ -335,6 +337,23 @@ Auto Session provides its own `:Autosession search` and `:Autosession delete` co

<img src="https://github.com/rmagatti/readme-assets/blob/main/session-lens.gif" width=800 />

### Statusline

One can show the current session name in the statusline by using an auto-session helper function.

Lualine example config and how it looks

```lua
require('lualine').setup{
options = {
theme = 'tokyonight',
},
sections = {lualine_c = {require('auto-session.lib').current_session_name}}
}
```

<img width="1904" alt="Screen Shot 2021-10-30 at 3 58 57 PM" src="https://user-images.githubusercontent.com/2881382/139559478-8edefdb8-8254-42e7-a0f3-babd3dfd6ff2.png">

# Compatibility

Neovim > 0.7
Expand Down

0 comments on commit 7b1b30d

Please sign in to comment.