bufferline.nvim
bufferline.nvim copied to clipboard
[Bug]: a unpinned buffer was pinned after session restore
Is there an existing issue for this?
- [x] I have searched the existing issues
What happened?
Reproduce:
- pin a buffer A, and I execute
:lua print(vim.g["BufferlinePinnedBuffers]), the output is the filepath of buffer A - unpin the buffer A, and I re-execute the print cmd above, the output is an empty string
- mksession and exit neovim
- open neovim and restore the session, the buffer A is pinned, and I also execute the print cmd above, the output is the filepath of buffer A
I try to solve this problem, it seems like caused by the neovim's session mechanism, we have to do unlet g:BufferlinePinnedBuffers before mksession if #vim.g["BufferlinePinnedBuffers"] == 0
I write a autocmd just like this, the problem seems to be solved:
vim.api.nvim_create_autocmd("User", {
group = vim.api.nvim_create_augroup("CelesteFixBufferlineForPinnedBuffer", { clear = true }),
pattern = "UserDefinedBeforeSessionSave",
callback = function()
if vim.fn.exists("g:BufferlinePinnedBuffers") then
if #vim.g["BufferlinePinnedBuffers"] == 0 then
vim.cmd("unlet g:BufferlinePinnedBuffers")
end
end
end,
})
What did you expect to happen?
- pin a buffer A, and I execute
:lua print(vim.g["BufferlinePinnedBuffers]), the output is the filepath of buffer A - unpin the buffer A, and I re-execute the print cmd above, the output is an empty string
- mksession and exit neovim
- open neovim and restore the session, the buffer A wasn't pinned
Config
opts = {
options = {
mode = "buffers",
numbers = function(opts)
return string.format("%s.%s", opts.id, opts.raise(opts.ordinal))
end,
buffer_close_icon = "",
modified_icon = "●",
close_icon = "",
left_trunc_marker = " ",
right_trunc_marker = " ",
offsets = {
{
filetype = "NvimTree",
text = "File Explorer",
text_align = "center",
highlight = "Directory",
separator = true,
},
},
color_icons = true,
get_element_icon = function(element)
return require("nvim-web-devicons").get_icon_by_filetype(element.filetype, { default = false })
end,
show_buffer_icons = true,
show_buffer_close_icons = true,
show_close_icon = true,
show_tab_indicators = true,
max_name_length = 18,
max_prefix_length = 15,
truncate_names = true,
diagnostics = "nvim_lsp",
diagnostics_update_on_event = true,
pick = {
alphabet = "abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMOPQRSTUVWXYZ1234567890",
},
}, -- options
},
Additional Information
No response
commit
No response