Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sourcing $MYVIMRC causes lots of errors #8

Closed
itchyny opened this issue Aug 26, 2013 · 8 comments
Closed

sourcing $MYVIMRC causes lots of errors #8

itchyny opened this issue Aug 26, 2013 · 8 comments
Labels

Comments

@itchyny
Copy link
Owner

itchyny commented Aug 26, 2013

:so $MYVIMRC
@nhoad
Copy link

nhoad commented Aug 27, 2013

I have found setting g:lightline in my .vimrc to be the cause for this issue (for me at least), e.g. let g:lightline = {'colorscheme': 'wombat'}

If I comment out that line, I can source the my config as many times as I like, without error. A conditional unlet g:loaded_lightline does not fix the problem either.

Sorry I can't be more helpful - I don't know vimscript very well :)

@itchyny
Copy link
Owner Author

itchyny commented Aug 27, 2013

Do you write the lightline setting after the syntax enable setting?

syntax enable
...
let g:lightline = ...
...

What if setting lightline before both enabling syntax and setting the colorscheme?

let g:lightline = ...
colorscheme XXX
syntax enable
...

@itchyny
Copy link
Owner Author

itchyny commented Aug 27, 2013

Ah, sorry. Order of syntax enable and g:lightline does not matter.
Maybe you may have letting g:lightline after setting the colorscheme.

@nhoad
Copy link

nhoad commented Aug 27, 2013

I did have colorscheme before g:lightline - swapping them around has fixed it! Thank you very much :)

Out of interest, why is the ordering important here in this case?

@itchyny
Copy link
Owner Author

itchyny commented Aug 27, 2013

It is a little complicated.

When colorscheme XXX is executed, all the colors of highlight groups are reset, including lightline's.
So lightline detects the colorscheme command and:

  • initializes g:lightline
  • sets the highlight groups of lightline
  • and the statusline for lightline.

The statusline of lightline assumes that g:lightline is properly initialized.
Letting g:lightline after colorscheme command causes errors in functions, which are used in the statusline.

Anyway, I'll shortly push the code fixing this issue.

@itchyny
Copy link
Owner Author

itchyny commented Aug 27, 2013

Note to me: after sourcing .vimrc, if the cool statusline disappears without error, change the statusline setting in the .vimrc

set statusline=...

to

if &statusline ==# ''
  set statusline=...
endif

Plus, letting g:lightline before syntax enable will fix all the problems.

  • call update in catch block in link function
  • do not overwrite the statusline in .vimrc
  • let g:lightline before syntax enable

Idea: watch CursorHold will make the second out of use.

@itchyny
Copy link
Owner Author

itchyny commented Aug 27, 2013

Simple idea: s:lightline

@itchyny
Copy link
Owner Author

itchyny commented Aug 27, 2013

I found the above simple idea will solve all the problems...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants