mirror of
https://github.com/folke/persistence.nvim.git
synced 2025-07-02 05:24:41 +02:00
feat: sessions per branch. Closes #9
This commit is contained in:
parent
9c0e5227fa
commit
cd0054e6a4
3 changed files with 17 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue