Skip to content
Permalink
Browse files

patch 8.1.1882: cannot specify properties of the info popup window

Problem:    Cannot specify properties of the info popup window.
Solution:   Add the 'completepopup' option.  Default to PmenuSel highlight.
  • Loading branch information...
brammool committed Aug 18, 2019
1 parent f4665e7 commit 62a0cb443c3184f24a6dac73d3505f9056cf6056
@@ -1,4 +1,4 @@
*insert.txt* For Vim version 8.1. Last change: 2019 May 07
*insert.txt* For Vim version 8.1. Last change: 2019 Aug 18


VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1092,7 +1092,7 @@ items:
menu extra text for the popup menu, displayed after "word"
or "abbr"
info more information about the item, can be displayed in a
preview window
preview or popup window
kind single letter indicating the type of completion
icase when non-zero case is to be ignored when comparing
items to be equal; when omitted zero is used, thus
@@ -1114,11 +1114,22 @@ items in the returned list.

The "menu" item is used in the popup menu and may be truncated, thus it should
be relatively short. The "info" item can be longer, it will be displayed in
the preview window when "preview" appears in 'completeopt'. The "info" item
will also remain displayed after the popup menu has been removed. This is
useful for function arguments. Use a single space for "info" to remove
existing text in the preview window. The size of the preview window is three
lines, but 'previewheight' is used when it has a value of 1 or 2.
the preview window when "preview" appears in 'completeopt' or in a popup
window when "popup" appears in 'completeopt'. In the preview window the
"info" item will also remain displayed after the popup menu has been removed.
This is useful for function arguments. Use a single space for "info" to
remove existing text in the preview window. The size of the preview window is
three lines, but 'previewheight' is used when it has a value of 1 or 2.

*complete-popup*
When "popup" is in 'completeopt' a popup window is used to display the "info".
Then the 'completepopup' option specifies the properties of the popup. The
option is a comma separated list of values:
height maximum height of the popup
width maximum width of the popup
highlight highlight group of the popup (default is Pmenu)
Example: >
:set completepopup=height:10,width:60,highlight:InfoPopup

The "kind" item uses a single letter to indicate the kind of completion. This
may be used to show the completion differently (different color or icon).
@@ -1,4 +1,4 @@
*options.txt* For Vim version 8.1. Last change: 2019 Aug 17
*options.txt* For Vim version 8.1. Last change: 2019 Aug 18


VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1918,6 +1918,7 @@ A jump table for the options with a short description can be found at |Q_op|.
popup Show extra information about the currently selected
completion in a popup window. Only works in combination
with "menu" or "menuone". Overrides "preview".
See |'completepopup'| for specifying properties.
{only works when compiled with the +textprop feature}

noinsert Do not insert any text for a match until the user selects
@@ -1929,6 +1930,15 @@ A jump table for the options with a short description can be found at |Q_op|.
"menu" or "menuone".


*'completepopup'* *'cpp'*
'completepopup' 'cpp' string (default empty)
global
{not available when compiled without the |+textprop|
or |+quickfix| feature}
When 'completeopt' contains "popup" then this option is used for the
properties of the info popup. See |complete-popup|.


*'concealcursor'* *'cocu'*
'concealcursor' 'cocu' string (default: "")
local to window
@@ -3160,8 +3170,8 @@ A jump table for the options with a short description can be found at |Q_op|.
*'fillchars'* *'fcs'*
'fillchars' 'fcs' string (default "vert:|,fold:-")
global
{not available when compiled without the |+windows|
and |+folding| features}
{not available when compiled without the |+folding|
feature}
Characters to fill the statuslines and vertical separators.
It is a comma separated list of items:

@@ -3797,8 +3807,7 @@ A jump table for the options with a short description can be found at |Q_op|.
*'guitablabel'* *'gtl'*
'guitablabel' 'gtl' string (default empty)
global
{only available when compiled with GUI enabled and
with the |+windows| feature}
{only available when compiled with GUI enabled}
When nonempty describes the text to use in a label of the GUI tab
pages line. When empty and when the result is empty Vim will use a
default label. See |setting-guitablabel| for more info.
@@ -3816,8 +3825,7 @@ A jump table for the options with a short description can be found at |Q_op|.
*'guitabtooltip'* *'gtt'*
'guitabtooltip' 'gtt' string (default empty)
global
{only available when compiled with GUI enabled and
with the |+windows| feature}
{only available when compiled with GUI enabled}
When nonempty describes the text to use in a tooltip for the GUI tab
pages line. When empty Vim will use a default tooltip.
This option is otherwise just like 'guitablabel' above.
@@ -3842,8 +3850,6 @@ A jump table for the options with a short description can be found at |Q_op|.
*'helpheight'* *'hh'*
'helpheight' 'hh' number (default 20)
global
{not available when compiled without the |+windows|
feature}
Minimal initial height of the help window when it is opened with the
":help" command. The initial height of the help window is half of the
current window, or (when the 'ea' option is on) the same as other
@@ -5642,17 +5648,17 @@ A jump table for the options with a short description can be found at |Q_op|.
*'previewheight'* *'pvh'*
'previewheight' 'pvh' number (default 12)
global
{not available when compiled without the |+windows| or
|+quickfix| features}
{not available when compiled without the |+quickfix|
feature}
Default height for a preview window. Used for |:ptag| and associated
commands. Used for |CTRL-W_}| when no count is given. Not used when
'previewpopup' is set.

