Skip to content
Myr

[vim] Add support for xoffset and yoffset options for popup

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Close https://github.com/junegunn/fzf.vim/issues/942

authored by Junegunn Choi · committed by Junegunn Choi · parent 0896036 · Browse files · 3 files+27 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+27 added−13 removed

  • other:+27 added−13 removed

3 files+27 added−13 removed

modified:doc/fzf.txt+9 added-5 removed
1fzf.txt fzf Last change: February 3 20201fzf.txt fzf Last change: February 6 20202FZF - TABLE OF CONTENTS *fzf* *fzf-toc*3==============================================================================45 FZF Vim integration
210 unmodified lines
216When `window` entry is a dictionary, fzf will start in a popup window. The217following options are allowed:218219 - Required:220 - `width` [float]221 - `height` [float]220 - `width` [float range [0 ~ 1]]221 - `height` [float range [0 ~ 1]]222 - Optional:223 - `xoffset` [float default 0.0 range [0 ~ 1]]224 - `yoffset` [float default 0.0 range [0 ~ 1]]225 - `highlight` [string default `'Comment'`]: Highlight group for border226 - `rounded` [boolean default `v:true`]: Use rounded border227228
78 unmodified lines
307Starting fzf in a popup window~308 *fzf-starting-fzf-in-a-popup-window*309>310 " Required:309 " - width [float]310 " - height [float]311 " - width [float range [0 ~ 1]]312 " - height [float range [0 ~ 1]]313 "314 " Optional:315 " - xoffset [float default 0.5 range [0 ~ 1]]316 " - yoffset [float default 0.5 range [0 ~ 1]]317 " - highlight [string default 'Comment']: Highlight group for border318 " - rounded [boolean default v:true]: Use rounded border319 let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }320<
27 unmodified lines
modified:plugin/fzf.vim+10 added-4 removed
841 unmodified lines
842endif843844function! s:popup(opts) abort845 " Size and position846 let width = float2nr(&columns * a:opts.width)847 let height = float2nr(&lines * a:opts.height)848 let row = float2nr((&lines - height) / 2)849 let col = float2nr((&columns - width) / 2)846 let width = min([max([0, float2nr(&columns * a:opts.width)]), &columns])847 let height = min([max([0, float2nr(&lines * a:opts.height)]), &lines - has('nvim')])848 let row = float2nr(get(a:opts, 'yoffset', 0.5) * (&lines - height))849 let col = float2nr(get(a:opts, 'xoffset', 0.5) * (&columns - width))850851 " Managing the differences852 let row = min([max([0, row]), &lines - has('nvim') - height])853 let col = min([max([0, col]), &columns - width])854 let row += !has('nvim')855 let col += !has('nvim')856857 " Border858 let edges = get(a:opts, 'rounded', 1) ? ['╭', '╮', '╰', '╯'] : ['┌', '┐', '└', '┘']859 let bar = repeat('─', width - 2)860 let top = edges[0] .. bar .. edges[1]
52 unmodified lines
modified:README-VIM.md+8 added-4 removed
196 unmodified lines
197When `window` entry is a dictionary, fzf will start in a popup window. The198following options are allowed:199200- Required:201 - `width` [float]202 - `height` [float]201 - `width` [float range [0 ~ 1]]202 - `height` [float range [0 ~ 1]]203- Optional:204 - `yoffset` [float default 0.5 range [0 ~ 1]]205 - `xoffset` [float default 0.5 range [0 ~ 1]]206 - `highlight` [string default `'Comment'`]: Highlight group for border207 - `rounded` [boolean default `v:true`]: Use rounded border208209`fzf#wrap`
82 unmodified lines
292#### Starting fzf in a popup window293294```vim295" Required:294" - width [float]295" - height [float]296" - width [float range [0 ~ 1]]297" - height [float range [0 ~ 1]]298"299" Optional:300" - xoffset [float default 0.0 range [0 ~ 1]]301" - yoffset [float default 0.0 range [0 ~ 1]]302" - highlight [string default 'Comment']: Highlight group for border303" - rounded [boolean default v:true]: Use rounded border304let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }305```
24 unmodified lines