Skip to content

Commit

Permalink
docs: update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
olimorris committed Sep 13, 2024
1 parent a9d1d6e commit 4672201
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 5 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ vim.api.nvim_create_autocmd("VimEnter", {
})
```

**Git Branching from directories that are not the CWD** by [mrloop](https://github.com/mrloop)
**Git Branching and Sub-directories** by [mrloop](https://github.com/mrloop)

As per [#149](https://github.com/olimorris/persisted.nvim/discussions/149), if you invoke Neovim from a sub-directory then the git branch will not be detected. The code below amends for this:

Expand All @@ -432,7 +432,7 @@ As per [#149](https://github.com/olimorris/persisted.nvim/discussions/149), if y
}
```

**Ignore Branches**
**Ignore Certain Branches**

If you'd like to ignore certain branches from being saved as a session:

Expand Down Expand Up @@ -462,6 +462,31 @@ If you'd like to ignore certain branches from being saved as a session:
}
```

**Only Save Certain Sessions**

You may wish to only save a session if the current working directory is in a table of allowed directories:

```lua
{
"olimorris/persisted.nvim",
lazy = false,
config = function()
local persisted = require("persisted")
local utils = require("persisted.utils")
local allowed_dirs = {
"~/code",
"~/notes/api"
}

persisted.setup({
should_save = function()
return utils.dirs_match(vim.fn.getcwd(), allowed_dirs)
end,
})
end,
}
```

<!-- panvimdoc-ignore-start -->

## :clap: Acknowledgements
Expand Down
31 changes: 28 additions & 3 deletions doc/persisted.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,7 @@ Autoloading a session if arguments are passed to Neovim:
})
<

**Git Branching from directories that are not the CWD** by mrloop
<https://github.com/mrloop>
**Git Branching and Sub-directories** by mrloop <https://github.com/mrloop>

As per #149 <https://github.com/olimorris/persisted.nvim/discussions/149>, if
you invoke Neovim from a sub-directory then the git branch will not be
Expand All @@ -456,7 +455,7 @@ detected. The code below amends for this:
}
<

**Ignore Branches**
**Ignore Certain Branches**

If you’d like to ignore certain branches from being saved as a session:

Expand Down Expand Up @@ -486,6 +485,32 @@ If you’d like to ignore certain branches from being saved as a session:
}
<

**Only Save Certain Sessions**

You may wish to only save a session if the current working directory is in a
table of allowed directories:

>lua
{
"olimorris/persisted.nvim",
lazy = false,
config = function()
local persisted = require("persisted")
local utils = require("persisted.utils")
local allowed_dirs = {
"~/code",
"~/notes/api"
}

persisted.setup({
should_save = function()
return utils.dirs_match(vim.fn.getcwd(), allowed_dirs)
end,
})
end,
}
<

Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>

vim:tw=78:ts=8:noet:ft=help:norl:

0 comments on commit 4672201

Please sign in to comment.