mirror of
https://github.com/folke/persistence.nvim.git
synced 2025-08-30 06:29:41 +02:00
feat!: opts.need specifieds how many buffers should be open for saving. Replaces save_empty. Closes #19
This commit is contained in:
parent
f0ac0e981e
commit
7bb575517c
2 changed files with 5 additions and 5 deletions
|
@ -35,16 +35,14 @@ function M.start()
|
|||
group = vim.api.nvim_create_augroup("persistence", { clear = true }),
|
||||
callback = function()
|
||||
M.fire("SavePre")
|
||||
if not Config.options.save_empty then
|
||||
if Config.options.need > 0 then
|
||||
local bufs = vim.tbl_filter(function(b)
|
||||
if vim.bo[b].buftype ~= "" or vim.bo[b].filetype == "gitcommit" or vim.bo[b].filetype == "gitrebase" then
|
||||
return false
|
||||
end
|
||||
return vim.api.nvim_buf_get_name(b) ~= ""
|
||||
end, vim.api.nvim_list_bufs())
|
||||
if #bufs == 0 then
|
||||
return
|
||||
end
|
||||
return #bufs >= Config.options.need
|
||||
end
|
||||
|
||||
M.save()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue