You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
-
82
79
**Telescope extension**
83
80
84
-
Ensure that the telescope extension is loaded with:
81
+
Ensure that the Telescope extension is loaded with:
85
82
86
83
```lua
87
84
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
199
196
The location of the session files may be changed by altering the `save_dir` configuration option. For example:
200
197
201
198
```lua
202
-
require("persisted").setup({
199
+
{
203
200
save_dir=vim.fn.expand(vim.fn.stdpath("data") .."/sessions/"), -- Resolves to ~/.local/share/nvim/sessions/
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:
213
210
214
211
```lua
215
-
require("persisted").setup({
212
+
{
216
213
use_git_branch=true,
217
-
})
214
+
}
218
215
```
219
216
220
217
**Autostart**
221
218
222
219
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:
223
220
224
221
```lua
225
-
require("persisted").setup({
222
+
{
226
223
autostart=false,
227
-
})
224
+
}
228
225
```
229
226
230
227
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
234
231
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.
235
232
236
233
```lua
237
-
require("persisted").setup({
234
+
{
238
235
---@returnbool
239
236
should_save=function()
240
237
-- Do not save if the alpha dashboard is the current filetype
@@ -243,7 +240,7 @@ require("persisted").setup({
243
240
end
244
241
returntrue
245
242
end,
246
-
})
243
+
}
247
244
```
248
245
249
246
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
253
250
The plugin can be enabled to automatically load sessions when Neovim is started. Whilst off by default, this can be turned on by:
254
251
255
252
```lua
256
-
require("persisted").setup({
253
+
{
257
254
autoload=true,
258
-
})
255
+
}
259
256
```
260
257
261
258
You can also provide a function to run when `autoload = true` and there is no session to load:
262
259
263
260
```lua
264
-
require("persisted").setup({
261
+
{
265
262
autoload=true,
266
263
on_autoload_no_session=function()
267
264
vim.notify("No existing session to load.")
268
265
end
269
-
})
266
+
}
270
267
```
271
268
272
269
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
279
276
You may specify a table of directories for which the plugin will start and/or autoload from. For example:
280
277
281
278
```lua
282
-
require("persisted").setup({
279
+
{
283
280
allowed_dirs= {
284
281
"~/.dotfiles",
285
282
"~/Code",
286
283
},
287
-
})
284
+
}
288
285
```
289
286
290
287
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
297
294
You may specify a table of directories for which the plugin will **never** start and autoload from. For example:
298
295
299
296
```lua
300
-
require("persisted").setup({
297
+
{
301
298
ignored_dirs= {
302
299
"~/.config",
303
300
"~/.local/nvim"
304
301
},
305
-
})
302
+
}
306
303
```
307
304
308
305
Specifying `~/.config` will prevent any autosaving and autoloading from that directory as well as all its sub-directories.
309
306
310
307
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:
311
308
312
309
```lua
313
-
require("persisted").setup({
310
+
{
314
311
ignored_dirs= {
315
312
"~/.config",
316
313
"~/.local/nvim",
317
314
{ "/", exact=true },
318
315
{ "/tmp", exact=true }
319
316
},
320
-
})
317
+
}
321
318
```
322
319
323
320
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