Add ability to determine if persistence.nvim is running
In my statusline, I like to know if persistence.nvim is active. I have a simple helper function: function using_session() return (vim.g.using_persistance ~= nil) end which I reference and display a corresponding glyphmain
parent
3d84264be5
commit
e70b5e2fc8
|
|
@ -46,6 +46,7 @@ function M.start()
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.stop()
|
function M.stop()
|
||||||
|
vim.g.using_persistance = nil
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
autocmd! Persistence
|
autocmd! Persistence
|
||||||
augroup! Persistence
|
augroup! Persistence
|
||||||
|
|
@ -57,12 +58,14 @@ function M.save()
|
||||||
vim.o.sessionoptions = table.concat(Config.options.options, ",")
|
vim.o.sessionoptions = table.concat(Config.options.options, ",")
|
||||||
vim.cmd("mks! " .. e(M.get_current()))
|
vim.cmd("mks! " .. e(M.get_current()))
|
||||||
vim.o.sessionoptions = tmp
|
vim.o.sessionoptions = tmp
|
||||||
|
vim.g.using_persistance = e(M.get_current())
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.load(opt)
|
function M.load(opt)
|
||||||
opt = opt or {}
|
opt = opt or {}
|
||||||
local sfile = opt.last and M.get_last() or M.get_current()
|
local sfile = opt.last and M.get_last() or M.get_current()
|
||||||
if sfile and vim.fn.filereadable(sfile) ~= 0 then
|
if sfile and vim.fn.filereadable(sfile) ~= 0 then
|
||||||
|
vim.g.using_persistance = e(sfile)
|
||||||
vim.cmd("source " .. e(sfile))
|
vim.cmd("source " .. e(sfile))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue