Hi, I am also seeing the behavior of “saving buffers will cause the tab bar and statusline to lose their highlight colors” (same as: https://github.com/itchyny/lightline.vim/issues/400)
If I have 3 “tabs” open, then saving the buffer on the first tab will not lose highlight colors. However, if I save the buffers on the 2nd or 3rd tab, then the highlight colors are lost on save.


Here is my init.vim:
" === Lightline options ===
set laststatus=2
set noshowmode " turn off extra -- INSERT --
" Change colors to be darker for status bar and tab bar
let g:lightline = {
\ 'colorscheme': 'darcula',
\ }
let g:lightline.component_expand = {
\ 'buffers': 'lightline#bufferline#buffers',
\ 'linter_checking': 'lightline#ale#checking',
\ 'linter_warnings': 'lightline#ale#warnings',
\ 'linter_errors': 'lightline#ale#errors',
\ 'linter_ok': 'lightline#ale#ok',
\ }
let g:lightline.component_type = {
\ 'buffers': 'tabsel',
\ 'linter_checking': 'left',
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error',
\ 'linter_ok': 'left',
\ }
" === Lightline-bufferline options ===
set showtabline=2
let g:lightline#bufferline#filename_modifier = ':t' " only filename, no path
let g:lightline#bufferline#show_number = 1
let g:lightline#bufferline#shorten_path = 1
let g:lightline#bufferline#unnamed = '[No Name]'
let g:lightline#bufferline#unicode_symbols = 0
let g:lightline#bufferline#enable_devicons = 1
let g:lightline#bufferline#min_buffer_count = 2
let g:lightline.tabline = {'left': [['buffers']], 'right': [['close']]}
The output of :au BufWrite:
--- Autocommands ---
coc_nvim BufWritePre
* call s:SyncAutocmd('BufWritePre', +expand('<abuf>'))
BufWritePre
* :%s/\s\+$//e
The output of au: BufWritePost:
--- Autocommands ---
coc_nvim BufWritePost
* call s:Autocmd('BufWritePost', +expand('<abuf>'))
gzip BufWritePost
*.gz call gzip#write("gzip")
*.bz2 call gzip#write("bzip2")
*.Z call gzip#write("compress -f")
*.lzma call gzip#write("lzma -z")
*.xz call gzip#write("xz -z")
*.lz call gzip#write("lzip")
*.zst call gzip#write("zstd --rm")
myvimrc BufWritePost
init.vim so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
plugins.vim
so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
I’m using Neovim v0.5.0-245-g1bfccf028 on Ubuntu 18.04.
Thank you for any insight on helping to solve this issue!
The problem is your myvimrc BufWritePost. If you have something like
autocmd BufWritePost init.vim so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
autocmd BufWritePost plugins.vim so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
then add ++nested attribute like;
autocmd BufWritePost init.vim ++nested so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
autocmd BufWritePost plugins.vim ++nested so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
Wow, that is some amazing troubleshooting, thank you for finding the cause!
I had this in my init.vim file:
" Watch for changes in .vimrc and auto reload
" http://superuser.com/questions/132029/how-do-you-reload-your-vimrc-file-without-restarting-vim
augroup myvimrc
au!
au BufWritePost init.vim,plugins.vim so $MYVIMRC | if has('gui_running') | so
$MYGVIMRC | endif
augroup END
From your suggestion, I made this change:
augroup myvimrc
au!
au BufWritePost init.vim,plugins.vim ++nested so $MYVIMRC | if has('gui_running') | so
$MYGVIMRC | endif
augroup END
Now, the problem is fixed, thank you so much!
Most helpful comment
The problem is your
myvimrc BufWritePost. If you have something likethen add
++nestedattribute like;