diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2020-02-06 12:27:48 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2020-02-06 12:27:48 +0900 |
commit | 446df07b6269d2fe519aa15c02b6b0d514f0d5dc (patch) | |
tree | c416be8dfcc1660c62571d00f8e572b20989dbb5 /plugin | |
parent | 8583b150c91c47b180f14099f72e93619ea946b2 (diff) |
[vim] Border style for popup window (rounded | sharp | horizontal)
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/fzf.vim | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 5c93f5aa..7e3046af 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -854,20 +854,33 @@ function! s:popup(opts) abort let row += !has('nvim') let col += !has('nvim') - " Border - let edges = get(a:opts, 'rounded', 1) ? ['╭', '╮', '╰', '╯'] : ['┌', '┐', '└', '┘'] - let bar = repeat('─', width - 2) - let top = edges[0] .. bar .. edges[1] - let mid = '│' .. repeat(' ', width - 2) .. '│' - let bot = edges[2] .. bar .. edges[3] - let border = [top] + repeat([mid], height - 2) + [bot] + " Border style + let style = get(a:opts, 'border', 'rounded') + if !has_key(a:opts, 'border') && !get(a:opts, 'rounded', 1) + let style = 'sharp' + endif + + if style == 'horizontal' + let hor = repeat('─', width) + let mid = repeat(' ', width) + let border = [hor] + repeat([mid], height - 2) + [hor] + let margin = 0 + else + let edges = style == 'sharp' ? ['┌', '┐', '└', '┘'] : ['╭', '╮', '╰', '╯'] + let bar = repeat('─', width - 2) + let top = edges[0] .. bar .. edges[1] + let mid = '│' .. repeat(' ', width - 2) .. '│' + let bot = edges[2] .. bar .. edges[3] + let border = [top] + repeat([mid], height - 2) + [bot] + let margin = 2 + endif let highlight = get(a:opts, 'highlight', 'Comment') let frame = s:create_popup(highlight, { \ 'row': row, 'col': col, 'width': width, 'height': height, 'border': border \ }) call s:create_popup('Normal', { - \ 'row': row + 1, 'col': col + 2, 'width': width - 4, 'height': height - 2 + \ 'row': row + 1, 'col': col + margin, 'width': width - margin * 2, 'height': height - 2 \ }) if has('nvim') execute 'autocmd BufWipeout <buffer> bwipeout '..frame |