junegunn / goyo.vim

:tulip: Distraction-free writing in Vim
MIT License
4.52k stars 118 forks source link

goyo broken with vim-airline-clock #214

Open Jemoka opened 4 years ago

Jemoka commented 4 years ago

When using goyo and airline with enricobacis/vim-airline-clock, the originally hidden airline appears after the first update of the clock.

Screen Shot 2020-01-05 at 5 22 47 PM

Part of my .vimrc that matters:

noremap <Leader>g :Goyo<CR>
function! s:goyo_enter()
  Limelight
  let b:quitting = 0
  let b:quitting_bang = 0
  autocmd QuitPre <buffer> let b:quitting = 1
  cabbrev <buffer> q! let b:quitting_bang = 1 <bar> q!
endfunction
function! s:goyo_leave()
  Limelight!
  if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1
    if b:quitting_bang
      qa!
    else
      qa
    endif
  endif
endfunction
autocmd! User GoyoEnter call <SID>goyo_enter()
autocmd! User GoyoLeave call <SID>goyo_leave()

Simplest solution (thus far) is to disable the airline clock or to disable/reenable the plugin at gogo_enter/gogo_leave. As the package is supporting airline hiding, this should be part of the default disabled packages as well. Using vim 8.1 with the latest versions of all packages mentioned.

mawkler commented 4 years ago

@Jemoka

Simplest solution (thus far) is to [...] disable/reenable the plugin at gogo_enter/gogo_leave

Did you get this to work? vim-airline-clock doesn't seem to have a toggle for enabling/disabling it at run-time, the closest setting I could find is let g:airline#extensions#clock#auto which I couldn't get working with GoyoEnter/GoyoLeave since it doesn't quite do what's needed here.

Jemoka commented 4 years ago

@Melkster

@Jemoka

Simplest solution (thus far) is to [...] disable/reenable the plugin at gogo_enter/gogo_leave

Did you get this to work? vim-airline-clock doesn't seem to have a toggle for enabling/disabling it at run-time, the closest setting I could find is let g:airline#extensions#clock#auto which I couldn't get working with GoyoEnter/GoyoLeave since it doesn't quite do what's needed here.

Well... No. Unfortunately I just disabled the plugin entirely and used tmux('s clock). However, I have seen success of other folks somehow disabling the segment representing the clock in vim-airline.

ferdv commented 3 years ago

I think I have a solution. The problem is the timer in vim-airline-clock:

image

Calling [timer_pause](https://vimhelp.org/eval.txt.html#timer_pause()) pauses or un-pauses the timer, so this is a quick vimrc fix:

autocmd! User GoyoEnter call s:on_goyo_enter()
autocmd! User GoyoLeave call s:on_goyo_exit()

function s:on_goyo_enter()
  if exists('g:airline#extensions#clock#timer')
    call timer_pause(g:airline#extensions#clock#timer, 1)
  endif
endfunction

function s:on_goyo_exit()
  if exists('g:airline#extensions#clock#timer')
    call timer_pause(g:airline#extensions#clock#timer, 0)
  endif
endfunction

I'll submit a patch to enricobacis/vim-airline-clock as I think the timer should be paused whenever Airline is toggled.