scrollbar.nvim
scrollbar.nvim copied to clipboard
When scrollbar visible cannot close window
When scrollbar is visible and I type :q<cr>
sometimes I get the following error:
E5601: Cannot close window, only floating window would remain
nvim version is v0.5.0-c7ef80220
how to reproduce?
Maybe related to this https://github.com/neovim/neovim/pull/11938
Steps to reproduce the issue
With the following config:
let g:scrollbar_right_offset = 0
let g:scrollbar_shape = {
\ 'head': ' ',
\ 'body': ' ',
\ 'tail': ' ',
\ }
let g:scrollbar_highlight = {
\ 'head': 'LineNr',
\ 'body': 'LineNr',
\ 'tail': 'LineNr',
\ }
let g:scrollbar_excluded_filetypes = ['nerdtree']
augroup configure_scrollbar
autocmd!
autocmd BufEnter,FocusGained,CursorMoved * silent! lua require('scrollbar').show()
autocmd BufLeave,FocusLost,VimResized * silent! lua require('scrollbar').clear()
augroup end
- Open nvim
- Do
:tabnew
- Do
:e $MYVIMRC
(or any long file that will show the scrollbar) - Do
:q
- Observe the following error message in the status line:
E5601: Cannot close window, only floating window would remain
Workaround / Potential solution
If I clear the scrollbar right before quitting with QuitPre
, I am able to close again:
autocmd BufLeave,FocusLost,VimResized,QuitPre * silent! lua require('scrollbar').clear()
Your solution is the best practice for now. Neovim can't close the window in a new tab and anchored by floating windows. I'll update the doc and readme later.
More details in this PR https://github.com/neovim/neovim/pull/11938
@Xuyuanp use QuitPro
autocmd to clear scrollbar, checkout https://github.com/SpaceVim/SpaceVim/pull/3855, now it works for me.
@wsdjeg thanks
I would add TabEnter
and TabLeave
to the solution of @jeromedalbert.
augroup ScrollbarInit
autocmd!
autocmd CursorMoved,VimResized,QuitPre * silent! lua require('scrollbar').show()
autocmd WinEnter,FocusGained,TabEnter * silent! lua require('scrollbar').show()
autocmd WinLeave,FocusLost,VimResized,QuitPre,TabLeave * silent! lua require('scrollbar').clear()
augroup end