romgrk / barbar.nvim

The neovim tabline plugin.
2.23k stars 83 forks source link

Fix session load #366

Closed otavioschwanck closed 1 year ago

otavioschwanck commented 1 year ago

Fixes: https://github.com/romgrk/barbar.nvim/issues/364

About the issue:

The SessionLoadPre is called multiple times for some reason. If i quickly load a session (when vim start), the first call will unset the pinned (because state.buffers is already set probably). With this, is prevented to call multiple times so quickly.

This PR Fixes LSP-Zero with session plugins that auto-load session on neovim start.

This is not the best solution but it's work!

cc @Iron-E

Iron-E commented 1 year ago

I can do a full review tomorrow, but try this in the meantime: the nvim_create_autocmd function has a once argument to prevent an autocmd from running multiple times. If you just add that will it work? E.g.

vim.api.nvim_create_autocmd('SessionLoadPost', {
  callback = function() … end,
  once = true, -- ← here
})
Iron-E commented 1 year ago

Glad you found the cause, by the way. And thanks for opening a pull!

otavioschwanck commented 1 year ago

I can do a full review tomorrow, but try this in the meantime: the nvim_create_autocmd function has a once argument to prevent an autocmd from running multiple times. If you just add that will it work? E.g.

vim.api.nvim_create_autocmd('SessionLoadPost', {
  callback = function() … end,
  once = true, -- ← here
})

if i put once, if someone reloads more than one session in one neovim instance, it will bug, right?

Glad you found the cause, by the way. And thanks for opening a pull!

You're welcome!

Iron-E commented 1 year ago

if i put once, if someone reloads more than one session in one neovim instance, it will bug, right?

Ah, yeah. You're right.

Iron-E commented 1 year ago

Thanks again!