Closed okuuva closed 1 year ago
Are you lazy loading the plugin? I use this for my config:
use({
"olimorris/persisted.nvim",
module = "persisted", -- For lazy loading
config = function()
require("persisted").setup()
require("telescope").load_extension("persisted") -- To load the telescope extension
end,
})
and my "Find Session" command calls require("persisted").load()
.
I take your point though that there could be times when an empty session is saved to disk. Defo a risk if you don't lazy load.
Hmm, how would lazyloading work with autoloading sessions? My use case is that I want to load alpha dashboard if session autoload fails, my reasoning being that manually loading an existing session for the current workdir is an unnecessary extra step.
It wouldn't; misread that first part of the issue 😄. Really good use case btw.
I think there's two components we'd need:
alpha
filetype, ensuring that a blank session is not saved to disk if you quit Neovim from the dashboardDo you agree?
That should do it, or at least I can't think of a reason why that wouldn't work.
I've marked this as an enhancement and will try and pick this up in a couple of weeks
Another option is to use the return value of a callback (e.g. true
or false
) to determine whether a session should be auto-saved — that way, any condition can be implemented. We could either use the existing before_save
or introduce a new callback like should_save
or should_autosave
, or perhaps even allow the user to pass a callback to the existing autosave
as an alternative to a boolean. It shouldn't affect manual SessionSave
s, of course.
@loqusion - really good suggestion! Much cleaner and will cover anyone's edge case. I've added this in the latest commit
That's really nice, works like a charm and makes it easy to update if there's more conditions in the future! Takkâ ennuv!
My use case is the following:
I want to autoload a session for the cwd at start if it exits. If not I want to open alpha dashboard. I have setup
alpha
not to start automatically and have the following function ason_autoload_no_session
function:The first run everything goes fine,
alpha
dashboard starts up: (just noticed the typo in "Find sesssion" :))Then I hit
<leader>q
which is bound to:qa!
in the dashboard settings.The next time I open nvim in the same cwd,
persisted
loads practically an empty session:Here's the actual session.vim file saved:
What should've happened (imo) is that the
alpha
dashboard would've opened instead of this "session".My question is: is there a way to prevent
persisted
from saving such an "empty" session?