itchyny / lightline.vim

A light and configurable statusline/tabline plugin for Vim
MIT License
6.75k stars 315 forks source link

Toggle Lightline when using Goyo #83

Closed obxhdx closed 10 years ago

obxhdx commented 10 years ago

I have Goyo.vim installed, which provides a distraction-free mode.

I want to temporarily disable Lightline when Goyo gets enabled, just like Goyo already does for some other plugins: https://github.com/junegunn/goyo.vim/blob/master/plugin/goyo.vim#L150.

I tried calling lightline#disable() but Lightline always comes back after a few seconds.

itchyny commented 10 years ago

Goyo automatically disables lightline as you see at https://github.com/junegunn/goyo.vim/blob/master/plugin/goyo.vim#L177

obxhdx commented 10 years ago

Thanks for pointing out that line in Goyo. But like I said, after disabled, Lightline was reappearing after some time.

Anyways, I just found out what the problem really was... I had the following configuration:

autocmd CursorHold,BufWritePost,InsertLeave * call s:component_expand()
function! s:component_expand()
  call TrailingSpaceWarning()
  call MixedIndentSpaceWarning()
  call lightline#update()
endfunction

So, that CursorHold was the issue.

itchyny commented 10 years ago

You call lightline#update so the statusline is updated. CursorHold is triggered even when you use Goyo or anything.

yous commented 8 years ago

You can modify your autocmd to update lightline.vim only when it's enabled.

autocmd CursorHold,BufWritePost,InsertLeave * call s:component_expand()
function! s:component_expand()
  call TrailingSpaceWarning()
  call MixedIndentSpaceWarning()
  if exists('#lightline')
    call lightline#update()
  endif
endfunction