This PR introduces a new global option, 'pumborder'
('pb'
), that allows
users to define borders and optional decorations for the completion popup
menu.
'pumborder' 'pb' number (default 0)
global
Defines a border and optional decorations for the popup menu in
completion. The value is a comma-separated list of keywords.
Border styles (at most one):
"single" use thin box-drawing characters
"double" use double-line box-drawing characters
"round" use rounded corners
"ascii" use ASCII characters (-, |, +)
"custom:X;X;X;X;X;X;X;X"
use eight characters separated by semicolons, in the
order: top, right, bottom, left,
topleft, topright, botright, botleft
Additional flags:
"margin" adds one-cell spacing inside the left and right border
"shadow" draws a shadow at the right and bottom edges
Highlight groups:
|hl-PmenuBorder| used for the border characters
|hl-PmenuShadow| used for the shadow
Examples: >
:set pumborder=single
:set pumborder=double,margin,shadow
:set pumborder=custom:─;│;─;│;┌;┐;┘;└,shadow
<
Border styles using box-drawing characters ("single", "double",
"round") are only available when |'encoding'| is "utf-8" and
|'ambiwidth'| is "single". "margin" requires a border style.
See also: |ins-completion-menu|.
Also, fixes #18441 (comment)
Screenshot.2025-09-24.at.10.55.21.AM.png (view on web)https://github.com/vim/vim/pull/18486
(72 files)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@girishji pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.
huh, looks good
image.png (view on web) image.png (view on web) image.png (view on web)—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
So this is essentially the same as #17091 ?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@chrisbra This PR builds on #18441, which simplifies the positioning logic, making it easier to add borders and shadows without introducing bugs.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@Copilot commented on this pull request.
This PR introduces a new global option 'pumborder'
('pb'
) that allows users to define borders and optional decorations for the completion popup menu. This enhancement provides visual improvements to the popup menu by adding customizable borders, margins, and shadows.
'pumborder'
option with support for different border styles (single, double, round, ascii, custom)PmenuBorder
and PmenuShadow
for customizationCopilot reviewed 73 out of 73 changed files in this pull request and generated 4 comments.
Show a summary per fileFile | Description |
---|---|
src/vim.h | Adds new highlight group constants for popup menu border and shadow |
src/popupmenu.c | Core implementation of border drawing, shadow effects, and popup positioning logic |
src/optionstr.c | Handles parsing and validation of the pumborder option |
src/optiondefs.h | Defines the new pumborder option in the options table |
src/option.h | Declares the global variable for the pumborder option |
src/highlight.c | Sets up default highlight groups and color schemes for border and shadow |
runtime/ files | Updates documentation, syntax highlighting, and option window support |
src/testdir/ files | Adds comprehensive tests and screen dumps for the new functionality |
src/popupmenu.c:211
width > p_pmw
to width >= p_pmw
. This means when width equals p_pmw, it will now be truncated and end_padding disabled. This could be a subtle behavior change that affects popup menu rendering. Verify this change is intentional and doesn't break existing functionality. if (p_pmw > 0 && width >= p_pmw)
{
width = p_pmw;
end_padding = FALSE;
}
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
In src/testdir/test_options.vim:
> @@ -637,7 +637,7 @@ func Test_set_completion_string_values() set keyprotocol& " previewpopup / completepopup
This change appears to be updating test expectations due to reordering of completion options. While the change itself is correct, consider adding a comment explaining why 'align:' is now expected first instead of 'height:' to help future maintainers understand this ordering dependency.
⬇️ Suggested change- " previewpopup / completepopup + " previewpopup / completepopup + " The completion options for 'set previewpopup=' are order-dependent.. + " 'align:' is currently the first option due to internal ordering. + " If the order changes in the future, update this test and document the reason.
In src/testdir/test_highlight.vim:
> @@ -820,7 +820,7 @@ endfunc " Test for 'highlight' option func Test_highlight_opt() let save_hl = &highlight
The change from 'j:b' to 'K:b' in this test suggests that 'j' is now a valid highlight group identifier (likely for PmenuBorder). Consider adding a comment explaining that 'j' was previously invalid but is now used for PmenuBorder highlighting.
⬇️ Suggested change- let save_hl = &highlight + let save_hl = &highlight + " Previously, 'j' was an invalid highlight group identifier and was used in this test. + " Now, 'j' is valid (used for PmenuBorder), so we use 'K' as an invalid identifier.
In src/popupmenu.c:
> @@ -568,7 +609,7 @@ pum_display_rtl_text( char_u *rt_start = rt; cells = mb_string2cells(rt, -1);
The removal of '- 1' from the truncation calculation appears in multiple places. While this might be correct for the new border logic, consider adding a comment explaining why this adjustment was needed to help future maintainers understand the calculation.
⬇️ Suggested change- cells = mb_string2cells(rt, -1); + cells = mb_string2cells(rt, -1); + // The '- 1' was removed from the truncation calculation below to match the new border logic. + // This ensures that the calculation correctly accounts for the available space, including borders and padding. + // If you change the border or padding logic, revisit this calculation.
In src/popupmenu.c:
> @@ -209,34 +255,29 @@ pum_compute_horizontal_placement(int cursor_col) return; } - // Truncated pum is no longer aligned with "cursor_col" -#ifdef FEAT_RIGHTLEFT - if (pum_rl) - available_width = Columns - pum_scrollbar; - else -#endif - available_width += cursor_col; + // Case 2: Truncated pum is no longer aligned with "cursor_col" + available_width = Columns - trailing_overhead - col_offset; if (available_width > p_pw) {
The removal of '+ 1' from p_pw + 1
changes the popup width calculation. This appears to be related to border adjustments, but consider adding a more detailed comment explaining why this change was necessary and how it relates to the new border feature.
- { + { + // Previously, pum_width was set to p_pw + 1 to account for the border. + // With the new border feature, the border is now handled separately, + // so the '+ 1' is no longer needed here. This ensures the popup width + // calculation is accurate and avoids off-by-one errors with borders.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
Does this also apply to popups or do you plan to make use of it for popups?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@girishji commented on this pull request.
In src/popupmenu.c:
> @@ -568,7 +609,7 @@ pum_display_rtl_text( char_u *rt_start = rt; cells = mb_string2cells(rt, -1);
not needed.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
@girishji commented on this pull request.
In src/testdir/test_highlight.vim:
> @@ -820,7 +820,7 @@ endfunc " Test for 'highlight' option func Test_highlight_opt() let save_hl = &highlight
not needed.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
@girishji commented on this pull request.
In src/testdir/test_options.vim:
> @@ -637,7 +637,7 @@ func Test_set_completion_string_values() set keyprotocol& " previewpopup / completepopup
not needed.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
Does this also apply to popups or do you plan to make use of it for popups?
popupwin.c already has border. Only popupmenu.c didn't have border, and now it does.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.