From e70b5e2fc87d56df13b45072aef2c4d7b11e1750 Mon Sep 17 00:00:00 2001 From: olimorris Date: Tue, 7 Sep 2021 19:38:33 +0100 Subject: [PATCH] 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 glyph --- lua/persistence/init.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/persistence/init.lua b/lua/persistence/init.lua index 6b1702a..4bfc985 100644 --- a/lua/persistence/init.lua +++ b/lua/persistence/init.lua @@ -46,6 +46,7 @@ function M.start() end function M.stop() + vim.g.using_persistance = nil vim.cmd([[ autocmd! Persistence augroup! Persistence @@ -57,12 +58,14 @@ function M.save() vim.o.sessionoptions = table.concat(Config.options.options, ",") vim.cmd("mks! " .. e(M.get_current())) vim.o.sessionoptions = tmp + vim.g.using_persistance = e(M.get_current()) end function M.load(opt) opt = opt or {} local sfile = opt.last and M.get_last() or M.get_current() if sfile and vim.fn.filereadable(sfile) ~= 0 then + vim.g.using_persistance = e(sfile) vim.cmd("source " .. e(sfile)) end end