chore: rename to persisted
parent
340136dca1
commit
9fd0958a19
|
|
@ -1,13 +1,13 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
---@class PersistenceOptions
|
---@class PersistedOptions
|
||||||
local defaults = {
|
local defaults = {
|
||||||
dir = vim.fn.expand(vim.fn.stdpath("config") .. "/sessions/"), -- directory where session files are saved
|
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
|
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
|
options = { "buffers", "curdir", "tabpages", "winsize" }, -- sessionoptions used for saving
|
||||||
}
|
}
|
||||||
|
|
||||||
---@type PersistenceOptions
|
---@type PersistedOptions
|
||||||
M.options = {}
|
M.options = {}
|
||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local Config = require("persistence.config")
|
local Config = require("persisted.config")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ function M.get_branch()
|
||||||
if Config.options.use_git_branch and git_enabled then
|
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)
|
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 = {}
|
local lines = {}
|
||||||
for s in branch:gmatch("[^\r\n]+") do
|
for s in branch:gmatch("[^\r\n]+") do
|
||||||
table.insert(lines, '_' .. s)
|
table.insert(lines, '_' .. s)
|
||||||
|
|
@ -45,20 +45,20 @@ end
|
||||||
|
|
||||||
function M.start()
|
function M.start()
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
augroup Persistence
|
augroup Persisted
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd VimLeavePre * lua require("persistence").save()
|
autocmd VimLeavePre * lua require("persisted").save()
|
||||||
augroup end
|
augroup end
|
||||||
]])
|
]])
|
||||||
vim.g.using_persistence = true
|
vim.g.using_persisted = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.stop()
|
function M.stop()
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
autocmd! Persistence
|
autocmd! Persisted
|
||||||
augroup! Persistence
|
augroup! Persisted
|
||||||
]])
|
]])
|
||||||
vim.g.using_persistence = false
|
vim.g.using_persisted = false
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.save()
|
function M.save()
|
||||||
|
|
@ -66,7 +66,7 @@ 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_persistence = true
|
vim.g.using_persisted = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.load(opt)
|
function M.load(opt)
|
||||||
|
|
@ -74,7 +74,7 @@ function M.load(opt)
|
||||||
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.cmd("source " .. e(sfile))
|
vim.cmd("source " .. e(sfile))
|
||||||
vim.g.using_persistence = true
|
vim.g.using_persisted = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Loading…
Reference in New Issue