zefei / vim-wintabs

Modern buffer manager for Vim
MIT License
325 stars 25 forks source link

w:wintabs_buflist not set on VimEnter / plugin init when g:wintabs_display = 'none' #22

Closed alexanderjeurissen closed 6 years ago

alexanderjeurissen commented 6 years ago

Observed behavior:

There seems to be a bug in how w:wintabs_buflist is set. If g:wintabs_display is either tabline or statusline it behaves as expected and w:wintabs_buflist is set whenever vim is opened and a file is opened in a buffer.

If however g:wintabs_display is set to none then vim-wintabs does not refresh the buflist it seems, and requires manualy invoking one of the wintabs navigation commands (WintabsNext / WintabsPrevious) to initialize the w:wintabs_buflist dictionary, which also only contains the current buffer in that case. Strange enough invoking WintabsRefresh does not work but WintabsNext does init the variable.

Expected behavior:

w:wintabs_buflist is set and behaves consistently regardless of the setting of g:wintabs_display

Reproduction steps:

Using the following minimal vimrc:

set nocompatible               " Be iMproved

"Note: install vim-plug if not present
if empty(glob('~/.config/nvim/autoload/plug.vim'))
  silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

  autocmd VimEnter * PlugInstall
endif

"Note: Skip initialization for vim-tiny or vim-small.
if !1 | finish | endif
if has('vim_starting')
  set nocompatible               " Be iMproved
  " Required:
  call plug#begin()
endif

Plug 'zefei/vim-wintabs'

" Add plugins to &runtimepath
call plug#end()

if has_key(g:plugs, 'vim-wintabs')
  let g:wintabs_display = 'none'
endif

invoked using: nvim -u ./minimal_vimrc.vim

  1. type the following in the commandline: :echo w:wintabs_buflist => expect error to be shown
  2. open any file, for example neovim config: :e ~/.config/nvim/init.vim
  3. redo step 1 => expect the same error to be shown
  4. open another file :e ~/.zshrc
  5. redo step 1 => expect the same error to be shown
  6. type the following in the command line: :WintabsNext
  7. redo step 1 => expect the variable to contain a single buffer (instead of two)
zefei commented 6 years ago

@alexanderjeurissen thanks again for the detailed repro, this is great. I'll take a look whenever possible.

zefei commented 6 years ago

@alexanderjeurissen I pushed a fix for this, can you check if it's still an issue?

alexanderjeurissen commented 6 years ago

I can confirm that with the following minimal vimrc I'm no longer able to reproduce the bug I reported earlier:

set nocompatible               " Be iMproved

"Note: install minpac if not present
if empty(glob('~/.config/nvim/pack/minpac/opt/minpac'))
  silent !git clone https://github.com/k-takata/minpac.git ~/.config/nvim/pack/minpac/opt/minpac
  autocmd VimEnter * PlugInstall
endif

packadd minpac
call minpac#init()
call minpac#add('zefei/vim-wintabs')
call minpac#update()

if has_key(g:minpac#pluglist, 'vim-wintabs')
  let g:wintabs_display = 'none'
endif

Nice work @zefei !!