aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/cmdexpand.c3
-rw-r--r--src/nvim/insexpand.c19
-rw-r--r--src/nvim/popupmenu.c27
-rw-r--r--src/nvim/popupmenu.h2
4 files changed, 31 insertions, 20 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index b37a1d690f..45648fc15f 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -357,7 +357,8 @@ static int cmdline_pum_create(CmdlineInfo *ccline, expand_T *xp, char **matches,
.pum_info = NULL,
.pum_extra = NULL,
.pum_kind = NULL,
- .pum_user_hlattr = -1,
+ .pum_user_abbr_hlattr = -1,
+ .pum_user_kind_hlattr = -1,
};
}
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index 84dd55fa78..2482cef7a1 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -164,7 +164,7 @@ struct compl_S {
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_abbr_hlattr; ///< highlight attribute for abbr
int cp_user_kind_hlattr; ///< highlight attribute for kind
};
@@ -798,7 +798,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 user_hlattr, int user_kind_hlattr)
+ int flags_arg, const bool adup, int user_abbr_hlattr, int user_kind_hlattr)
FUNC_ATTR_NONNULL_ARG(1)
{
compl_T *match;
@@ -864,7 +864,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_user_hlattr = user_hlattr;
+ match->cp_user_abbr_hlattr = user_abbr_hlattr;
match->cp_user_kind_hlattr = user_kind_hlattr;
if (cptext != NULL) {
@@ -1268,7 +1268,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_user_hlattr = comp->cp_user_hlattr;
+ compl_match_array[i].pum_user_abbr_hlattr = comp->cp_user_abbr_hlattr;
compl_match_array[i].pum_user_kind_hlattr = comp->cp_user_kind_hlattr;
if (comp->cp_text[CPT_MENU] != NULL) {
compl_match_array[i++].pum_extra = comp->cp_text[CPT_MENU];
@@ -2567,9 +2567,9 @@ 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 *user_hlname = NULL;
+ char *user_abbr_hlname = NULL;
+ int user_abbr_hlattr = -1;
char *user_kind_hlname = NULL;
- int user_hlattr = -1;
int user_kind_hlattr = -1;
typval_T user_data;
@@ -2581,8 +2581,8 @@ static int ins_compl_add_tv(typval_T *const tv, const Direction dir, bool fast)
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);
- user_hlname = tv_dict_get_string(tv->vval.v_dict, "hl_group", false);
- user_hlattr = get_user_highlight_attr(user_hlname);
+ user_abbr_hlname = tv_dict_get_string(tv->vval.v_dict, "abbr_hlgroup", false);
+ user_abbr_hlattr = get_user_highlight_attr(user_abbr_hlname);
user_kind_hlname = tv_dict_get_string(tv->vval.v_dict, "kind_hlgroup", false);
user_kind_hlattr = get_user_highlight_attr(user_kind_hlname);
@@ -2608,7 +2608,8 @@ 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_hlattr, user_kind_hlattr);
+ &user_data, dir, flags, dup,
+ user_abbr_hlattr, user_kind_hlattr);
if (status != OK) {
tv_clear(&user_data);
}
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c
index ddcb819054..ed4c9f3056 100644
--- a/src/nvim/popupmenu.c
+++ b/src/nvim/popupmenu.c
@@ -654,11 +654,14 @@ void pum_redraw(void)
int item_type = order[j];
hlf = hlfs[item_type];
attr = win_hl_attr(curwin, (int)hlf);
- if (pum_array[idx].pum_user_hlattr > 0) {
- attr = hl_combine_attr(attr, pum_array[idx].pum_user_hlattr);
+ int orig_attr = attr;
+ int user_abbr_hlattr = pum_array[idx].pum_user_abbr_hlattr;
+ int 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 && pum_array[idx].pum_user_kind_hlattr > 0) {
- attr = hl_combine_attr(attr, pum_array[idx].pum_user_kind_hlattr);
+ if (item_type == CPT_KIND && user_kind_hlattr > 0) {
+ attr = hl_combine_attr(attr, user_kind_hlattr);
}
int width = 0;
char *s = NULL;
@@ -684,8 +687,10 @@ void pum_redraw(void)
*p = saved;
}
- int user_hlattr = pum_array[idx].pum_user_hlattr;
- int *attrs = pum_compute_text_attrs(st, hlf, user_hlattr);
+ int *attrs = NULL;
+ if (item_type == CPT_ABBR) {
+ attrs = pum_compute_text_attrs(st, hlf, user_abbr_hlattr);
+ }
if (pum_rl) {
char *rt = reverse_text(st);
@@ -727,7 +732,9 @@ void pum_redraw(void)
grid_col += width;
}
- xfree(attrs);
+ if (attrs != NULL) {
+ XFREE_CLEAR(attrs);
+ }
if (*p != TAB) {
break;
@@ -769,10 +776,12 @@ void pum_redraw(void)
}
if (pum_rl) {
- grid_line_fill(col_off - basic_width - n + 1, grid_col + 1, schar_from_ascii(' '), attr);
+ grid_line_fill(col_off - basic_width - n + 1, grid_col + 1,
+ schar_from_ascii(' '), orig_attr);
grid_col = col_off - basic_width - n;
} else {
- grid_line_fill(grid_col, col_off + basic_width + n, schar_from_ascii(' '), attr);
+ grid_line_fill(grid_col, col_off + basic_width + n,
+ schar_from_ascii(' '), orig_attr);
grid_col = col_off + basic_width + n;
}
totwidth = basic_width + n;
diff --git a/src/nvim/popupmenu.h b/src/nvim/popupmenu.h
index f7eb0240ae..40bd42ee17 100644
--- a/src/nvim/popupmenu.h
+++ b/src/nvim/popupmenu.h
@@ -16,7 +16,7 @@ typedef struct {
char *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_abbr_hlattr; ///< highlight attribute for abbr
int pum_user_kind_hlattr; ///< highlight attribute for kind
} pumitem_T;