Skip to content

Commit 4672201

Browse files
committed
docs: update README.md
1 parent a9d1d6e commit 4672201

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ vim.api.nvim_create_autocmd("VimEnter", {
408408
})
409409
```
410410

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

413413
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:
414414

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

435-
**Ignore Branches**
435+
**Ignore Certain Branches**
436436

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

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

465+
**Only Save Certain Sessions**
466+
467+
You may wish to only save a session if the current working directory is in a table of allowed directories:
468+
469+
```lua
470+
{
471+
"olimorris/persisted.nvim",
472+
lazy = false,
473+
config = function()
474+
local persisted = require("persisted")
475+
local utils = require("persisted.utils")
476+
local allowed_dirs = {
477+
"~/code",
478+
"~/notes/api"
479+
}
480+
481+
persisted.setup({
482+
should_save = function()
483+
return utils.dirs_match(vim.fn.getcwd(), allowed_dirs)
484+
end,
485+
})
486+
end,
487+
}
488+
```
489+
465490
<!-- panvimdoc-ignore-start -->
466491

467492
## :clap: Acknowledgements

doc/persisted.nvim.txt

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,7 @@ Autoloading a session if arguments are passed to Neovim:
429429
})
430430
<
431431

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

435434
As per #149 <https://github.com/olimorris/persisted.nvim/discussions/149>, if
436435
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:
456455
}
457456
<
458457

459-
**Ignore Branches**
458+
**Ignore Certain Branches**
460459

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

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

488+
**Only Save Certain Sessions**
489+
490+
You may wish to only save a session if the current working directory is in a
491+
table of allowed directories:
492+
493+
>lua
494+
{
495+
"olimorris/persisted.nvim",
496+
lazy = false,
497+
config = function()
498+
local persisted = require("persisted")
499+
local utils = require("persisted.utils")
500+
local allowed_dirs = {
501+
"~/code",
502+
"~/notes/api"
503+
}
504+
505+
persisted.setup({
506+
should_save = function()
507+
return utils.dirs_match(vim.fn.getcwd(), allowed_dirs)
508+
end,
509+
})
510+
end,
511+
}
512+
<
513+
489514
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
490515

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

0 commit comments

Comments
 (0)