summaryrefslogtreecommitdiffstats
path: root/README-VIM.md
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2020-02-04 00:35:57 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2020-02-04 00:35:57 +0900
commit7ceb58b2aadfcf0f5e99da83626cf88d282159b2 (patch)
tree814a058c79dcb2e8a2b7a79d3977109675fb5c95 /README-VIM.md
parent293dd76af14ff47cde08281b0e2d5f7dd1ce46af (diff)
[vim] Popup window support for both Vim and Neovim
e.g. let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } } Based on the code from https://github.com/junegunn/fzf.vim/issues/821#issuecomment-581273191 by @lacygoill.
Diffstat (limited to 'README-VIM.md')
-rw-r--r--README-VIM.md56
1 files changed, 20 insertions, 36 deletions
diff --git a/README-VIM.md b/README-VIM.md
index 554d748a..103b8e52 100644
--- a/README-VIM.md
+++ b/README-VIM.md
@@ -184,6 +184,7 @@ The following table summarizes the available options.
| `dir` | string | Working directory |
| `up`/`down`/`left`/`right` | number/string | (Layout) Window position and size (e.g. `20`, `50%`) |
| `window` (Vim 8 / Neovim) | string | (Layout) Command to open fzf window (e.g. `vertical aboveleft 30new`) |
+| `window` (Vim 8 / Neovim) | dict | (Layout) Popup window settings (e.g. `{'width': 0.9, 'height': 0.6}`) |
`options` entry can be either a string or a list. For simple cases, string
should suffice, but prefer to use list type to avoid escaping issues.
@@ -193,6 +194,16 @@ call fzf#run({'options': '--reverse --prompt "C:\\Program Files\\"'})
call fzf#run({'options': ['--reverse', '--prompt', 'C:\Program Files\']})
```
+When `window` entry is a dictionary, fzf will start in a popup window. The
+following options are allowed:
+
+- Required:
+ - `width` [float]
+ - `height` [float]
+- Optional:
+ - `highlight` [string default `'Comment'`]: Highlight group for border
+ - `rounded` [boolean default `v:true`]: Use rounded border
+
`fzf#wrap`
----------
@@ -276,44 +287,17 @@ The latest versions of Vim and Neovim include builtin terminal emulator
- On Terminal Vim with a non-default layout
- `call fzf#run({'left': '30%'})` or `let g:fzf_layout = {'left': '30%'}`
-#### Starting fzf in Neovim floating window
+#### Starting fzf in a popup window
```vim
-" Using floating windows of Neovim to start fzf
-if has('nvim')
- function! FloatingFZF(width, height, border_highlight)
- function! s:create_float(hl, opts)
- let buf = nvim_create_buf(v:false, v:true)
- let opts = extend({'relative': 'editor', 'style': 'minimal'}, a:opts)
- let win = nvim_open_win(buf, v:true, opts)
- call setwinvar(win, '&winhighlight', 'NormalFloat:'.a:hl)
- call setwinvar(win, '&colorcolumn', '')
- return buf
- endfunction
-
- " Size and position
- let width = float2nr(&columns * a:width)
- let height = float2nr(&lines * a:height)
- let row = float2nr((&lines - height) / 2)
- let col = float2nr((&columns - width) / 2)
-
- " Border
- let top = '╭' . repeat('─', width - 2) . '╮'
- let mid = '│' . repeat(' ', width - 2) . '│'
- let bot = '╰' . repeat('─', width - 2) . '╯'
- let border = [top] + repeat([mid], height - 2) + [bot]
-
- " Draw frame
- let s:frame = s:create_float(a:border_highlight, {'row': row, 'col': col, 'width': width, 'height': height})
- call nvim_buf_set_lines(s:frame, 0, -1, v:true, border)
-
- " Draw viewport
- call s:create_float('Normal', {'row': row + 1, 'col': col + 2, 'width': width - 4, 'height': height - 2})
- autocmd BufWipeout <buffer> execute 'bwipeout' s:frame
- endfunction
-
- let g:fzf_layout = { 'window': 'call FloatingFZF(0.9, 0.6, "Comment")' }
-endif
+" Required:
+" - width [float]
+" - height [float]
+"
+" Optional:
+" - highlight [string default 'Comment']: Highlight group for border
+" - rounded [boolean default v:true]: Use rounded border
+let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
```
#### Hide statusline