patch 9.1.0618: cannot mark deprecated attributes in completion menu

Problem:  cannot mark deprecated attributes in completion menu
Solution: add hl_group to the Dictionary of supported completion fields
          (glepnir)

closes: #15314

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index 0267d28..a33d6be 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -359,6 +359,7 @@
 	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_extrahlattr = -1;
     }
 
     // Compute the popup menu starting column
diff --git a/src/insexpand.c b/src/insexpand.c
index 2be63a5..02d29704 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -114,6 +114,7 @@
     int		cp_flags;	// CP_ values
     int		cp_number;	// sequence number
     int		cp_score;	// fuzzy match score
+    int		cp_extrahlattr;	// extra highlight group attr
 };
 
 // values for cp_flags
@@ -205,7 +206,7 @@
 
 static int	  *compl_fuzzy_scores;
 
-static int ins_compl_add(char_u *str, int len, char_u *fname, char_u **cptext, typval_T *user_data, int cdir, int flags, int adup);
+static int ins_compl_add(char_u *str, int len, char_u *fname, char_u **cptext, typval_T *user_data, int cdir, int flags, int adup, int extrahl);
 static void ins_compl_longest_match(compl_T *match);
 static void ins_compl_del_pum(void);
 static void ins_compl_files(int count, char_u **files, int thesaurus, int flags, regmatch_T *regmatch, char_u *buf, int *dir);
@@ -745,7 +746,7 @@
     if (icase)
 	flags |= CP_ICASE;
 
-    res = ins_compl_add(str, len, fname, NULL, NULL, dir, flags, FALSE);
+    res = ins_compl_add(str, len, fname, NULL, NULL, dir, flags, FALSE, -1);
     vim_free(tofree);
     return res;
 }
@@ -778,7 +779,8 @@
     typval_T	*user_data UNUSED,  // "user_data" entry or NULL
     int		cdir,
     int		flags_arg,
-    int		adup)		// accept duplicate match
+    int		adup,		    // accept duplicate match
+    int		extra_hlattr)
 {
     compl_T	*match;
     int		dir = (cdir == 0 ? compl_direction : cdir);
@@ -842,6 +844,7 @@
     else
 	match->cp_fname = NULL;
     match->cp_flags = flags;
+    match->cp_extrahlattr = extra_hlattr;
 
     if (cptext != NULL)
     {
@@ -994,7 +997,7 @@
 
     for (i = 0; i < num_matches && add_r != FAIL; i++)
 	if ((add_r = ins_compl_add(matches[i], -1, NULL, NULL, NULL, dir,
-			       CP_FAST | (icase ? CP_ICASE : 0), FALSE)) == OK)
+			       CP_FAST | (icase ? CP_ICASE : 0), FALSE, -1)) == OK)
 	    // if dir was BACKWARD then honor it just once
 	    dir = FORWARD;
     FreeWild(num_matches, matches);
@@ -1338,6 +1341,7 @@
 	    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_extrahlattr = compl->cp_extrahlattr;
 	    if (compl->cp_text[CPT_MENU] != NULL)
 		compl_match_array[i++].pum_extra =
 		    compl->cp_text[CPT_MENU];
@@ -2856,6 +2860,8 @@
     char_u	*(cptext[CPT_COUNT]);
     typval_T	user_data;
     int		status;
+    char_u	*extra_hlname;
+    int		extra_hlattr = -1;
 
     user_data.v_type = VAR_UNKNOWN;
     if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)
@@ -2865,6 +2871,10 @@
 	cptext[CPT_MENU] = dict_get_string(tv->vval.v_dict, "menu", FALSE);
 	cptext[CPT_KIND] = dict_get_string(tv->vval.v_dict, "kind", FALSE);
 	cptext[CPT_INFO] = dict_get_string(tv->vval.v_dict, "info", FALSE);
+	extra_hlname = dict_get_string(tv->vval.v_dict, "hl_group", FALSE);
+	if (extra_hlname != NULL && *extra_hlname != NUL)
+	    extra_hlattr = syn_name2attr(extra_hlname);
+
 	dict_get_tv(tv->vval.v_dict, "user_data", &user_data);
 	if (dict_get_string(tv->vval.v_dict, "icase", FALSE) != NULL
 				  && dict_get_number(tv->vval.v_dict, "icase"))
@@ -2887,7 +2897,8 @@
 	clear_tv(&user_data);
 	return FAIL;
     }
-    status = ins_compl_add(word, -1, NULL, cptext, &user_data, dir, flags, dup);
+    status = ins_compl_add(word, -1, NULL, cptext,
+				    &user_data, dir, flags, dup, extra_hlattr);
     if (status != OK)
 	clear_tv(&user_data);
     return status;
