0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 9.1.0754: fixed order of items in insert-mode completion menu

Problem:  fixed order of items in insert-mode completion menu
Solution: Introduce the 'completeitemalign' option with default
          value "abbr,kind,menu" (glepnir).

Adding an new option `completeitemalign` abbr is `cia` to custom
the complete-item order in popupmenu.

closes: #14006
closes: #15760

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
glepnir
2024-10-01 20:32:12 +02:00
committed by Christian Brabandt
parent e021f39b79
commit 6a89c94a9e
20 changed files with 326 additions and 41 deletions

View File

@@ -1635,6 +1635,58 @@ expand_set_completeopt(optexpand_T *args, int *numMatches, char_u ***matches)
matches);
}
/*
* The 'completeitemalign' option is changed.
*/
char *
did_set_completeitemalign(optset_T *args UNUSED)
{
char_u *p = p_cia;
unsigned new_cia_flags = 0;
int seen[3] = { FALSE, FALSE, FALSE };
int count = 0;
char_u buf[10];
while (*p)
{
copy_option_part(&p, buf, sizeof(buf), ",");
if (count >= 3)
return e_invalid_argument;
if (STRCMP(buf, "abbr") == 0)
{
if (seen[CPT_ABBR])
return e_invalid_argument;
new_cia_flags = new_cia_flags * 10 + CPT_ABBR;
seen[CPT_ABBR] = TRUE;
count++;
}
else if (STRCMP(buf, "kind") == 0)
{
if (seen[CPT_KIND])
return e_invalid_argument;
new_cia_flags = new_cia_flags * 10 + CPT_KIND;
seen[CPT_KIND] = TRUE;
count++;
}
else if (STRCMP(buf, "menu") == 0)
{
if (seen[CPT_MENU])
return e_invalid_argument;
new_cia_flags = new_cia_flags * 10 + CPT_MENU;
seen[CPT_MENU] = TRUE;
count++;
}
else
return e_invalid_argument;
}
if (new_cia_flags == 0 || count != 3)
return e_invalid_argument;
cia_flags = new_cia_flags;
return NULL;
}
#if (defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX)) || defined(PROTO)
/*
* The 'completepopup' option is changed.