From 64d1b28b932423518e972872e769728426267297 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 18 Feb 2015 02:54:32 +0900 Subject: [PATCH] Add g:limelight_paragraph_span (#12) --- README.md | 3 +++ autoload/limelight.vim | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b3223a4..f0123e9 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,9 @@ let g:limelight_conceal_guifg = '#777777' " Default: 0.5 let g:limelight_default_coefficient = 0.7 + +" Number of preceding/following paragraphs to include (default: 0) +let g:limelight_paragraph_span = 1 ``` Goyo.vim integration diff --git a/autoload/limelight.vim b/autoload/limelight.vim index 027e294..4535581 100644 --- a/autoload/limelight.vim +++ b/autoload/limelight.vim @@ -42,6 +42,20 @@ function! s:unsupported() endif endfunction +function! s:getpos() + let span = max([0, get(g:, 'limelight_paragraph_span', 0) - empty(getline('.'))]) + let pos = getpos('.') + for _ in range(0, span) + let start = searchpos('^$', 'bW')[0] + endfor + call setpos('.', pos) + for _ in range(0, span) + let end = searchpos('^$', 'W')[0] + endfor + call setpos('.', pos) + return [start, end] +endfunction + function! s:limelight() if !exists('w:limelight_prev') let w:limelight_prev = [0, 0, 0, 0] @@ -55,7 +69,7 @@ function! s:limelight() return endif - let paragraph = [searchpos('^$', 'bnW')[0], searchpos('^$', 'nW')[0]] + let paragraph = s:getpos() if paragraph ==# w:limelight_prev[2 : 3] return endif