summaryrefslogtreecommitdiffstats
path: root/src/cmdexpand.c
diff options
context:
space:
mode:
authorShougo Matsushita <Shougo.Matsu@gmail.com>2023-08-20 20:55:55 +0200
committerChristian Brabandt <cb@256bit.org>2023-08-20 20:55:55 +0200
commit92997dda789ad8061841128cbc99b15ec0374411 (patch)
tree47a00691b428554c6d6bba0126e7b3874d28b135 /src/cmdexpand.c
parent19a3bc3addf9b4aa8150a01b11b4249c67d15d3b (diff)
patch 9.0.1774: no support for custom cmdline completionv9.0.1774
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: #12228 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Diffstat (limited to 'src/cmdexpand.c')
-rw-r--r--src/cmdexpand.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index b8c2711b28..6ffef0c3e7 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -4022,6 +4022,7 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
{
xpc.xp_pattern = pat;
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
+ xpc.xp_line = pat;
xpc.xp_context = cmdcomplete_str_to_type(type);
if (xpc.xp_context == EXPAND_NOTHING)
@@ -4030,6 +4031,30 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
return;
}
+ if (xpc.xp_context == EXPAND_USER_DEFINED)
+ {
+ // Must be "custom,funcname" pattern
+ if (STRNCMP(type, "custom,", 7) != 0)
+ {
+ semsg(_(e_invalid_argument_str), type);
+ return;
+ }
+
+ xpc.xp_arg = type + 7;
+ }
+
+ if (xpc.xp_context == EXPAND_USER_LIST)
+ {
+ // Must be "customlist,funcname" pattern
+ if (STRNCMP(type, "customlist,", 11) != 0)
+ {
+ semsg(_(e_invalid_argument_str), type);
+ return;
+ }
+
+ xpc.xp_arg = type + 11;
+ }
+
# if defined(FEAT_MENU)
if (xpc.xp_context == EXPAND_MENUS)
{