aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/insexpand.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/insexpand.c')
-rw-r--r--src/nvim/insexpand.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index 46114b2973..f72167cfcb 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -39,6 +39,7 @@
#include "nvim/globals.h"
#include "nvim/highlight.h"
#include "nvim/highlight_defs.h"
+#include "nvim/highlight_group.h"
#include "nvim/indent.h"
#include "nvim/indent_c.h"
#include "nvim/insexpand.h"
@@ -170,6 +171,7 @@ struct compl_S {
int cp_flags; ///< CP_ values
int cp_number; ///< sequence number
int cp_score; ///< fuzzy match score
+ int cp_extrahlattr; ///< extra extra highlight group attr
};
/// state information used for getting the next set of insert completion
@@ -762,7 +764,7 @@ int ins_compl_add_infercase(char *str_arg, int len, bool icase, char *fname, Dir
flags |= CP_ICASE;
}
- int res = ins_compl_add(str, len, fname, NULL, false, NULL, dir, flags, false);
+ int res = ins_compl_add(str, len, fname, NULL, false, NULL, dir, flags, false, -1);
xfree(tofree);
return res;
}
@@ -802,7 +804,7 @@ static inline void free_cptext(char *const *const cptext)
/// returned in case of error.
static int ins_compl_add(char *const str, int len, char *const fname, char *const *const cptext,
const bool cptext_allocated, typval_T *user_data, const Direction cdir,
- int flags_arg, const bool adup)
+ int flags_arg, const bool adup, int extra_hlattr)
FUNC_ATTR_NONNULL_ARG(1)
{
compl_T *match;
@@ -868,6 +870,7 @@ static int ins_compl_add(char *const str, int len, char *const fname, char *cons
match->cp_fname = NULL;
}
match->cp_flags = flags;
+ match->cp_extrahlattr = extra_hlattr;
if (cptext != NULL) {
int i;
@@ -1001,7 +1004,7 @@ static void ins_compl_add_matches(int num_matches, char **matches, int icase)
for (int i = 0; i < num_matches && add_r != FAIL; i++) {
if ((add_r = ins_compl_add(matches[i], -1, NULL, NULL, false, NULL, dir,
CP_FAST | (icase ? CP_ICASE : 0),
- false)) == OK) {
+ false, -1)) == OK) {
// If dir was BACKWARD then honor it just once.
dir = FORWARD;
}
@@ -1268,6 +1271,7 @@ static int ins_compl_build_pum(void)
compl_match_array[i].pum_kind = comp->cp_text[CPT_KIND];
compl_match_array[i].pum_info = comp->cp_text[CPT_INFO];
compl_match_array[i].pum_score = comp->cp_score;
+ compl_match_array[i].pum_extrahlattr = comp->cp_extrahlattr;
if (comp->cp_text[CPT_MENU] != NULL) {
compl_match_array[i++].pum_extra = comp->cp_text[CPT_MENU];
} else {
@@ -2552,6 +2556,8 @@ static int ins_compl_add_tv(typval_T *const tv, const Direction dir, bool fast)
bool empty = false;
int flags = fast ? CP_FAST : 0;
char *(cptext[CPT_COUNT]);
+ char *extra_hlname = NULL;
+ int extra_hlattr = -1;
typval_T user_data;
user_data.v_type = VAR_UNKNOWN;
@@ -2561,6 +2567,10 @@ static int ins_compl_add_tv(typval_T *const tv, const Direction dir, bool fast)
cptext[CPT_MENU] = tv_dict_get_string(tv->vval.v_dict, "menu", true);
cptext[CPT_KIND] = tv_dict_get_string(tv->vval.v_dict, "kind", true);
cptext[CPT_INFO] = tv_dict_get_string(tv->vval.v_dict, "info", true);
+ extra_hlname = tv_dict_get_string(tv->vval.v_dict, "hl_group", false);
+ if (extra_hlname != NULL && *extra_hlname != NUL) {
+ extra_hlattr = syn_name2attr(extra_hlname);
+ }
tv_dict_get_tv(tv->vval.v_dict, "user_data", &user_data);
if (tv_dict_get_number(tv->vval.v_dict, "icase")) {
@@ -2582,7 +2592,7 @@ static int ins_compl_add_tv(typval_T *const tv, const Direction dir, bool fast)
return FAIL;
}
int status = ins_compl_add((char *)word, -1, NULL, cptext, true,
- &user_data, dir, flags, dup);
+ &user_data, dir, flags, dup, extra_hlattr);
if (status != OK) {
tv_clear(&user_data);
}
@@ -2675,7 +2685,7 @@ static void set_completion(colnr_T startcol, list_T *list)
flags |= CP_ICASE;
}
if (ins_compl_add(compl_orig_text, -1, NULL, NULL, false, NULL, 0,
- flags | CP_FAST, false) != OK) {
+ flags | CP_FAST, false, -1) != OK) {
return;
}
@@ -3420,7 +3430,7 @@ static void get_next_bufname_token(void)
char *tail = path_tail(b->b_sfname);
if (strncmp(tail, compl_orig_text, strlen(compl_orig_text)) == 0) {
ins_compl_add(tail, (int)strlen(tail), NULL, NULL, false, NULL, 0,
- p_ic ? CP_ICASE : 0, false);
+ p_ic ? CP_ICASE : 0, false, -1);
}
}
}
@@ -4458,7 +4468,7 @@ static int ins_compl_start(void)
flags |= CP_ICASE;
}
if (ins_compl_add(compl_orig_text, -1, NULL, NULL, false, NULL, 0,
- flags, false) != OK) {
+ flags, false, -1) != OK) {
XFREE_CLEAR(compl_pattern);
compl_patternlen = 0;
XFREE_CLEAR(compl_orig_text);