vim-patch:9.0.1774: no support for custom cmdline completion (#24808)

Problem:  no support for custom cmdline completion
Solution: Add new vimscript functions

Add the following two functions:
- getcmdcompltype() returns custom and customlist functions

- getcompletion() supports both custom and customlist

closes: vim/vim#12228

92997dda78

Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
This commit is contained in:
zeertzjq
2023-08-21 07:29:49 +08:00
committed by GitHub
parent ac99e63d73
commit 694814cdd5
7 changed files with 87 additions and 6 deletions

View File

@@ -3515,12 +3515,34 @@ void f_getcompletion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
ExpandInit(&xpc);
xpc.xp_pattern = (char *)pattern;
xpc.xp_pattern_len = strlen(xpc.xp_pattern);
xpc.xp_line = (char *)pattern;
xpc.xp_context = cmdcomplete_str_to_type(type);
if (xpc.xp_context == EXPAND_NOTHING) {
semsg(_(e_invarg2), type);
return;
}
if (xpc.xp_context == EXPAND_USER_DEFINED) {
// Must be "custom,funcname" pattern
if (strncmp(type, "custom,", 7) != 0) {
semsg(_(e_invarg2), type);
return;
}
xpc.xp_arg = (char *)(type + 7);
}
if (xpc.xp_context == EXPAND_USER_LIST) {
// Must be "customlist,funcname" pattern
if (strncmp(type, "customlist,", 11) != 0) {
semsg(_(e_invarg2), type);
return;
}
xpc.xp_arg = (char *)(type + 11);
}
if (xpc.xp_context == EXPAND_MENUS) {
set_context_in_menu_cmd(&xpc, "menu", xpc.xp_pattern, false);
xpc.xp_pattern_len = strlen(xpc.xp_pattern);