Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add popup preview border #349

Merged
merged 2 commits into from
Mar 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions autoload/clap.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 16 additions & 3 deletions autoload/clap/popup.vim
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,29 @@ 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',
\ 'col': pos.col,
\ '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
Expand Down
14 changes: 14 additions & 0 deletions doc/clap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down