focus_on_delete = 'prev' | 'next' closes NvimTree (and NvimTree can't be toggled correctly after that)
if
focus_on_delete = 'prev' | 'next'
is set and you close the current buffer (file) via left-clicking at the bufferline 'x' symbol,
NvimTree disappears and will only reappear when executing :NvimTreeToggle twice!
It would be nice if this behave differently. It would be best if NvimTree did not close in the first place 😎
Great plugin btw, i really enjoy using it! 👍
I ran into the same issue with CHADtree, so I'll share my observations, as I don't have time to look for a solution right now. (I'm disabling focus_on_delete for now)
It seems to happen when it tries to rename itself (after it has been opened without a "path" argument and figured it out itself). According to the vim documentation, this triggers BufDelete, which is preceded by BufUnload.
BufDelete Before deleting a buffer from the buffer list.
The BufUnload may be called first (if the
buffer was loaded).
Also used just before a buffer in the buffer
list is renamed.
This means, that this triggers the autocommand for focus_on_delete as set in augroups.lua:60
autocmd BufUnload *
\ exe printf(
\ 'lua require("cokeline/augroups").focus_on_delete(%s)', expand('<abuf>')
\ )
But the buffer is still active, so deleting it will throw the following error
pynvim.api.common.NvimError: Vim(lua):E5108: Error executing lua ...ack/packer/start/nvim-cokeline/lua/cokeline/augroups.lua:39: Vim(buffer):E937: Attempt to delete a buffer that is
in use
Or maybe in the case of NvimTree just closes the buffer. This might have something to do with how async CHADtree is set out to be. I would guess that this is the same issue as #43 but for Neogit it was possible to check for the filename. Other plugins might set different names.
I don't have a good solution right now as I'm not a NeoVim or plugin developer, but maybe this helps.
Thanks for the plugin, I really enjoy it! I had to replace hardline because it didn't work well with dynamic status from the LSP and so far it's a blast!
If we could name the command used to close/delete a tab we could use 'famiu/bufdelete.nvim'. Bufdelete closes a buffer but doesn't delete the window. This works with cokeline, if I call it manually, but if I click on the the x in the "tab" it fails because it's not using the same command.
@typkrft , thanks for mentioning 'famiu/bufdelete.nvim' . I use key-binding to close the buffer, so this works for me. @noib3 thanks for creating cokeline. Nice plugin.