junegunn / goyo.vim

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

Width becomes wrong from fullscreen mode in linux #43

Closed lervag closed 9 years ago

lervag commented 9 years ago

If I open gvim, go to fullscreen mode, issue :Goyo, then the window with becomes much less than the default 80. If I instead issue :Goyo before I go to fullscreen mode, then it works as expected.

My vimrc settings are:

let g:goyo_margin_top = 0
let g:goyo_margin_bottom = 0
map <F8> :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()
  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
autocmd  User GoyoEnter call <SID>goyo_enter()
autocmd! User GoyoLeave
autocmd  User GoyoLeave call <SID>goyo_leave()

Note that the current workaround works (although it should not be necessary):

autocmd User GoyoEnter Goyo 80
junegunn commented 9 years ago

Thanks for the report. I currently don't have access to a linux desktop, I will check when I get a chance. (From what I can tell it's not reproducible on MacVim.)

lervag commented 9 years ago

I'm not surprised if it is not reproducible on MacVim, which even allows to set fullscreen mode from inside vim. In any case, let me know if there is anything I can do to help.

junegunn commented 9 years ago

Which distro are you running?

lervag commented 9 years ago

I'm on Arch linux and I use xfce4.

  1. sep. 2014 16:28 skrev "Junegunn Choi" notifications@github.com følgende:

Which distro are you running?

— Reply to this email directly or view it on GitHub https://github.com/junegunn/goyo.vim/issues/43#issuecomment-55750968.

junegunn commented 9 years ago

I managed to set up an Arch VM with xfce4, but I couldn't reproduce the problem. (However, I ran into a different problem where "height" instead of width shrinks by a few lines. But it seemed like a bug of GVim itself, as it was easily reproducible with tab split without Goyo)

Could you try it without any other plugins and settings?

gvim -Nu <(echo 'set rtp+=~/.vim/bundle/goyo.vim')
lervag commented 9 years ago

Ah, I'm very sorry, I should of course have tested a minimal example first. I should at the very least have tested the example I described initially!

My problem is due to the use of a different plugin vim-fontsize that I use inside the goyo_enter function to increase the font size. I do not understand why the problem occur. I'll investigate further on my own, and in the inprobable case that there is something wrong with Goyo I'll reopen the issue.

lervag commented 9 years ago

Ok, so I managed to find a simple example that fails without using external plugins. Personally I use the Inconsolata-g\ Medium font, but since you might use other fonts I chose to let you choose the font yourself. In any case, if you use the following goyo_enter function where the font size is increased with set guifont, the problem should be reproducible.

function! s:goyo_enter()
  set guifont=<selected font> 11
endfunction
junegunn commented 9 years ago

What happens when you add nested to the autocmd statements like so? Does it help?

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

Goyo re-adjusts the sizes of the windows on VimResized event which should be invoked on set guifont.

junegunn commented 9 years ago

I recently updated README page to encourage the use of nested flag.

https://github.com/junegunn/goyo.vim/commit/9eadf29430af9e98247f8e22c9103a9c74aa5a17

lervag commented 9 years ago

Yes, with nested the issue is solved. Thanks!