docs: update README.md

main
Oli Morris 2024-09-13 10:22:07 +01:00
parent a9d1d6e2ce
commit 46722016e0
2 changed files with 55 additions and 5 deletions

View File

@ -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:
@ -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:
@ -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

View File

@ -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
@ -456,7 +455,7 @@ detected. The code below amends for this:
}
<
**Ignore Branches**
**Ignore Certain Branches**
If youd like to ignore certain branches from being saved as a session:
@ -486,6 +485,32 @@ If youd 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: