From f660ca376ef6f30ca45ec4598444b3d08301abe1 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 5 May 2015 22:59:00 +0900 Subject: [PATCH] Add g:goyo_height and deprecate g:goyo_margin_{top,bottom} --- README.md | 1 + autoload/goyo.vim | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4e6ee30..9a52871 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ Configuration ------------- - `g:goyo_width` (default: 80) +- `g:goyo_height` (default: 85%) - `g:goyo_linenr` (default: 0) ### Callbacks diff --git a/autoload/goyo.vim b/autoload/goyo.vim index ca66bb0..9d3d1eb 100644 --- a/autoload/goyo.vim +++ b/autoload/goyo.vim @@ -374,12 +374,20 @@ function! s:relsz(expr, limit) endfunction function! s:parse_arg(arg) - let top = max([0, s:relsz(get(g:, 'goyo_margin_top', 4), &lines)]) - let bot = max([0, s:relsz(get(g:, 'goyo_margin_bottom', 4), &lines)]) + if exists('g:goyo_height') || !exists('g:goyo_margin_top') && !exists('g:goyo_margin_bottom') + let height = s:relsz(get(g:, 'goyo_height', '85%'), &lines) + let yoff = 0 + else + let top = max([0, s:relsz(get(g:, 'goyo_margin_top', 4), &lines)]) + let bot = max([0, s:relsz(get(g:, 'goyo_margin_bottom', 4), &lines)]) + let height = &lines - top - bot + let yoff = top - bot + endif + let dim = { 'width': s:relsz(get(g:, 'goyo_width', 80), &columns), - \ 'height': &lines - top - bot, + \ 'height': height, \ 'xoff': 0, - \ 'yoff': top - bot } + \ 'yoff': yoff } if empty(a:arg) return dim endif