@pynvim.command('Scratch')
def cmd_scratch(self):
buffer = self.nvim.api.create_buf(False, True)
win = self.nvim.api.open_win(buffer, True, {'width':60,'height':5,'style':'minimal','relative':'editor','row':0,'col':0})
self.nvim.out_write(f'Scratch {buffer=} {win=}\n')
@pynvim.autocmd('BufUnload', eval='+expand("<abuf>")', sync=True)
def on_bufunload(self, buffer):
self.nvim.out_write(f'BufUnload {buffer=} {self.nvim.current.buffer.number=}\n')
When I :bdelete the scratch buffer, the BufUnload event fires and the callback receives the number of the newly focused buffer (i.e. the same as nvim.current.buffer, not the scratch buffer) in its buffer argument, from the <abuf> expansion.
IIUC, the BufUnload docs says <abuf> should hold the unloading buffer number (here, the scratch buffer). Am I doing something wrong or is that a bug?
(This looks a lot like neovim/node-client#58.)
When I
:bdeletethe scratch buffer, the BufUnload event fires and the callback receives the number of the newly focused buffer (i.e. the same asnvim.current.buffer, not the scratch buffer) in itsbufferargument, from the<abuf>expansion.IIUC, the BufUnload docs says
<abuf>should hold the unloading buffer number (here, the scratch buffer). Am I doing something wrong or is that a bug?(This looks a lot like neovim/node-client#58.)