patch 9.2.0428: popup: no opacity support for completepopup/previewpopup
Commit:
https://github.com/vim/vim/commit/59e59a62b417c6cee7384718120a9378ee347064
Author: Yasuhiro Matsumoto <[email protected]>
Date: Fri May 1 16:28:51 2026 +0000
patch 9.2.0428: popup: no opacity support for completepopup/previewpopup
Problem: popup: no opacity support for completepopup/previewpopup
Solution: Add support opacity: suboption for the 'completeopt'.
Accepts opacity:0-100 with the same semantics as popup_create()'s
opacity option, allowing the info / preview popup to blend with
the background.
closes: #20099
Signed-off-by: Yasuhiro Matsumoto <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index b0f3f1c72..7e1d4cb67 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -2393,6 +2393,9 @@ A jump table for the options with a short description can
be found at |Q_op|.
close show close button: "on" (default) or "off"
height maximum height of the popup
highlight popup highlight group (default: PmenuSel)
+ opacity opacity percentage 0-100 (default 100, fully
+ opaque). When less than 100, content beneath
+ the popup shows through.
resize show resize handle: "on" (default) or "off"
shadow "off" (default) or "on" using |hl-PmenuShadow|
width maximum width of the popup
@@ -2400,6 +2403,7 @@ A jump table for the options with a short description can
be found at |Q_op|.
Example: >
:set completepopup=height:10,border:single,highlight:InfoPopup
:set completepopup=width:60,border:custom:─;│;─;│;┌;┐;┘;└
+ :set completepopup=border:round,opacity:80
<
When "align" is set to "item", the popup is positioned near the
selected item and moves as the selection changes.
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index ca69850e0..c9ede397b 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -52587,6 +52587,7 @@ Popups ~
- Support for transparency, see |popup-opacity|.
- 'previewpopup' supports the same values as 'completepopup' (except for
"align").
+- Support "opacity" setting for 'completepopup' option.
Diff mode ~
---------
diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt
index f27cc6b05..f0d9afaf1 100644
--- a/runtime/doc/windows.txt
+++ b/runtime/doc/windows.txt
@@ -1,4 +1,4 @@
-*windows.txt* For Vim version 9.2. Last change: 2026 Mar 01
+*windows.txt* For Vim version 9.2. Last change: 2026 May 01
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -960,6 +960,9 @@ settings. The option is a comma-separated list of values:
the value is "on", it must be set after border.
height maximum height of the popup
highlight highlight group of the popup (default is Pmenu)
+ opacity opacity percentage 0-100 (default 100, fully opaque).
+ When less than 100, content beneath the popup shows
+ through.
resize show resize handle: "on" (default) or "off"
shadow "off" (default) or "on" using |hl-PmenuShadow|
width maximum width of the popup
@@ -968,6 +971,7 @@ Example: >
:set previewpopup=height:10,width:60
:set previewpopup=border:single,borderhilight:PmenuBorder
:set previewpopup=border:custom:─;│;─;│;┌;┐;┘;└
+ :set previewpopup=border:round,opacity:80
A few peculiarities:
- If the file is in a buffer already, it will be re-used. This will allow for
diff --git a/src/optionstr.c b/src/optionstr.c
index 128e5a946..59d490913 100644
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -73,11 +73,11 @@ static char *(p_kpc_protocol_values[]) = {"none", "mok2",
"kitty", NULL};
#ifdef FEAT_PROP_POPUP
// Note: Keep this in sync with parse_popup_option()
static char *(p_popup_cpp_option_values[]) = {"align:", "border:",
- "borderhighlight:", "close:", "height:", "highlight:", "resize:",
- "shadow:", "width:", NULL};
+ "borderhighlight:", "close:", "height:", "highlight:", "opacity:",
+ "resize:", "shadow:", "width:", NULL};
static char *(p_popup_pvp_option_values[]) = {"border:",
- "borderhighlight:", "close:", "height:", "highlight:", "resize:",
- "shadow:", "width:", NULL};
+ "borderhighlight:", "close:", "height:", "highlight:", "opacity:",
+ "resize:", "shadow:", "width:", NULL};
static char *(p_popup_option_on_off_values[]) = {"on", "off", NULL};
static char *(p_popup_cpp_border_values[]) = {"single", "double", "round",
"ascii", "on", "off", "custom:", NULL};
diff --git a/src/popupwin.c b/src/popupwin.c
index 103daccd2..fb6e17d05 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -2163,6 +2163,19 @@ parse_popup_option(win_T *wp, int is_preview)
if (wp != NULL && menu)
wp->w_popup_flags |= POPF_INFO_MENU;
}
+ else if (STRNCMP(s, "opacity:", 8) == 0)
+ {
+ if (dig != p || x < 0 || x > 100)
+ return FAIL;
+ if (wp != NULL)
+ {
+ if (x < 100)
+ wp->w_popup_flags |= POPF_OPACITY;
+ else
+ wp->w_popup_flags &= ~POPF_OPACITY;
+ wp->w_popup_blend = 100 - x;
+ }
+ }
else
return FAIL;
}
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index 91610e128..bbca7fe46 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -663,6 +663,22 @@ func Test_set_completion_string_values()
call feedkeys(":set completepopup=height:10,align:\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set completepopup=height:10,align:item', @:)
call assert_equal([], getcompletion('set completepopup=bogusname:',
'cmdline'))
+
+ " opacity: numeric, 0..100 only
+ call assert_true(index(getcompletion('set completepopup=', 'cmdline'),
+ \ 'opacity:') >= 0)
+ call assert_true(index(getcompletion('set previewpopup=', 'cmdline'),
+ \ 'opacity:') >= 0)
+ set completepopup=border:on,opacity:0
+ set completepopup=border:on,opacity:50
+ set completepopup=border:on,opacity:100
+ call assert_fails('set completepopup=opacity:101', 'E474:')
+ call assert_fails('set completepopup=opacity:abc', 'E474:')
+ call assert_fails('set completepopup=opacity:-10', 'E474:')
+ set previewpopup=opacity:30
+ call assert_fails('set previewpopup=opacity:200', 'E474:')
+ call assert_fails('set previewpopup=opacity:-10', 'E474:')
+
set previewpopup& completepopup&
" diffopt: special handling of algorithm:<alg_list> and inline:<inline_type>
diff --git a/src/version.c b/src/version.c
index d77ebcc1f..376f278c6 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 428,
/**/
427,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1wIqzA-000gdQ-9i%40256bit.org.