feat: sessions per branch. Closes #9
This commit is contained in:
@ -6,6 +6,7 @@ local defaults = {
|
||||
-- minimum number of file buffers that need to be open to save
|
||||
-- Set to 0 to always save
|
||||
need = 1,
|
||||
branch = true, -- use git branch to save session
|
||||
}
|
||||
|
||||
---@type Persistence.Config
|
||||
|
@ -10,6 +10,12 @@ local e = vim.fn.fnameescape
|
||||
|
||||
function M.current()
|
||||
local name = vim.fn.getcwd():gsub("[\\/:]", "%%")
|
||||
if Config.options.branch then
|
||||
local branch = M.branch()
|
||||
if branch and branch ~= "main" and branch ~= "master" then
|
||||
name = name .. "-" .. branch
|
||||
end
|
||||
end
|
||||
return Config.options.dir .. name .. ".vim"
|
||||
end
|
||||
|
||||
@ -111,4 +117,10 @@ function M.select()
|
||||
end)
|
||||
end
|
||||
|
||||
--- get current branch name
|
||||
---@return string?
|
||||
function M.branch()
|
||||
return vim.fn.systemlist("git branch --show-current")[1]
|
||||
end
|
||||
|
||||
return M
|
||||
|
Reference in New Issue
Block a user