*'previewpopup'* *'pvp'*
'previewpopup' 'pvp' string (default empty)
global
{not available when compiled without the |+windows|,
|+textprop| or |+quickfix| feature}
{not available when compiled without the |+textprop|
or |+quickfix| feature}
When not empty a popup window is used for commands that would open a
preview window. See |preview-popup|.
Not used for the insert completion info, add "popup" to
@@ -5662,8 +5668,8 @@ A jump table for the options with a short description can be found at |Q_op|.
*'pvw'* *'nopvw'* *E590*
'previewwindow' 'pvw' boolean (default off)
local to window
{not available when compiled without the |+windows| or
|+quickfix| features}
{not available when compiled without the |+quickfix|
feature}
Identifies the preview window. Only one window can have this option
set. It's normally not set directly, but by using one of the commands
|:ptag|, |:pedit|, etc.
@@ -6781,8 +6787,6 @@ A jump table for the options with a short description can be found at |Q_op|.
*'showtabline'* *'stal'*
'showtabline' 'stal' number (default 1)
global
{not available when compiled without the |+windows|
feature}
The value of this option specifies when the line with tab page labels
will be displayed:
0: never
@@ -7079,8 +7083,6 @@ A jump table for the options with a short description can be found at |Q_op|.
*'splitbelow'* *'sb'* *'nosplitbelow'* *'nosb'*
'splitbelow' 'sb' boolean (default off)
global
{not available when compiled without the |+windows|
feature}
When on, splitting a window will put the new window below the current
one. |:split|

@@ -7401,8 +7403,6 @@ A jump table for the options with a short description can be found at |Q_op|.
*'tabline'* *'tal'*
'tabline' 'tal' string (default empty)
global
{not available when compiled without the |+windows|
feature}
When nonempty, this option determines the content of the tab pages
line at the top of the Vim window. When empty Vim will use a default
tab pages line. See |setting-tabline| for more info.
@@ -7428,8 +7428,6 @@ A jump table for the options with a short description can be found at |Q_op|.
*'tabpagemax'* *'tpm'*
'tabpagemax' 'tpm' number (default 10)
global
{not available when compiled without the |+windows|
feature}
Maximum number of tab pages to be opened by the |-p| command line
argument or the ":tab all" command. |tabpage|

@@ -8739,8 +8737,6 @@ A jump table for the options with a short description can be found at |Q_op|.
*'winheight'* *'wh'* *E591*
'winheight' 'wh' number (default 1)
global
{not available when compiled without the |+windows|
feature}
Minimal number of lines for the current window. This is not a hard
minimum, Vim will use fewer lines if there is not enough room. If the
focus goes to a window that is smaller, its size is increased, at the
@@ -8761,8 +8757,6 @@ A jump table for the options with a short description can be found at |Q_op|.
*'winfixheight'* *'wfh'* *'nowinfixheight'* *'nowfh'*
'winfixheight' 'wfh' boolean (default off)
local to window
{not available when compiled without the |+windows|
feature}
Keep the window height when windows are opened or closed and
'equalalways' is set. Also for |CTRL-W_=|. Set by default for the
|preview-window| and |quickfix-window|.
@@ -8771,17 +8765,13 @@ A jump table for the options with a short description can be found at |Q_op|.
*'winfixwidth'* *'wfw'* *'nowinfixwidth'* *'nowfw'*
'winfixwidth' 'wfw' boolean (default off)
local to window
{not available when compiled without the |+windows|
feature}
Keep the window width when windows are opened or closed and
'equalalways' is set. Also for |CTRL-W_=|.
The width may be changed anyway when running out of room.

