mirror of
https://github.com/vim/vim.git
synced 2025-07-04 23:07:33 -04:00
patch 9.1.0771: completion attribute hl_group is confusing
Problem: Currently completion attribute hl_group is combined with all items, which is redundant and confusing with kind_hlgroup Solution: Renamed to abbr_hlgroup and combine it only with the abbr item (glepnir). closes: #15818 Signed-off-by: glepnir <glephunter@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
0407d621bb
commit
0fe17f8ffb
@ -1183,12 +1183,12 @@ items:
|
||||
user_data custom data which is associated with the item and
|
||||
available in |v:completed_item|; it can be any type;
|
||||
defaults to an empty string
|
||||
hl_group an additional highlight group whose attributes are
|
||||
abbr_hlgroup an additional highlight group whose attributes are
|
||||
combined with |hl-PmenuSel| and |hl-Pmenu| or
|
||||
|hl-PmenuMatchSel| and |hl-PmenuMatch| highlight
|
||||
attributes in the popup menu to apply cterm and gui
|
||||
properties (with higher priority) like strikethrough
|
||||
to the completion items
|
||||
to the completion items abbreviation
|
||||
kind_hlgroup an additional highlight group specifically for setting
|
||||
the highlight attributes of the completion kind. When
|
||||
this field is present, it will override the
|
||||
|
@ -360,7 +360,8 @@ cmdline_pum_create(
|
||||
compl_match_array[i].pum_info = NULL;
|
||||
compl_match_array[i].pum_extra = NULL;
|
||||
compl_match_array[i].pum_kind = NULL;
|
||||
compl_match_array[i].pum_user_hlattr = -1;
|
||||
compl_match_array[i].pum_user_abbr_hlattr = -1;
|
||||
compl_match_array[i].pum_user_kind_hlattr = -1;
|
||||
}
|
||||
|
||||
// Compute the popup menu starting column
|
||||
|
@ -100,13 +100,14 @@ struct compl_S
|
||||
#ifdef FEAT_EVAL
|
||||
typval_T cp_user_data;
|
||||
#endif
|
||||
char_u *cp_fname; // file containing the match, allocated when
|
||||
// cp_flags has CP_FREE_FNAME
|
||||
int cp_flags; // CP_ values
|
||||
int cp_number; // sequence number
|
||||
int cp_score; // fuzzy match score
|
||||
int cp_user_hlattr; // highlight attribute to combine with
|
||||
int cp_user_kind_hlattr; // highlight attribute for kind
|
||||
char_u *cp_fname; // file containing the match, allocated when
|
||||
// cp_flags has CP_FREE_FNAME
|
||||
int cp_flags; // CP_ values
|
||||
int cp_number; // sequence number
|
||||
int cp_score; // fuzzy match score
|
||||
int cp_user_abbr_hlattr; // highlight attribute to combine with
|
||||
// for abbr.
|
||||
int cp_user_kind_hlattr; // highlight attribute for kind
|
||||
};
|
||||
|
||||
// values for cp_flags
|
||||
@ -772,7 +773,7 @@ ins_compl_add(
|
||||
int cdir,
|
||||
int flags_arg,
|
||||
int adup, // accept duplicate match
|
||||
int user_hlattr,
|
||||
int user_abbr_hlattr,
|
||||
int user_kind_hlattr)
|
||||
{
|
||||
compl_T *match;
|
||||
@ -837,7 +838,7 @@ ins_compl_add(
|
||||
else
|
||||
match->cp_fname = NULL;
|
||||
match->cp_flags = flags;
|
||||
match->cp_user_hlattr = user_hlattr;
|
||||
match->cp_user_abbr_hlattr = user_abbr_hlattr;
|
||||
match->cp_user_kind_hlattr = user_kind_hlattr;
|
||||
|
||||
if (cptext != NULL)
|
||||
@ -1335,7 +1336,7 @@ ins_compl_build_pum(void)
|
||||
compl_match_array[i].pum_kind = compl->cp_text[CPT_KIND];
|
||||
compl_match_array[i].pum_info = compl->cp_text[CPT_INFO];
|
||||
compl_match_array[i].pum_score = compl->cp_score;
|
||||
compl_match_array[i].pum_user_hlattr = compl->cp_user_hlattr;
|
||||
compl_match_array[i].pum_user_abbr_hlattr = compl->cp_user_abbr_hlattr;
|
||||
compl_match_array[i].pum_user_kind_hlattr = compl->cp_user_kind_hlattr;
|
||||
if (compl->cp_text[CPT_MENU] != NULL)
|
||||
compl_match_array[i++].pum_extra =
|
||||
@ -2863,9 +2864,9 @@ ins_compl_add_tv(typval_T *tv, int dir, int fast)
|
||||
char_u *(cptext[CPT_COUNT]);
|
||||
typval_T user_data;
|
||||
int status;
|
||||
char_u *user_hlname;
|
||||
char_u *user_abbr_hlname;
|
||||
int user_abbr_hlattr = -1;
|
||||
char_u *user_kind_hlname;
|
||||
int user_hlattr = -1;
|
||||
int user_kind_hlattr = -1;
|
||||
|
||||
user_data.v_type = VAR_UNKNOWN;
|
||||
@ -2877,8 +2878,8 @@ ins_compl_add_tv(typval_T *tv, int dir, int fast)
|
||||
cptext[CPT_KIND] = dict_get_string(tv->vval.v_dict, "kind", FALSE);
|
||||
cptext[CPT_INFO] = dict_get_string(tv->vval.v_dict, "info", FALSE);
|
||||
|
||||
user_hlname = dict_get_string(tv->vval.v_dict, "hl_group", FALSE);
|
||||
user_hlattr = get_user_highlight_attr(user_hlname);
|
||||
user_abbr_hlname = dict_get_string(tv->vval.v_dict, "abbr_hlgroup", FALSE);
|
||||
user_abbr_hlattr = get_user_highlight_attr(user_abbr_hlname);
|
||||
|
||||
user_kind_hlname = dict_get_string(tv->vval.v_dict, "kind_hlgroup", FALSE);
|
||||
user_kind_hlattr = get_user_highlight_attr(user_kind_hlname);
|
||||
@ -2906,7 +2907,8 @@ ins_compl_add_tv(typval_T *tv, int dir, int fast)
|
||||
return FAIL;
|
||||
}
|
||||
status = ins_compl_add(word, -1, NULL, cptext,
|
||||
&user_data, dir, flags, dup, user_hlattr, user_kind_hlattr);
|
||||
&user_data, dir, flags, dup,
|
||||
user_abbr_hlattr, user_kind_hlattr);
|
||||
if (status != OK)
|
||||
clear_tv(&user_data);
|
||||
return status;
|
||||
|
@ -586,6 +586,8 @@ pum_redraw(void)
|
||||
pum_extra_width };
|
||||
int basic_width; // first item width
|
||||
int last_isabbr = FALSE;
|
||||
int user_abbr_hlattr, user_kind_hlattr;
|
||||
int orig_attr = -1;
|
||||
|
||||
hlf_T hlfsNorm[3];
|
||||
hlf_T hlfsSel[3];
|
||||
@ -660,10 +662,13 @@ pum_redraw(void)
|
||||
item_type = order[j];
|
||||
hlf = hlfs[item_type];
|
||||
attr = highlight_attr[hlf];
|
||||
if (pum_array[idx].pum_user_hlattr > 0)
|
||||
attr = hl_combine_attr(attr, pum_array[idx].pum_user_hlattr);
|
||||
if (item_type == CPT_KIND && pum_array[idx].pum_user_kind_hlattr > 0)
|
||||
attr = hl_combine_attr(attr, pum_array[idx].pum_user_kind_hlattr);
|
||||
orig_attr = attr;
|
||||
user_abbr_hlattr = pum_array[idx].pum_user_abbr_hlattr;
|
||||
user_kind_hlattr = pum_array[idx].pum_user_kind_hlattr;
|
||||
if (item_type == CPT_ABBR && user_abbr_hlattr > 0)
|
||||
attr = hl_combine_attr(attr, user_abbr_hlattr);
|
||||
if (item_type == CPT_KIND && user_kind_hlattr > 0)
|
||||
attr = hl_combine_attr(attr, user_kind_hlattr);
|
||||
width = 0;
|
||||
s = NULL;
|
||||
p = pum_get_item(idx, item_type);
|
||||
@ -678,7 +683,7 @@ pum_redraw(void)
|
||||
// Display the text that fits or comes before a Tab.
|
||||
// First convert it to printable characters.
|
||||
char_u *st;
|
||||
int *attrs;
|
||||
int *attrs = NULL;
|
||||
int saved = *p;
|
||||
|
||||
if (saved != NUL)
|
||||
@ -687,9 +692,9 @@ pum_redraw(void)
|
||||
if (saved != NUL)
|
||||
*p = saved;
|
||||
|
||||
int user_hlattr = pum_array[idx].pum_user_hlattr;
|
||||
attrs = pum_compute_text_attrs(st, hlf, user_hlattr);
|
||||
|
||||
if (item_type == CPT_ABBR)
|
||||
attrs = pum_compute_text_attrs(st, hlf,
|
||||
user_abbr_hlattr);
|
||||
#ifdef FEAT_RIGHTLEFT
|
||||
if (pum_rl)
|
||||
{
|
||||
@ -771,7 +776,11 @@ pum_redraw(void)
|
||||
col += width;
|
||||
}
|
||||
|
||||
vim_free(attrs);
|
||||
if (attrs != NULL)
|
||||
{
|
||||
vim_free(attrs);
|
||||
attrs = NULL;
|
||||
}
|
||||
|
||||
if (*p != TAB)
|
||||
break;
|
||||
@ -781,13 +790,14 @@ pum_redraw(void)
|
||||
if (pum_rl)
|
||||
{
|
||||
screen_puts_len((char_u *)" ", 2, row, col - 1,
|
||||
attr);
|
||||
orig_attr);
|
||||
col -= 2;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
screen_puts_len((char_u *)" ", 2, row, col, attr);
|
||||
screen_puts_len((char_u *)" ", 2, row, col,
|
||||
orig_attr);
|
||||
col += 2;
|
||||
}
|
||||
totwidth += 2;
|
||||
@ -823,7 +833,7 @@ pum_redraw(void)
|
||||
#endif
|
||||
{
|
||||
screen_fill(row, row + 1, col, pum_col + basic_width + n,
|
||||
' ', ' ', attr);
|
||||
' ', ' ', orig_attr);
|
||||
col = pum_col + basic_width + n;
|
||||
}
|
||||
totwidth = basic_width + n;
|
||||
|
@ -4468,14 +4468,14 @@ typedef struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char_u *pum_text; // main menu text
|
||||
char_u *pum_kind; // extra kind text (may be truncated)
|
||||
char_u *pum_extra; // extra menu text (may be truncated)
|
||||
char_u *pum_info; // extra info
|
||||
int pum_score; // fuzzy match score
|
||||
int pum_idx; // index of item before sorting by score
|
||||
int pum_user_hlattr; // highlight attribute to combine with
|
||||
int pum_user_kind_hlattr; // highlight attribute for kind
|
||||
char_u *pum_text; // main menu text
|
||||
char_u *pum_kind; // extra kind text (may be truncated)
|
||||
char_u *pum_extra; // extra menu text (may be truncated)
|
||||
char_u *pum_info; // extra info
|
||||
int pum_score; // fuzzy match score
|
||||
int pum_idx; // index of item before sorting by score
|
||||
int pum_user_abbr_hlattr; // highlight attribute to combine with
|
||||
int pum_user_kind_hlattr; // highlight attribute for kind
|
||||
} pumitem_T;
|
||||
|
||||
/*
|
||||
@ -5086,4 +5086,3 @@ typedef struct
|
||||
|
||||
#define KEYVALUE_ENTRY(k, v) \
|
||||
{(k), (v), STRLEN_LITERAL(v)}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|a+0&#ffffff0|w|o|r|d|1> @68
|
||||
|a+0#ff404010#e0e0e08|w|o|r|d|1| |W| |e|x|t|r|a| |t|e|x|t| |1| | +0#4040ff13#ffffff0@52
|
||||
|a+0#ff404010#e0e0e08|w|o|r|d|1| +0#0000001&|W| |e|x|t|r|a| |t|e|x|t| |1| | +0#4040ff13#ffffff0@52
|
||||
|a+0#0000001#ffd7ff255|w|o|r|d|2| |W| |e|x|t|r|a| |t|e|x|t| |2| | +0#4040ff13#ffffff0@52
|
||||
|你*0#ff404010#ffd7ff255|好| +&@2|W| |e|x|t|r|a| |t|e|x|t| |3| | +0#4040ff13#ffffff0@52
|
||||
|你*0#ff404010#ffd7ff255|好| +0#0000001&@2|W| |e|x|t|r|a| |t|e|x|t| |3| | +0#4040ff13#ffffff0@52
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|
@ -1,7 +1,7 @@
|
||||
|a+0&#ffffff0|w|o|r|d|1> @68
|
||||
|a+8#ff404010#e0e0e08|w|o+0&&|r|d|1| |W| |e|x|t|r|a| |t|e|x|t| |1| | +0#4040ff13#ffffff0@52
|
||||
|a+8#ff404010#e0e0e08|w|o+0&&|r|d|1| +0#0000001&|W| |e|x|t|r|a| |t|e|x|t| |1| | +0#4040ff13#ffffff0@52
|
||||
|a+8#0000e05#ffd7ff255|w|o+0#0000001&|r|d|2| |W| |e|x|t|r|a| |t|e|x|t| |2| | +0#4040ff13#ffffff0@52
|
||||
|你*0#ff404010#ffd7ff255|好| +&@2|W| |e|x|t|r|a| |t|e|x|t| |3| | +0#4040ff13#ffffff0@52
|
||||
|你*0#ff404010#ffd7ff255|好| +0#0000001&@2|W| |e|x|t|r|a| |t|e|x|t| |3| | +0#4040ff13#ffffff0@52
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|
@ -1,7 +1,7 @@
|
||||
|a+0&#ffffff0|w|o|r|d|2> @68
|
||||
|a+8#ff404010#ffd7ff255|w|o+0&&|r|d|1| |W| |e|x|t|r|a| |t|e|x|t| |1| | +0#4040ff13#ffffff0@52
|
||||
|a+8#ff404010#ffd7ff255|w|o+0&&|r|d|1| +0#0000001&|W| |e|x|t|r|a| |t|e|x|t| |1| | +0#4040ff13#ffffff0@52
|
||||
|a+8#00e0e07#e0e0e08|w|o+0#0000001&|r|d|2| |W| |e|x|t|r|a| |t|e|x|t| |2| | +0#4040ff13#ffffff0@52
|
||||
|你*0#ff404010#ffd7ff255|好| +&@2|W| |e|x|t|r|a| |t|e|x|t| |3| | +0#4040ff13#ffffff0@52
|
||||
|你*0#ff404010#ffd7ff255|好| +0#0000001&@2|W| |e|x|t|r|a| |t|e|x|t| |3| | +0#4040ff13#ffffff0@52
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|
@ -1,7 +1,7 @@
|
||||
|a+0&#ffffff0|w|o|r|d|1> @68
|
||||
|a+0#ff404010#e0e0e08|w|o|r|d|1| |v+0#ffff4012&|a|r|i|a|b|l|e| |e+0#ff404010&|x|t|r|a| |t|e|x|t| |1| | +0#4040ff13#ffffff0@45
|
||||
|a+0#0000001#ffd7ff255|w|o|r|d|2| |f+0#4040ff13&|u|n|c|t|i|o|n| |e+0#0000001&|x|t|r|a| |t|e|x|t| |2| | +0#4040ff13#ffffff0@45
|
||||
|你*0#0000001#ffd7ff255|好| +&@2|c+0#40ff4011&|l|a|s@1| @3|e+0#0000001&|x|t|r|a| |t|e|x|t| |3| | +0#4040ff13#ffffff0@45
|
||||
|a+0#ff404010#e0e0e08|w|o|r|d|1| +0#0000001&|v+0#ffff4012&|a|r|i|a|b|l|e| +0#0000001&|e|x|t|r|a| |t|e|x|t| |1| | +0#4040ff13#ffffff0@45
|
||||
|a+0#0000001#ffd7ff255|w|o|r|d|2| |f+0#4040ff13&|u|n|c|t|i|o|n| +0#0000001&|e|x|t|r|a| |t|e|x|t| |2| | +0#4040ff13#ffffff0@45
|
||||
|你*0#0000001#ffd7ff255|好| +&@2|c+0#40ff4011&|l|a|s@1| +0#0000001&@3|e|x|t|r|a| |t|e|x|t| |3| | +0#4040ff13#ffffff0@45
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|
@ -1504,7 +1504,7 @@ func Test_pum_highlights_match()
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
func Test_pum_user_hl_group()
|
||||
func Test_pum_user_abbr_hlgroup()
|
||||
CheckScreendump
|
||||
let lines =<< trim END
|
||||
func CompleteFunc( findstart, base )
|
||||
@ -1513,9 +1513,9 @@ func Test_pum_user_hl_group()
|
||||
endif
|
||||
return {
|
||||
\ 'words': [
|
||||
\ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'hl_group': 'StrikeFake' },
|
||||
\ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
|
||||
\ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', },
|
||||
\ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'hl_group': 'StrikeFake' },
|
||||
\ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
|
||||
\]}
|
||||
endfunc
|
||||
set completeopt=menu
|
||||
@ -1557,7 +1557,7 @@ func Test_pum_user_kind_hlgroup()
|
||||
endif
|
||||
return {
|
||||
\ 'words': [
|
||||
\ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'variable', 'kind_hlgroup': 'KindVar', 'hl_group': 'StrikeFake' },
|
||||
\ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'variable', 'kind_hlgroup': 'KindVar', 'abbr_hlgroup': 'StrikeFake' },
|
||||
\ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'function', 'kind_hlgroup': 'KindFunc' },
|
||||
\ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'class', 'kind_hlgroup': 'KindClass' },
|
||||
\]}
|
||||
|
@ -704,6 +704,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
771,
|
||||
/**/
|
||||
770,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user