From b39e3e7bb2c41264c2ad515f20cd698323879ddd Mon Sep 17 00:00:00 2001 From: Liu-Cheng Xu Date: Sun, 15 Mar 2020 10:49:03 +0800 Subject: [PATCH 1/2] Add popup preview border Close #156 --- autoload/clap.vim | 2 ++ autoload/clap/popup.vim | 19 ++++++++++++++++--- doc/clap.txt | 14 ++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/autoload/clap.vim b/autoload/clap.vim index 65513a67b..db1bdf602 100644 --- a/autoload/clap.vim +++ b/autoload/clap.vim @@ -88,6 +88,8 @@ let g:clap_enable_icon = get(g:, 'clap_enable_icon', exists('g:loaded_webdevicon let g:clap_insert_mode_only = get(g:, 'clap_insert_mode_only', v:false) let g:clap_providers_relaunch_code = get(g:, 'clap_providers_relaunch_code', '@@') +let g:clap_popup_border = get(g:, 'clap_popup_border', 'rounded') + function! s:inject_default_impl_is_ok(provider_info) abort let provider_info = a:provider_info diff --git a/autoload/clap/popup.vim b/autoload/clap/popup.vim index a1f6a51e5..dddda7195 100644 --- a/autoload/clap/popup.vim +++ b/autoload/clap/popup.vim @@ -102,8 +102,8 @@ function! s:create_preview() abort if !exists('s:preview_winid') || empty(popup_getpos(s:preview_winid)) let pos = popup_getpos(s:display_winid) let line = pos.line + pos.height - let s:preview_winid = popup_create([], { - \ 'wrap': v:false, + let preview_opts = { + \ 'wrap': v:true, \ 'zindex': 100, \ 'scrollbar': 0, \ 'highlight': 'ClapPreview', @@ -111,7 +111,20 @@ function! s:create_preview() abort \ 'line': line, \ 'minwidth': pos.width, \ 'maxwidth': pos.width, - \ }) + \ } + if g:clap_popup_border !=? 'nil' + let borderchars = ['─', '│', '─', '│'] + if g:clap_popup_border ==? 'rounded' + let borderchars += ['╭', '╮', '╯', '╰'] + else + let borderchars += ['┌', '┐', '┘', '└'] + endif + let preview_opts.border = [] + let preview_opts.borderchars = borderchars + let preview_opts.minwidth -= 2 + let preview_opts.maxwidth -= 2 + endif + let s:preview_winid = popup_create([], preview_opts) call popup_hide(s:preview_winid) call win_execute(s:preview_winid, 'setlocal nonumber') let g:clap#popup#preview.winid = s:preview_winid diff --git a/doc/clap.txt b/doc/clap.txt index fefb2fc80..697a158c4 100644 --- a/doc/clap.txt +++ b/doc/clap.txt @@ -148,6 +148,20 @@ g:clap_popup_input_delay *g:clap_popup_input_delay* This option is only meaningful for Vim, NeoVim does not have this delay. +g:clap_popup_border *g:clap_popup_border* + + Type: |String| + Default: `'rounded'` + + This variable adds the border to the preview popup, avaliable border style: + `'rounded'`, `'sharp'`. + + Set it to `'nil'` to disable the border. + + NeoVim's floating_win is unsupported as it does not have a native + border option and the workaround is not good for clap's use case. + + g:clap_maple_delay *g:clap_maple_delay* Type: |Number| From 860c4d2e18b94ccf1c190ab1667d33a40b863329 Mon Sep 17 00:00:00 2001 From: Liu-Cheng Xu Date: Sun, 15 Mar 2020 11:20:42 +0800 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fa6237c1..e9af1793e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ CHANGELOG ## [unreleased] +### Added + +- Add `g:clap_popup_border` for adding the border for the preview popup. ([#349](https://github.com/liuchengxu/vim-clap/pull/349)) + ### Improved - Print a note about Rust nightly is requred for building the Python dynamic module.