junegunn / goyo.vim

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

Quitting vim w/goyo is not working with vimwiki #213

Open rsyi opened 4 years ago

rsyi commented 4 years ago

I've added this snippet to my .vimrc file to permit :q to quit both goyo and vim, but I noticed it doesn't work when I am using vimwiki and have multiple entries in my buffer, even if I remove the single buffer condition.

The pared-down snippet in my .vimrc is:

function! s:goyo_enter()
  let b:quitting = 0
  autocmd QuitPre <buffer> let b:quitting = 1
endfunction

function! s:goyo_leave()
  if b:quitting
      qa
  endif
endfunction

autocmd! User GoyoEnter call <SID>goyo_enter()
autocmd! User GoyoLeave call <SID>goyo_leave()

Naturally, removing if b:quitting allows the me to leave vim w/:q, suggesting b:quitting not being set correctly by autocmd QuitPre, but I'm not sure where to go from here. Any thoughts on how to fix this?

I'm using vim 8.1.

samyakbardiya commented 4 years ago

Please check this from there Wiki, there are more commands to be added in your function. I have copied this exact and it is working for me even with VimWiki.