diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-08-21 07:29:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-21 07:29:49 +0800 |
commit | 694814cdd54ac245d1f4d2c28dce7e9132fcb616 (patch) | |
tree | 70258002f855c8b921998bc1d90b992840dc5a1f /src/nvim/cmdexpand.c | |
parent | ac99e63d73df84cc20766ad86655724f3a0345b9 (diff) | |
download | rneovim-694814cdd54ac245d1f4d2c28dce7e9132fcb616.tar.gz rneovim-694814cdd54ac245d1f4d2c28dce7e9132fcb616.tar.bz2 rneovim-694814cdd54ac245d1f4d2c28dce7e9132fcb616.zip |
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
https://github.com/vim/vim/commit/92997dda789ad8061841128cbc99b15ec0374411
Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Diffstat (limited to 'src/nvim/cmdexpand.c')
-rw-r--r-- | src/nvim/cmdexpand.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index eb9394c8ff..9470f77ab5 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -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); |