Skip to content

Feat: Add border for popup menu ('pumborder' option) - #18486

Closed
girishji wants to merge 4 commits into
vim:masterfrom
girishji:border2
Closed

girishji wants to merge 4 commits into
vim:masterfrom
girishji:border2

Conversation

@girishji

@girishji girishji commented Oct 4, 2025

Copy link
Copy Markdown
Contributor

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

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'*
'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:XXXXXXXX"
			use eight characters given after "custom:",
			in 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 vim#18441 (comment)
Comment thread src/optionstr.c Fixed
@habamax

habamax commented Oct 5, 2025

Copy link
Copy Markdown
Contributor

huh, looks good

image image image

@chrisbra

chrisbra commented Oct 5, 2025

Copy link
Copy Markdown
Member

So this is essentially the same as #17091 ?

@Shane-XB-Qian

This comment was marked as off-topic.

@girishji

girishji commented Oct 5, 2025

Copy link
Copy Markdown
Contributor Author

@chrisbra This PR builds on #18441, which simplifies the positioning logic, making it easier to add borders and shadows without introducing bugs.

@chrisbra
chrisbra requested a review from Copilot October 6, 2025 18:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

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.

  • Adds the 'pumborder' option with support for different border styles (single, double, round, ascii, custom)
  • Implements margin and shadow features for the popup menu
  • Adds new highlight groups PmenuBorder and PmenuShadow for customization

Reviewed Changes

Copilot reviewed 73 out of 73 changed files in this pull request and generated 4 comments.

Show a summary per file
File 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
Comments suppressed due to low confidence (1)

src/popupmenu.c:211

  • The condition changed from 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.

Comment thread src/testdir/test_options.vim
Comment thread src/testdir/test_highlight.vim
Comment thread src/popupmenu.c
Comment thread src/popupmenu.c
@chrisbra

chrisbra commented Oct 6, 2025

Copy link
Copy Markdown
Member

Does this also apply to popups or do you plan to make use of it for popups?

@girishji

girishji commented Oct 7, 2025 •

Copy link
Copy Markdown
Contributor Author

Does this also apply to popups or do you plan to make use of it for popups?

popupwin.c (used by plugins and info window) already has border. Only popupmenu.c didn't have border, and now it does.

@chrisbra

chrisbra commented Oct 7, 2025

Copy link
Copy Markdown
Member

thanks

@chrisbra chrisbra closed this in 474b981 Oct 7, 2025
bennyyip pushed a commit to bennyyip/vim that referenced this pull request Oct 7, 2025
Problem:  not possible to style popup borders globally
Solution: Add the 'pumborder' option (Girish Palya)

This commit introduces a new global option, 'pumborder' ('pb'), that
allows users to define borders and optional decorations for the
completion popup menu.

```
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"singleuse thin box-drawing characters
"double"doubleuse double-line box-drawing characters
"round"rounduse rounded corners
"ascii"asciiuse ASCII characters (-, |, +)
"custom:XXXXXXXX"
    use eight characters given after "custom:",
    in order: top, right, bottom, left,
    topleft, topright, botright, botleft

Additional flags:
"margin"marginadds one-cell spacing inside the left and right border
"shadow"shadowdraws a shadow at the right and bottom edges

Highlight groups:
|hl-PmenuBorder|hl-PmenuBorderused for the border characters
|hl-PmenuShadow|hl-PmenuShadowused 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|.
```

fixes: vim#18441 (comment)
closes: vim#18486
closes: vim#17091

Signed-off-by: Girish Palya <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
@girishji

girishji commented Oct 8, 2025

Copy link
Copy Markdown
Contributor Author

Thanks

@girishji
girishji deleted the border2 branch October 8, 2025 04:12
@girishji

girishji commented Jan 8, 2026

Copy link
Copy Markdown
Contributor Author

@zeertzjq any reason why this is not merged into Neovim?

@zeertzjq

zeertzjq commented Jan 8, 2026

Copy link
Copy Markdown
Member

A part of it is merged (some of the 'pumborder' values works), but due to the presence of the existing 'winborder' option there are some differences, and I haven't figured out how to merged the remaining part yet.

@girishji

girishji commented Jan 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks, I guess I was using the older version of Neovim. Your shadow implementation does not look right though (on the side it is only half as wide as the bottom), and underlying text is invisible unlike Vim which has some transparency. Option values cannot be combined either. Anyway, just nitpicking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants