@@ -115,6 +115,7 @@ struct compl_S
115115 int cp_number ; // sequence number
116116 int cp_score ; // fuzzy match score
117117 int cp_user_hlattr ; // highlight attribute to combine with
118+ int cp_user_kind_hlattr ; // highlight attribute for kind
118119};
119120
120121// values for cp_flags
@@ -206,7 +207,7 @@ static int compl_selected_item = -1;
206207
207208static int * compl_fuzzy_scores ;
208209
209- 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 user_hlattr );
210+ 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 user_hlattr , int user_kind_hlattr );
210211static void ins_compl_longest_match (compl_T * match );
211212static void ins_compl_del_pum (void );
212213static void ins_compl_files (int count , char_u * * files , int thesaurus , int flags , regmatch_T * regmatch , char_u * buf , int * dir );
@@ -746,7 +747,7 @@ ins_compl_add_infercase(
746747 if (icase )
747748 flags |= CP_ICASE ;
748749
749- res = ins_compl_add (str , len , fname , NULL , NULL , dir , flags , FALSE, -1 );
750+ res = ins_compl_add (str , len , fname , NULL , NULL , dir , flags , FALSE, -1 , -1 );
750751 vim_free (tofree );
751752 return res ;
752753}
@@ -780,7 +781,8 @@ ins_compl_add(
780781 int cdir ,
781782 int flags_arg ,
782783 int adup , // accept duplicate match
783- int user_hlattr )
784+ int user_hlattr ,
785+ int user_kind_hlattr )
784786{
785787 compl_T * match ;
786788 int dir = (cdir == 0 ? compl_direction : cdir );
@@ -845,6 +847,7 @@ ins_compl_add(
845847 match -> cp_fname = NULL ;
846848 match -> cp_flags = flags ;
847849 match -> cp_user_hlattr = user_hlattr ;
850+ match -> cp_user_kind_hlattr = user_kind_hlattr ;
848851
849852 if (cptext != NULL )
850853 {
@@ -997,7 +1000,7 @@ ins_compl_add_matches(
9971000
9981001 for (i = 0 ; i < num_matches && add_r != FAIL ; i ++ )
9991002 if ((add_r = ins_compl_add (matches [i ], -1 , NULL , NULL , NULL , dir ,
1000- CP_FAST | (icase ? CP_ICASE : 0 ), FALSE, -1 )) == OK )
1003+ CP_FAST | (icase ? CP_ICASE : 0 ), FALSE, -1 , -1 )) == OK )
10011004 // if dir was BACKWARD then honor it just once
10021005 dir = FORWARD ;
10031006 FreeWild (num_matches , matches );
@@ -1343,6 +1346,7 @@ ins_compl_build_pum(void)
13431346 compl_match_array [i ].pum_info = compl -> cp_text [CPT_INFO ];
13441347 compl_match_array [i ].pum_score = compl -> cp_score ;
13451348 compl_match_array [i ].pum_user_hlattr = compl -> cp_user_hlattr ;
1349+ compl_match_array [i ].pum_user_kind_hlattr = compl -> cp_user_kind_hlattr ;
13461350 if (compl -> cp_text [CPT_MENU ] != NULL )
13471351 compl_match_array [i ++ ].pum_extra =
13481352 compl -> cp_text [CPT_MENU ];
@@ -2844,6 +2848,14 @@ expand_by_function(int type, char_u *base)
28442848#endif // FEAT_COMPL_FUNC
28452849
28462850#if defined(FEAT_COMPL_FUNC ) || defined(FEAT_EVAL ) || defined(PROTO )
2851+
2852+ static inline int
2853+ get_user_highlight_attr (char_u * hlname )
2854+ {
2855+ if (hlname != NULL && * hlname != NUL )
2856+ return syn_name2attr (hlname );
2857+ return -1 ;
2858+ }
28472859/*
28482860 * Add a match to the list of matches from a typeval_T.
28492861 * If the given string is already in the list of completions, then return
@@ -2862,7 +2874,9 @@ ins_compl_add_tv(typval_T *tv, int dir, int fast)
28622874 typval_T user_data ;
28632875 int status ;
28642876 char_u * user_hlname ;
2877+ char_u * user_kind_hlname ;
28652878 int user_hlattr = -1 ;
2879+ int user_kind_hlattr = -1 ;
28662880
28672881 user_data .v_type = VAR_UNKNOWN ;
28682882 if (tv -> v_type == VAR_DICT && tv -> vval .v_dict != NULL )
@@ -2872,9 +2886,12 @@ ins_compl_add_tv(typval_T *tv, int dir, int fast)
28722886 cptext [CPT_MENU ] = dict_get_string (tv -> vval .v_dict , "menu" , FALSE);
28732887 cptext [CPT_KIND ] = dict_get_string (tv -> vval .v_dict , "kind" , FALSE);
28742888 cptext [CPT_INFO ] = dict_get_string (tv -> vval .v_dict , "info" , FALSE);
2889+
28752890 user_hlname = dict_get_string (tv -> vval .v_dict , "hl_group" , FALSE);
2876- if (user_hlname != NULL && * user_hlname != NUL )
2877- user_hlattr = syn_name2attr (user_hlname );
2891+ user_hlattr = get_user_highlight_attr (user_hlname );
2892+
2893+ user_kind_hlname = dict_get_string (tv -> vval .v_dict , "kind_hlgroup" , FALSE);
2894+ user_kind_hlattr = get_user_highlight_attr (user_kind_hlname );
28782895
28792896 dict_get_tv (tv -> vval .v_dict , "user_data" , & user_data );
28802897 if (dict_get_string (tv -> vval .v_dict , "icase" , FALSE) != NULL
@@ -2899,7 +2916,7 @@ ins_compl_add_tv(typval_T *tv, int dir, int fast)
28992916 return FAIL ;
29002917 }
29012918 status = ins_compl_add (word , -1 , NULL , cptext ,
2902- & user_data , dir , flags , dup , user_hlattr );
2919+ & user_data , dir , flags , dup , user_hlattr , user_kind_hlattr );
29032920 if (status != OK )
29042921 clear_tv (& user_data );
29052922 return status ;
@@ -2986,7 +3003,7 @@ set_completion(colnr_T startcol, list_T *list)
29863003 flags |= CP_ICASE ;
29873004 if (compl_orig_text == NULL || ins_compl_add (compl_orig_text ,
29883005 -1 , NULL , NULL , NULL , 0 ,
2989- flags | CP_FAST , FALSE, -1 ) != OK )
3006+ flags | CP_FAST , FALSE, -1 , -1 ) != OK )
29903007 return ;
29913008
29923009 ctrl_x_mode = CTRL_X_EVAL ;
@@ -5218,7 +5235,7 @@ ins_compl_start(void)
52185235 if (p_ic )
52195236 flags |= CP_ICASE ;
52205237 if (compl_orig_text == NULL || ins_compl_add (compl_orig_text ,
5221- -1 , NULL , NULL , NULL , 0 , flags , FALSE, -1 ) != OK )
5238+ -1 , NULL , NULL , NULL , 0 , flags , FALSE, -1 , -1 ) != OK )
52225239 {
52235240 VIM_CLEAR (compl_pattern );
52245241 compl_patternlen = 0 ;
0 commit comments