Background: neovim with tagbar plugin installed
Goal: when starting nvim, if current window size is larger than 100, open tagbar and set auto-open for new buffers.
Currently I use the settings below to achieve auto-open for supported files in new buffers:
autocmd VimEnter * nested :call tagbar#autoopen(1)
I want the auto-open be controlled by window width because sometimes I use a narrow terminal split by iTerms or tmux, tagbar is not suitable to open in this situation.
I tried the following but it didn't work:
" if I add `echo winwidth('%') here, it will show 80, not the current terminal width if winwidth('%') > 100 autocmd VimEnter * nested :call tagbar#autoopen(1) endif
It seems that
winwidth('%') returns number of
columns when nvimrc is executed (I didn't overwrite columns, the default value is 80), so the
if is always false and the tagbar never auto-opens. But when I execute
:echo winwidth('%') after nvim is opened, the result is 154, represents the actual width of current terminal window.
Please help me find out the right
if statement, or gives another solution lead to the same goal.