[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
Provenance
- Commit
a859aa7- Tree
093eaf2- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
0896036
3 files changed+27 added−13 removed
modified:doc/fzf.txt+9 added-5 removed
1-fzf.txt fzf Last change: February 3 20201+fzf.txt fzf Last change: February 6 20202 FZF - TABLE OF CONTENTS *fzf* *fzf-toc*3 ==============================================================================4 5 FZF Vim integration210 unmodified lines216 When `window` entry is a dictionary, fzf will start in a popup window. The217 following options are allowed:218 219 - 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 border227 228 78 unmodified lines307 Starting 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 linesmodified:plugin/fzf.vim+10 added-4 removed
841 unmodified lines842 endif843 844 function! 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))850 851+ " 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')856+857 " Border858 let edges = get(a:opts, 'rounded', 1) ? ['╭', '╮', '╰', '╯'] : ['┌', '┐', '└', '┘']859 let bar = repeat('─', width - 2)860 let top = edges[0] .. bar .. edges[1]52 unmodified linesmodified:README-VIM.md+8 added-4 removed
196 unmodified lines197 When `window` entry is a dictionary, fzf will start in a popup window. The198 following options are allowed:199 200 - 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 border208 209 `fzf#wrap`82 unmodified lines292 #### Starting fzf in a popup window293 294 ```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 border304 let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }305 ```24 unmodified lines