mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 10:56:31 +00:00
vim-patch:9.0.1397: highlight for popupmenu kind and extra cannot be set (#22619)
Problem: Highlight for popupmenu kind and extra cannot be set.
Solution: Add PmenuKind, PmenuKindSel, PmenuExtra and PmenuExtraSel
highlight groups and use them. (Gianmaria Bajo, closes vim/vim#12114)
6a7c774920
Co-authored-by: Gianmaria Bajo <mg1979.git@gmail.com>
This commit is contained in:
@@ -100,6 +100,10 @@ typedef enum {
|
||||
HLF_SPL, // SpellLocal
|
||||
HLF_PNI, // popup menu normal item
|
||||
HLF_PSI, // popup menu selected item
|
||||
HLF_PNK, // popup menu normal item "kind"
|
||||
HLF_PSK, // popup menu selected item "kind"
|
||||
HLF_PNX, // popup menu normal item "menu" (extra text)
|
||||
HLF_PSX, // popup menu selected item "menu" (extra text)
|
||||
HLF_PSB, // popup menu scrollbar
|
||||
HLF_PST, // popup menu scrollbar thumb
|
||||
HLF_TP, // tabpage line
|
||||
@@ -165,6 +169,10 @@ EXTERN const char *hlf_names[] INIT(= {
|
||||
[HLF_SPL] = "SpellLocal",
|
||||
[HLF_PNI] = "Pmenu",
|
||||
[HLF_PSI] = "PmenuSel",
|
||||
[HLF_PNK] = "PmenuKind",
|
||||
[HLF_PSK] = "PmenuKindSel",
|
||||
[HLF_PNX] = "PmenuExtra",
|
||||
[HLF_PSX] = "PmenuExtraSel",
|
||||
[HLF_PSB] = "PmenuSbar",
|
||||
[HLF_PST] = "PmenuThumb",
|
||||
[HLF_TP] = "TabLine",
|
||||
|
@@ -150,6 +150,10 @@ static const char *highlight_init_both[] = {
|
||||
"default link QuickFixLine Search",
|
||||
"default link CursorLineSign SignColumn",
|
||||
"default link CursorLineFold FoldColumn",
|
||||
"default link PmenuKind Pmenu",
|
||||
"default link PmenuKindSel PmenuSel",
|
||||
"default link PmenuExtra Pmenu",
|
||||
"default link PmenuExtraSel PmenuSel",
|
||||
"default link Substitute Search",
|
||||
"default link Whitespace NonText",
|
||||
"default link MsgSeparator StatusLine",
|
||||
|
@@ -92,8 +92,9 @@ typedef enum {
|
||||
"N:CursorLineNr,G:CursorLineSign,O:CursorLineFold" \
|
||||
"r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg," \
|
||||
"W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn," \
|
||||
"-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar," \
|
||||
"X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn," \
|
||||
"-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel," \
|
||||
"[:PmenuKind,]:PmenuKindSel,{:PmenuExtra,}:PmenuExtraSel,x:PmenuSbar,X:PmenuThumb," \
|
||||
"*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn," \
|
||||
"q:QuickFixLine,0:Whitespace,I:NormalNC"
|
||||
|
||||
// Default values for 'errorformat'.
|
||||
|
@@ -407,8 +407,6 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
||||
void pum_redraw(void)
|
||||
{
|
||||
int row = 0;
|
||||
int attr_norm = win_hl_attr(curwin, HLF_PNI);
|
||||
int attr_select = win_hl_attr(curwin, HLF_PSI);
|
||||
int attr_scroll = win_hl_attr(curwin, HLF_PSB);
|
||||
int attr_thumb = win_hl_attr(curwin, HLF_PST);
|
||||
int i;
|
||||
@@ -418,9 +416,14 @@ void pum_redraw(void)
|
||||
int w;
|
||||
int thumb_pos = 0;
|
||||
int thumb_height = 1;
|
||||
int round;
|
||||
int n;
|
||||
|
||||
#define HA(hlf) (win_hl_attr(curwin, (hlf)))
|
||||
// "word" "kind" "extra text"
|
||||
const int attrsNorm[3] = { HA(HLF_PNI), HA(HLF_PNK), HA(HLF_PNX) };
|
||||
const int attrsSel[3] = { HA(HLF_PSI), HA(HLF_PSK), HA(HLF_PSX) };
|
||||
#undef HA
|
||||
|
||||
int grid_width = pum_width;
|
||||
int col_off = 0;
|
||||
bool extra_space = false;
|
||||
@@ -482,7 +485,8 @@ void pum_redraw(void)
|
||||
|
||||
for (i = 0; i < pum_height; i++) {
|
||||
int idx = i + pum_first;
|
||||
int attr = (idx == pum_selected) ? attr_select : attr_norm;
|
||||
const int *const attrs = (idx == pum_selected) ? attrsSel : attrsNorm;
|
||||
int attr = attrs[0]; // start with "word" highlight
|
||||
|
||||
grid_puts_line_start(&pum_grid, row);
|
||||
|
||||
@@ -496,26 +500,25 @@ void pum_redraw(void)
|
||||
}
|
||||
|
||||
// Display each entry, use two spaces for a Tab.
|
||||
// Do this 3 times: For the main text, kind and extra info
|
||||
// Do this 3 times:
|
||||
// 0 - main text
|
||||
// 1 - kind
|
||||
// 2 - extra info
|
||||
int grid_col = col_off;
|
||||
int totwidth = 0;
|
||||
|
||||
for (round = 1; round <= 3; round++) {
|
||||
for (int round = 0; round < 3; round++) {
|
||||
attr = attrs[round];
|
||||
width = 0;
|
||||
s = NULL;
|
||||
|
||||
switch (round) {
|
||||
case 0:
|
||||
p = pum_array[idx].pum_text; break;
|
||||
case 1:
|
||||
p = pum_array[idx].pum_text;
|
||||
break;
|
||||
|
||||
p = pum_array[idx].pum_kind; break;
|
||||
case 2:
|
||||
p = pum_array[idx].pum_kind;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
p = pum_array[idx].pum_extra;
|
||||
break;
|
||||
p = pum_array[idx].pum_extra; break;
|
||||
}
|
||||
|
||||
if (p != NULL) {
|
||||
@@ -592,17 +595,17 @@ void pum_redraw(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (round > 1) {
|
||||
if (round > 0) {
|
||||
n = pum_kind_width + 1;
|
||||
} else {
|
||||
n = 1;
|
||||
}
|
||||
|
||||
// Stop when there is nothing more to display.
|
||||
if ((round == 3)
|
||||
|| ((round == 2)
|
||||
&& (pum_array[idx].pum_extra == NULL))
|
||||
if ((round == 2)
|
||||
|| ((round == 1)
|
||||
&& (pum_array[idx].pum_extra == NULL))
|
||||
|| ((round == 0)
|
||||
&& (pum_array[idx].pum_kind == NULL)
|
||||
&& (pum_array[idx].pum_extra == NULL))
|
||||
|| (pum_base_width + n >= pum_width)) {
|
||||
|
Reference in New Issue
Block a user