Lightline.vim: lightline background highlighting disappears with resourcing vimrc

Created on 23 Jan 2019  路  4Comments  路  Source: itchyny/lightline.vim

Thanks for lightline -it's a great plugin.
However, I recently wanted to add the option set scrolloff=2 to my .vimrc file, and found that it killed my lightline. To clarify, I could still see all of the information from the lightline (e.g. NORMAL [my buffer] unix | latin1 | r 1% 3:1), but the highlighted background color was no longer visible, which made the text hard to distinguish from the file contents --with horizontal pane-splits, this really makes it hard to see where you are at any given moment, and everything just looks blurred together.

When I commented out the scrolloff option in my .vimrc (and re-sourced), the line was not restored. However, when I quit vim entirely and started it up again (without setting scrolloff, then the lightline was present and visible as desired).

Especially weird: when I set scrolloff manually in my session (i.e. outside of my .vimrc) I did not encounter this problem (i.e. the lightline retained its normal, visible behaviour), although this isn't really a satisfactory solution, since I'd like to have scrolloff set automatically for every session.

Any suggestions as to how I can have scrolloff set in my vimrc without disrupting the lightline settings?

Thanks again.

configuration

Most helpful comment

Sorry, I hadn't noticed that previous issue.
I just changed the above .vimrc line to the following:

autocmd BufWritePost $MYVIMRC nested source $MYVIMRC

and, indeed, the line remains after resourcing. Problem solved. Thank you!

All 4 comments

I can't reproduce the problem in terminal Vim on macOS. So please give me some information on the Vim version, in terminal or GUI, OS version with some screenshots if possible. Sounds like an interesting behavior but I can't still judge the issue exists in this plugin or Vim itself.

Thanks for the quick reply. After another look I realize this doesn't actually have anything to do with scrolloff, rather, it is due to my re-sourcing of the vimrc file itself (I have changed the name of this issue accordingly)

some further info:

$ vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 22 2018 17:19:56)
macOS version
Included patches: 1-450
Compiled by Homebrew

My .vimrc file contains the following lines:

" Source the vimrc file after saving it
if has("autocmd")                                       
 autocmd bufwritepost .vimrc source $MYVIMRC
endif

So, if I open three files as follows:
vim test1 test2 test3 -o
Everything looks lovely see first screenshot

but then I open my .vimrc file in a vertical split panel, and without making any changes at all to that file, I simply hit :w to write it, which triggers a re-source, and then the resulting change of the lines is shown in the second screenshot.

Please add nested flag before source. Related comment: https://github.com/itchyny/lightline.vim/issues/102#issuecomment-102979082. Sourcing vimrc -> loading colorscheme (which has hi clear) -> ColorScheme event (triggers nested events) -> lightline#highlight is called by https://github.com/itchyny/lightline.vim/blob/83ae633be323a7fb5baf77e493232cf3358d02bf/plugin/lightline.vim#L20-L21.

Sorry, I hadn't noticed that previous issue.
I just changed the above .vimrc line to the following:

autocmd BufWritePost $MYVIMRC nested source $MYVIMRC

and, indeed, the line remains after resourcing. Problem solved. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dongsibo picture dongsibo  路  4Comments

8i8 picture 8i8  路  3Comments

mckellyln picture mckellyln  路  5Comments

kiryph picture kiryph  路  3Comments

mrbig033 picture mrbig033  路  4Comments