junegunn / goyo.vim

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

Allow `b:` variables, respect `'textwidth'` #262

Open jez opened 2 years ago

jez commented 2 years ago

This PR implements two somewhat orthogonal changes.

If you'd like to only have one of these changes but not the other, I'm happy to split this PR up and send the changes individually, but since the two of them together would have merge conflicts independently, I've authored them in a single PR.

The two changes:

  1. Allow b: variants of the documented configuration variables. This allows setting things like goyo_width to different settings in different file types or different buffers, by setting a buffer-scoped variable.

  2. Default goyo_width to &textwidth + 1 if it is set and neither b:goyo_width nor g:goyo_width are set. The + 1 is to handle an off-by-one error where for a line that has exactly &textwidth characters, goyo would force the line to wrap.

I've been using these changes locally for some files where I have textwidth set to values larger and smaller than 80, and have been working well.


Thanks for your work on Goyo by the way—it makes writing in Vim rather enjoyable.