Skip to content
Junegunn Choi edited this page Apr 18, 2014 · 23 revisions

Callbacks for GVim

function! g:goyo_before()
  if has('gui_running')
    set fullscreen
    set background=light
    set linespace=7
  elseif exists('$TMUX')
    silent !tmux set status off
  endif
endfunction

function! g:goyo_after()
  if has('gui_running')
    set nofullscreen
    set background=dark
    set linespace=0
  elseif exists('$TMUX')
    silent !tmux set status on
  endif
endfunction

let g:goyo_callbacks = [function('g:goyo_before'), function('g:goyo_after')]

Disabling plugins

MiniBufExpl with g:miniBufExplBuffersNeeded set

function! s:goyo_before()
  MBEClose
  wincmd w
endfunction

let g:goyo_callbacks = [function('s:goyo_before')]

lightline.vim

function! g:goyo_before()
  call lightline#disable()
  set statusline=
endfunction

function! g:goyo_after()
  call lightline#enable()
endfunction

let g:goyo_callbacks = [function('g:goyo_before'), function('g:goyo_after')]

ZoomWin

function! g:goyo_before()
  delcommand ZoomWin
  delcommand <Plug>ZoomWin
endfunction

function! g:goyo_after()
  command! ZoomWin call ZoomWin()
  command! <Plug>ZoomWin call ZoomWin()
endfunction

let g:goyo_callbacks = [function('g:goyo_before'), function('g:goyo_after')]

Ensure :q to quit even when Goyo is active

Suggested by mm2703 and axelGschaider in #16

function! g:goyo_before()
  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! g:goyo_after()
  " Quit Vim if this is the only remaining buffer
  if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1
    if b:quitting_bang
      qa!
    else
      qa
    endif
  endif
endfunction

let g:goyo_callbacks = [function('g:goyo_before'), function('g:goyo_after')]
Clone this wiki locally