junegunn / goyo.vim

:tulip: Distraction-free writing in Vim
MIT License
4.49k stars 115 forks source link

Integration with vimwiki issues #219

Closed hahuang65 closed 4 years ago

hahuang65 commented 4 years ago

When using with vimwiki, and I am in :Goyo mode, <CR> has issues.

In vimwiki, <CR> is mapped to :VimwikiFollowLink (https://github.com/vimwiki/vimwiki/blob/master/doc/vimwiki.txt#L274)

It will take the current word, and create a link, or follow it. The creation of the link works fine as depicted by these two screenshots: Screen Shot 2020-04-13 at 4 15 18 PM Screen Shot 2020-04-13 at 4 15 14 PM

But then, attempting to follow the link results in exiting out of Goyo: Screen Shot 2020-04-13 at 4 16 02 PM

Once out of Goyo, I can finally follow the link (but leaves me out of Goyo): Screen Shot 2020-04-13 at 4 16 33 PM

Here is my setup for activating Goyo:

nnoremap <localleader>g :Goyo<CR>

function! s:goyo_enter()
  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()
  " 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

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

augroup vimwiki_goyo
  autocmd! FileType vimwiki :Goyo
augroup end
hahuang65 commented 4 years ago

I resolved it by simply using

autocmd! BufRead,BufNewFile *.md :Goyo 75%x75%