2

Currently when I open a file (NerdTree appears automatically as well), the light line status line plugin I installed does not show up right away. It only shows up after I switch tabs into NerdTree and then back to the file I have open. The first picture is what the file I open looks like right away, the second is after I switch into nerdtree and then back into my file. Obviously this switching business is quite annoying, so how can I avoid this? The pictures are with my vimrc for reference. Thanks. enter image description here

enter image description here

4
  • 1
    Welcome to Vi and Vim!
    – filbranden
    Jun 6 at 20:43
  • Are you setting g:lightline in your vimrc somewhere? If so, can you share the snippet that sets it? Please edit the question to include those details... Also, try the command :verb set statusline? from the NERDTree window when you open Vim, to check where it's being set, if it's actually being set somewhere... Thanks!
    – filbranden
    Jun 6 at 21:00
  • After trying :verb set statusline? I get the following result: Last set from ~/.vim/plugged/lightline.vim/autoload/lightline.vim line 24, I do not think I am setting g:lightline anywhere in my vimrc, I just have the plugin installed. Jun 6 at 21:11
  • 1
    wait a second, how do you open the vim window? Do you open it directly with NerdTree Open? How? It looks like lightline is not loaded correctly for the NerdTree window, perhaps missing some autocommand event. Jun 11 at 11:43
2

I too had encountered a similar problem. In my case, there was a missing (external) executable, leading to an error in Vim on startup, thus preventing lightline from loading correctly.

I found that switching windows and opening a new split 'fixed' the issue, ie. adding/moving between splits resulted in lightline updating the statusline correctly.

Poking around the source code (plugin/lightline.vim) I found the following line:

  autocmd WinEnter,BufEnter,BufDelete,SessionLoadPost,FileChangedShellPost * call lightline#update()

As I understand it, it is this autocmd that helps to update the statusline correctly as one moves between splits. (In your case, switching to NerdTree and back)

Now, what we want is for lightline to update the statusline once Vim is started... This is the VimEnter event.

Thus, adding

  autocmd VimEnter * call lightline#update()

to your vimrc should resolve the issue.

2
  • Thanks so much, this finally fixed the issue! Jun 21 at 2:24
  • No problem, happy to help :)
    – husB
    Jun 21 at 3:29
0

You need to set the option laststatus to 2 as explained in the help page of lightline:

Problem 4:                  *lightline-problem-4*
    Cool statuslines appear only on |:vsp|.

        Add the following setting to your .vimrc(_vimrc).
>
            set laststatus=2
4
  • 2
    Thanks, but this answer addresses the case where lightline shows only on split windows, which is different from OP's problem. OP already has multiple split windows open, but lightline is still not shown at the start.
    – husB
    Jun 14 at 7:54
  • oh ok, I'm sorry, should I delete my "answer"?
    – TornaxO7
    Jun 14 at 15:36
  • no worries, I hope my comment didn't come across as harsh. I think it's fine to keep it.. your answer may help someone else with a related problem :)
    – husB
    Jun 14 at 16:30
  • no worries, I hope my comment didn't come across as harsh. no it wasn't ;)
    – TornaxO7
    Jun 14 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.