*'winminheight'* *'wmh'*
'winminheight' 'wmh' number (default 1)
global
{not available when compiled without the |+windows|
feature}
The minimal height of a window, when it's not the current window.
This is a hard minimum, windows will never become smaller.
When set to zero, windows may be "squashed" to zero lines (i.e. just a
@@ -891,6 +891,15 @@ static struct vimoption options[] =
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
#endif
SCTX_INIT},
{"completepopup", "cpp", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
#ifdef FEAT_TEXT_PROP
(char_u *)&p_cpp, PV_NONE,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCTX_INIT},
{"completeslash", "csl", P_STRING|P_VI_DEF|P_VIM,
@@ -7826,6 +7835,12 @@ did_set_string_option(
if (parse_previewpopup(NULL) == FAIL)
errmsg = e_invarg;
}
// 'completepopup'
else if (varp == &p_cpp)
{
if (parse_completepopup(NULL) == FAIL)
errmsg = e_invarg;
}
#endif

/* Options that are a list of flags. */
@@ -503,6 +503,7 @@ EXTERN int p_fs; // 'fsync'
#endif
EXTERN int p_gd; // 'gdefault'
#ifdef FEAT_TEXT_PROP
EXTERN char_u *p_cpp; // 'completepopup'
EXTERN char_u *p_pvp; // 'previewpopup'
#endif
#ifdef FEAT_PRINTER
@@ -550,8 +550,7 @@ popup_highlight_curline(win_T *wp)

if (syn_name2id((char_u *)linehl) == 0)
linehl = "PmenuSel";
sign_define_by_name(sign_name, NULL,
(char_u *)linehl, NULL, NULL);
sign_define_by_name(sign_name, NULL, (char_u *)linehl, NULL, NULL);
}

sign_place(&sign_id, (char_u *)"popupmenu", sign_name,
@@ -1286,16 +1285,16 @@ popup_set_buffer_text(buf_T *buf, typval_T text)
}

/*
* Parse the 'previewpopup' option and apply the values to window "wp" if it
* not NULL.
* Parse the 'previewpopup' or 'completepopup' option and apply the values to
* window "wp" if it is not NULL.
* Return FAIL if the parsing fails.
*/
int
parse_previewpopup(win_T *wp)
static int
parse_popup_option(win_T *wp, int is_preview)
{
char_u *p;

for (p = p_pvp; *p != NUL; p += (*p == ',' ? 1 : 0))
for (p = is_preview ? p_pvp : p_cpp; *p != NUL; p += (*p == ',' ? 1 : 0))
{
char_u *e, *dig;
char_u *s = p;
@@ -1310,31 +1309,69 @@ parse_previewpopup(win_T *wp)
p = e + STRLEN(e);
dig = e + 1;
x = getdigits(&dig);
if (dig != p)
return FAIL;

if (STRNCMP(s, "height:", 7) == 0)
{
if (dig != p)
return FAIL;
if (wp != NULL)
{
wp->w_minheight = x;
if (is_preview)
wp->w_minheight = x;
wp->w_maxheight = x;
}
}
else if (STRNCMP(s, "width:", 6) == 0)
{
if (dig != p)
return FAIL;
if (wp != NULL)
{
wp->w_minwidth = x;
if (is_preview)
wp->w_minwidth = x;
wp->w_maxwidth = x;
}
}
else if (STRNCMP(s, "highlight:", 10) == 0)
{
if (wp != NULL)
{
int c = *p;

*p = NUL;
set_string_option_direct_in_win(wp, (char_u *)"wincolor", -1,
s + 10, OPT_FREE|OPT_LOCAL, 0);
*p = c;
}
}
else
return FAIL;
}
return OK;
}

/*
* Parse the 'previewpopup' option and apply the values to window "wp" if it
* is not NULL.
* Return FAIL if the parsing fails.
*/
int
parse_previewpopup(win_T *wp)
{
return parse_popup_option(wp, TRUE);
}

/*
* Parse the 'completepopup' option and apply the values to window "wp" if it
* is not NULL.
* Return FAIL if the parsing fails.
*/
int
parse_completepopup(win_T *wp)
{
return parse_popup_option(wp, FALSE);
}

/*
* Set w_wantline and w_wantcol for the cursor position in the current window.
* Keep at least "width" columns from the right of the screen.
@@ -1641,6 +1678,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
wp->w_popup_flags |= POPF_DRAG | POPF_RESIZE;
wp->w_popup_close = POPCLOSE_BUTTON;
add_border_left_right_padding(wp);
parse_completepopup(wp);
}

for (i = 0; i < 4; ++i)
@@ -11,6 +11,7 @@ int popup_width(win_T *wp);
int popup_extra_width(win_T *wp);
void popup_adjust_position(win_T *wp);
int parse_previewpopup(win_T *wp);
int parse_completepopup(win_T *wp);
void popup_set_wantpos_cursor(win_T *wp, int width);
void popup_set_wantpos_rowcol(win_T *wp, int row, int col);
void f_popup_clear(typval_T *argvars, typval_T *rettv);
@@ -996,7 +996,12 @@ get_wcr_attr(win_T *wp)
wcr_attr = syn_name2attr(wp->w_p_wcr);
#ifdef FEAT_TEXT_PROP
else if (WIN_IS_POPUP(wp))
wcr_attr = HL_ATTR(HLF_PNI);
{
if (wp->w_popup_flags & POPF_INFO)
wcr_attr = HL_ATTR(HLF_PSI); // PmenuSel
else
wcr_attr = HL_ATTR(HLF_PNI); // Pmenu
}
#endif
return wcr_attr;
}

0 comments on commit 62a0cb4

Please sign in to comment.
You can’t perform that action at this time.