@@ -2974,7 +2985,7 @@
 	flags |= CP_ICASE;
     if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
 					      -1, NULL, NULL, NULL, 0,
-					      flags | CP_FAST, FALSE) != OK)
+					      flags | CP_FAST, FALSE, -1) != OK)
 	return;
 
     ctrl_x_mode = CTRL_X_EVAL;
@@ -5177,7 +5188,7 @@
     if (p_ic)
 	flags |= CP_ICASE;
     if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
-		-1, NULL, NULL, NULL, 0, flags, FALSE) != OK)
+		-1, NULL, NULL, NULL, 0, flags, FALSE, -1) != OK)
     {
 	VIM_CLEAR(compl_pattern);
 	compl_patternlen = 0;
diff --git a/src/popupmenu.c b/src/popupmenu.c
index c116b10..0f19c9e 100644
--- a/src/popupmenu.c
+++ b/src/popupmenu.c
@@ -510,7 +510,8 @@
     int		cells UNUSED,
     char_u	*text,
     int		textlen,
-    int		*attrs)
+    int		*attrs,
+    int		extra_attr)
 {
     int		col_start = col;
     char_u	*ptr = text;
@@ -527,6 +528,8 @@
 	else
 #endif
 	    attr = attrs[col - col_start];
+	if (extra_attr > 0)
+	    attr = hl_combine_attr(extra_attr, attr);
 	screen_puts_len(ptr, char_len, row, col, attr);
 	col += mb_ptr2cells(ptr);
 	ptr += char_len;
@@ -628,6 +631,8 @@
 	{
 	    hlf = hlfs[round];
 	    attr = highlight_attr[hlf];
+	    if (pum_array[idx].pum_extrahlattr > 0)
+		attr = hl_combine_attr(attr, pum_array[idx].pum_extrahlattr);
 	    width = 0;
 	    s = NULL;
 	    switch (round)
@@ -698,7 +703,8 @@
 				    else
 					pum_screen_puts_with_attrs(row,
 						    col - cells + 1, cells, rt,
-						       (int)STRLEN(rt), attrs);
+						       (int)STRLEN(rt), attrs,
+						       pum_array[idx].pum_extrahlattr);
 
 				    vim_free(rt_start);
 				}
@@ -732,7 +738,8 @@
 				    screen_puts_len(st, size, row, col, attr);
 				else
 				    pum_screen_puts_with_attrs(row, col, cells,
-							      st, size, attrs);
+							      st, size, attrs,
+							      pum_array[idx].pum_extrahlattr);
 
 				vim_free(st);
 			    }
diff --git a/src/structs.h b/src/structs.h
index 6309211..2e8efa8 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -4466,12 +4466,13 @@
  */
 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
+    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_extrahlattr;  // extra highlight group attr for combine
 } pumitem_T;
 
 /*
diff --git a/src/testdir/dumps/Test_pum_highlights_12.dump b/src/testdir/dumps/Test_pum_highlights_12.dump
new file mode 100644
index 0000000..a0d2b49
--- /dev/null
+++ b/src/testdir/dumps/Test_pum_highlights_12.dump
@@ -0,0 +1,20 @@
+|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#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
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |U|s|e|r| |d|e|f|i|n|e|d| |c|o|m|p|l|e|t|i|o|n| |(|^|U|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |3| +0#0000000&@26
diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim
index d930133..30cabf9 100644
--- a/src/testdir/test_popup.vim
+++ b/src/testdir/test_popup.vim
@@ -1499,4 +1499,33 @@
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_pum_extrahl()
+  CheckScreendump
+  let lines =<< trim END
+    hi StrikeFake ctermfg=9
+    func CompleteFunc( findstart, base )
+      if a:findstart
+        return 0
+      endif
+      return {
+            \ 'words': [
+            \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'extrahl': 'StrikeFake' },
+            \ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', },
+            \ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'extrahl': 'StrikeFake' },
+            \]}
+    endfunc
+    set completeopt=menu
+    set completefunc=CompleteFunc
+  END
+  call writefile(lines, 'Xscript', 'D')
+  let buf = RunVimInTerminal('-S Xscript', {})
+  call TermWait(buf)
+  call term_sendkeys(buf, "iaw\<C-X>\<C-u>")
+  call TermWait(buf, 50)
+  call VerifyScreenDump(buf, 'Test_pum_highlights_12', {})
+  call term_sendkeys(buf, "\<C-E>\<Esc>u")
+  call TermWait(buf)
+  call StopVimInTerminal(buf)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 1a267fd..fd33dab 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    618,
+/**/
     617,
 /**/
     616,