Mercurial > vim
comparison src/ex_getln.c @ 32947:306f51627f50 v9.0.1774
commit 92997dda789ad8061841128cbc99b15ec0374411
Author: Shougo Matsushita <Shougo.Matsu@gmail.com>
Date: Sun Aug 20 20:55:55 2023 +0200
patch 9.0.1774: no support for custom cmdline completion
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>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 20 Aug 2023 22:11:05 +0200 |
parents | c18185d165cc |
children | 29b2193466e0 |
comparison
equal
deleted
inserted
replaced
32946:50dd2a4504d7 | 32947:306f51627f50 |
---|---|
4150 */ | 4150 */ |
4151 static char_u * | 4151 static char_u * |
4152 get_cmdline_completion(void) | 4152 get_cmdline_completion(void) |
4153 { | 4153 { |
4154 cmdline_info_T *p; | 4154 cmdline_info_T *p; |
4155 char_u *buffer; | |
4155 | 4156 |
4156 if (cmdline_star > 0) | 4157 if (cmdline_star > 0) |
4157 return NULL; | 4158 return NULL; |
4158 | 4159 |
4159 p = get_ccline_ptr(); | 4160 p = get_ccline_ptr(); |
4163 set_expand_context(p->xpc); | 4164 set_expand_context(p->xpc); |
4164 if (p->xpc->xp_context == EXPAND_UNSUCCESSFUL) | 4165 if (p->xpc->xp_context == EXPAND_UNSUCCESSFUL) |
4165 return NULL; | 4166 return NULL; |
4166 | 4167 |
4167 char_u *cmd_compl = cmdcomplete_type_to_str(p->xpc->xp_context); | 4168 char_u *cmd_compl = cmdcomplete_type_to_str(p->xpc->xp_context); |
4168 if (cmd_compl != NULL) | 4169 if (cmd_compl == NULL) |
4169 return vim_strsave(cmd_compl); | 4170 return NULL; |
4170 | 4171 |
4171 return NULL; | 4172 if (p->xpc->xp_context == EXPAND_USER_LIST || p->xpc->xp_context == EXPAND_USER_DEFINED) |
4173 { | |
4174 buffer = alloc(STRLEN(cmd_compl) + STRLEN(p->xpc->xp_arg) + 2); | |
4175 if (buffer == NULL) | |
4176 return NULL; | |
4177 sprintf((char *)buffer, "%s,%s", cmd_compl, p->xpc->xp_arg); | |
4178 return buffer; | |
4179 } | |
4180 | |
4181 return vim_strsave(cmd_compl); | |
4172 } | 4182 } |
4173 | 4183 |
4174 /* | 4184 /* |
4175 * "getcmdcompltype()" function | 4185 * "getcmdcompltype()" function |
4176 */ | 4186 */ |