I'm really enjoying the simplicity of persistence, but coming from Obsession, there's a few things I was wanting, and I think this patch addresses them all.
I use nvim for all sorts of sysadmin stuff, I don't need session files getting littered around unless I'm actually in a project that warrants it -- I want control over when to start and stop the management
I'd like to have a way to ask the plugin if it's currently active or not (a cleaner way might be to just check for the existence of the 'persistence' augroup, but I didn't find any methods to do that.)
Similarly, I'd like to ask the plugin if a session file is present for some basic boolean stuff.
With this patch, I can integrate things with lualine,
local function sessionRunning()
if require( 'persistence' ).running then
return ''
else
return ''
end
end
... dashboard,
shortcut = {
{
desc = '↪️ Restore Session ',
action = function()
persistence = require( 'persistence' )
if persistence.has_session() then
persistence.load()
else
print "No session for this directory."
end
end,
key = 's',
},
and have a global "on/off" switch for only starting up a session when I want:
require( 'persistence' ).setup({
auto_start = false
})
-- Toggle session tracking for current directory.
--
vim.keymap.set( '', '<F8>', function()
local persistence = require( 'persistence' )
if persistence.running then
persistence.stop()
print "Disabled session tracking."
else
persistence.start()
print "Enabled session tracking."
end
end, { desc = "Toggle session tracking" })
This also indirectly fixes stuff like #14 as a possible alternative option.
Default behavior is exactly as-is, this shouldn't change anything for existing installations.
I'm really enjoying the simplicity of persistence, but coming from Obsession, there's a few things I was wanting, and I think this patch addresses them all.
With this patch, I can integrate things with lualine,
... dashboard,
and have a global "on/off" switch for only starting up a session when I want:
This also indirectly fixes stuff like #14 as a possible alternative option.
Default behavior is exactly as-is, this shouldn't change anything for existing installations.