Closed gj86 closed 11 months ago
Thanks for reporting the issue @gj86!
I'm unable to reproduce the problem. I tried creating two sessions. Then from another Neovim instance, I loaded one session and then the other. There were no unexpected buffers nor issues when closing Neovim.
Do you have a minimal set of steps I can use to encounter the issue?
Thanks for reporting the issue @gj86! No problem.
Here is the minimum init script to reproduce the issue.
local root = vim.fn.fnamemodify('./.repro', ':p')
-- set stdpaths to use .repro
for _, name in ipairs({ 'config', 'data', 'state', 'cache' }) do
vim.env[('XDG_%s_HOME'):format(name:upper())] = root .. '/' .. name
end
-- bootstrap lazy
local lazypath = root .. '/plugins/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'--single-branch',
'https://github.com/folke/lazy.nvim.git',
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{
'jedrzejboczar/possession.nvim',
dependencies = { 'nvim-lua/plenary.nvim' },
opts = {
session_dir = vim.fn.expand(vim.fn.stdpath('data') .. '/possession'),
silent = true,
load_silent = true,
debug = false,
logfile = false,
prompt_no_cr = true,
autosave = {
current = false, -- or fun(name): boolean
tmp = false, -- or fun(): boolean
tmp_name = 'tmp', -- or fun(): string
on_load = true,
on_quit = true,
},
commands = {
save = 'PossessionSave',
load = 'PossessionLoad',
rename = 'PossessionRename',
close = 'PossessionClose',
delete = 'PossessionDelete',
show = 'PossessionShow',
list = 'PossessionList',
migrate = 'PossessionMigrate',
},
hooks = {
before_load = function(name, user_data)
-- delete unmodified buffers from loaded session/workspace.
vim.cmd('silent %bd')
return user_data
end,
},
plugins = {
-- disable all close/delete plugins. this deletes modified real buffers.
close_windows = false,
delete_hidden_buffers = false,
delete_buffers = false,
},
},
},
{
'dstein64/nvim-scrollview',
version = false,
config = function()
require('scrollview').setup({
excluded_filetypes = {},
current_only = false,
always_show = true,
winblend = 50,
base = 'right',
column = 1,
signs_column = 1,
hover = false,
signs_on_startup = {
'cursor',
'diagnostics',
'folds',
'loclist',
'marks',
'quickfix',
'search',
'spell',
},
diagnostics_severities = {
vim.diagnostic.severity.ERROR,
vim.diagnostic.severity.WARN,
vim.diagnostic.severity.INFO,
vim.diagnostic.severity.HINT,
},
})
end,
},
}
require('lazy').setup(plugins, {
root = root .. '/plugins',
})
-- add anything else here
vim.opt.termguicolors = true
Let me know if you need more information.
Edit: I copied and edited the template from folke/noice.nvim repo.
Thanks for supplying an init script that results in the problem. I can now reproduce the issue.
nvim-scrollview
creates a single buffer for all scrollbars and a single buffer for all signs. The motivation for this is so that the buffer list doesn't grow too large. For users who use :[N]buffer
, it would be inconvenient to have to type large numbers for [N]
.
I see that over the course of possession.nvim
's processing, the two aforementioned buffers for nvim-scrollview
entered an unloaded state (:help :bunload
). Changing the state of those buffers presumably relates to possession.nvim
's session restoring.
To work around the issue, nvim-scrollview
will now :bufload
its buffers that have been unloaded (41d8f6deee0c04c10188e7b313b4ec9058f1ff78, 5aba7e02337a7acf1816f6c8035254657bcdcfa8).
Thank you for fixing the issue so fast :)
Switching session without closing Neovim causes ScrollView to create ghost buffers. And when trying to close Neovim have to deal with "Do you want to save this buffer?"
I have tried disabling ScrollView (vim.cmd.ScrollViewDisable()) before closing Neovim, that didn't work.
This ghost buffers does not close with "%bd" because they are modified.
Note: I use possession.nvim to manage/switching session. Neovim details: NVIM v0.10.0-dev+658-g06694203e Build type: RelWithDebInfo LuaJIT 2.1.0-beta3