chore: rename to persisted
parent
340136dca1
commit
9fd0958a19
|
|
@ -1,13 +1,13 @@
|
|||
local M = {}
|
||||
|
||||
---@class PersistenceOptions
|
||||
---@class PersistedOptions
|
||||
local defaults = {
|
||||
dir = vim.fn.expand(vim.fn.stdpath("config") .. "/sessions/"), -- directory where session files are saved
|
||||
use_git_branch = false, -- create session files based on the branch of the git enabled repository
|
||||
options = { "buffers", "curdir", "tabpages", "winsize" }, -- sessionoptions used for saving
|
||||
}
|
||||
|
||||
---@type PersistenceOptions
|
||||
---@type PersistedOptions
|
||||
M.options = {}
|
||||
|
||||
function M.setup(opts)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
local Config = require("persistence.config")
|
||||
local Config = require("persisted.config")
|
||||
|
||||
local M = {}
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ function M.get_branch()
|
|||
if Config.options.use_git_branch and git_enabled then
|
||||
local branch = vim.api.nvim_exec([[!git rev-parse --abbrev-ref HEAD 2>/dev/null]], true)
|
||||
|
||||
-- The branch command returns two lines. We only need the second line
|
||||
-- The branch command returns two lines. We only need the second one
|
||||
local lines = {}
|
||||
for s in branch:gmatch("[^\r\n]+") do
|
||||
table.insert(lines, '_' .. s)
|
||||
|
|
@ -45,20 +45,20 @@ end
|
|||
|
||||
function M.start()
|
||||
vim.cmd([[
|
||||
augroup Persistence
|
||||
augroup Persisted
|
||||
autocmd!
|
||||
autocmd VimLeavePre * lua require("persistence").save()
|
||||
autocmd VimLeavePre * lua require("persisted").save()
|
||||
augroup end
|
||||
]])
|
||||
vim.g.using_persistence = true
|
||||
vim.g.using_persisted = true
|
||||
end
|
||||
|
||||
function M.stop()
|
||||
vim.cmd([[
|
||||
autocmd! Persistence
|
||||
augroup! Persistence
|
||||
autocmd! Persisted
|
||||
augroup! Persisted
|
||||
]])
|
||||
vim.g.using_persistence = false
|
||||
vim.g.using_persisted = false
|
||||
end
|
||||
|
||||
function M.save()
|
||||
|
|
@ -66,7 +66,7 @@ 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_persistence = true
|
||||
vim.g.using_persisted = true
|
||||
end
|
||||
|
||||
function M.load(opt)
|
||||
|
|
@ -74,7 +74,7 @@ function M.load(opt)
|
|||
local sfile = opt.last and M.get_last() or M.get_current()
|
||||
if sfile and vim.fn.filereadable(sfile) ~= 0 then
|
||||
vim.cmd("source " .. e(sfile))
|
||||
vim.g.using_persistence = true
|
||||
vim.g.using_persisted = true
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue