Skip to content

Commit b4b7a28

Browse files
committed
docs: update README.md
1 parent da8d3f8 commit b4b7a28

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

README.md

+23-26
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,13 @@ Install and configure the plugin with your preferred package manager:
4242
-- Lua
4343
{
4444
"olimorris/persisted.nvim",
45-
lazy = false, -- make sure the plugin is always loaded at startup
46-
config = true
45+
event = "BufReadPre", -- Ensure the plugin loads only when a buffer has been loaded
46+
opts = {
47+
-- Your config goes here ...
48+
},
4749
}
4850
```
4951

50-
> [!NOTE]
51-
> Setting `lazy = true` option may be useful if you use a dashboard
52-
5352
**[Packer](https://github.com/wbthomason/packer.nvim)**
5453

5554
```lua
@@ -77,11 +76,9 @@ lua << EOF
7776
EOF
7877
```
7978

80-
If you wish to use session _autoloading_ alongside a dashboard plugin, it is recommended that you give this plugin a greater loading priority. With **Packer** the `after` config option can be used and in **Lazy.nvim**, the `priority` property.
81-
8279
**Telescope extension**
8380

84-
Ensure that the telescope extension is loaded with:
81+
Ensure that the Telescope extension is loaded with:
8582

8683
```lua
8784
require("telescope").load_extension("persisted")
@@ -199,9 +196,9 @@ As the plugin uses Vim's `:mksession` command then you may change the `vim.o.ses
199196
The location of the session files may be changed by altering the `save_dir` configuration option. For example:
200197

201198
```lua
202-
require("persisted").setup({
199+
{
203200
save_dir = vim.fn.expand(vim.fn.stdpath("data") .. "/sessions/"), -- Resolves to ~/.local/share/nvim/sessions/
204-
})
201+
}
205202
```
206203

207204
> [!NOTE]
@@ -212,19 +209,19 @@ require("persisted").setup({
212209
One of the plugin's core features is the ability to have multiple session files for a given project, by using git branches. To enable git branching:
213210

214211
```lua
215-
require("persisted").setup({
212+
{
216213
use_git_branch = true,
217-
})
214+
}
218215
```
219216

220217
**Autostart**
221218

222219
By default, the plugin will automatically start when the setup function is called. This results in a Neovim session being saved to disk when the `VimLeavePre` event is triggered. This can be disabled by:
223220

224221
```lua
225-
require("persisted").setup({
222+
{
226223
autostart = false,
227-
})
224+
}
228225
```
229226

230227
Autostarting can be further controlled for certain directories by specifying `allowed_dirs` and `ignored_dirs`.
@@ -234,7 +231,7 @@ Autostarting can be further controlled for certain directories by specifying `al
234231
There may be occasions when you do not wish to save the session; perhaps when a dashboard or a certain filetype is present. To handle this, the `should_save` function may be used which should return a boolean value.
235232

236233
```lua
237-
require("persisted").setup({
234+
{
238235
---@return bool
239236
should_save = function()
240237
-- Do not save if the alpha dashboard is the current filetype
@@ -243,7 +240,7 @@ require("persisted").setup({
243240
end
244241
return true
245242
end,
246-
})
243+
}
247244
```
248245

249246
Of course, if you wish to manually save the session the `:SessionSave` command can be used.
@@ -253,20 +250,20 @@ Of course, if you wish to manually save the session the `:SessionSave` command c
253250
The plugin can be enabled to automatically load sessions when Neovim is started. Whilst off by default, this can be turned on by:
254251

255252
```lua
256-
require("persisted").setup({
253+
{
257254
autoload = true,
258-
})
255+
}
259256
```
260257

261258
You can also provide a function to run when `autoload = true` and there is no session to load:
262259

263260
```lua
264-
require("persisted").setup({
261+
{
265262
autoload = true,
266263
on_autoload_no_session = function()
267264
vim.notify("No existing session to load.")
268265
end
269-
})
266+
}
270267
```
271268

272269
Autoloading can be further controlled for directories in the `allowed_dirs` and `ignored_dirs` config tables.
@@ -279,12 +276,12 @@ Autoloading can be further controlled for directories in the `allowed_dirs` and
279276
You may specify a table of directories for which the plugin will start and/or autoload from. For example:
280277

281278
```lua
282-
require("persisted").setup({
279+
{
283280
allowed_dirs = {
284281
"~/.dotfiles",
285282
"~/Code",
286283
},
287-
})
284+
}
288285
```
289286

290287
Specifying `~/Code` will start and autoload from that directory as well as all its sub-directories.
@@ -297,27 +294,27 @@ Specifying `~/Code` will start and autoload from that directory as well as all i
297294
You may specify a table of directories for which the plugin will **never** start and autoload from. For example:
298295

299296
```lua
300-
require("persisted").setup({
297+
{
301298
ignored_dirs = {
302299
"~/.config",
303300
"~/.local/nvim"
304301
},
305-
})
302+
}
306303
```
307304

308305
Specifying `~/.config` will prevent any autosaving and autoloading from that directory as well as all its sub-directories.
309306

310307
You can also specify exact directory matches to ignore. In this case, unlike the default behavior which ignores all children of the ignored directory, this will ignore only the specified child. For example:
311308

312309
```lua
313-
require("persisted").setup({
310+
{
314311
ignored_dirs = {
315312
"~/.config",
316313
"~/.local/nvim",
317314
{ "/", exact = true },
318315
{ "/tmp", exact = true }
319316
},
320-
})
317+
}
321318
```
322319

323320
In this setup, `~/.config` and `~/.local/nvim` are still going to behave in their default setting (ignoring all listed directory and its children), however `/` and `/tmp` will only ignore those directories exactly.

0 commit comments

Comments
 (0)