summaryrefslogtreecommitdiffstats
path: root/src/ex_getln.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-03-05 17:41:49 +0100
committerBram Moolenaar <Bram@vim.org>2016-03-05 17:41:49 +0100
commit35ca0e7a1cb6e6daef8e0052a8437801226cef19 (patch)
treece62743d4ab746c29b4a080bd44ac06f32fe00dd /src/ex_getln.c
parent019b9c644e92742e37efc08fef47c2620a01b6b3 (diff)
patch 7.4.1492v7.4.1492
Problem: No command line completion for ":packadd". Solution: Implement completion. (Hirohito Higashi)
Diffstat (limited to 'src/ex_getln.c')
-rw-r--r--src/ex_getln.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 8db37d9977..96c3a8ceba 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -112,6 +112,7 @@ static int expand_showtail(expand_T *xp);
#ifdef FEAT_CMDL_COMPL
static int expand_shellcmd(char_u *filepat, int *num_file, char_u ***file, int flagsarg);
static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname[]);
+static int ExpandPackAddDir(char_u *pat, int *num_file, char_u ***file);
# ifdef FEAT_CMDHIST
static char_u *get_history_arg(expand_T *xp, int idx);
# endif
@@ -4231,6 +4232,7 @@ addstar(
|| context == EXPAND_COMPILER
|| context == EXPAND_OWNSYNTAX
|| context == EXPAND_FILETYPE
+ || context == EXPAND_PACKADD
|| (context == EXPAND_TAGS && fname[0] == '/'))
retval = vim_strnsave(fname, len);
else
@@ -4647,6 +4649,8 @@ ExpandFromContext(
if (xp->xp_context == EXPAND_USER_LIST)
return ExpandUserList(xp, num_file, file);
# endif
+ if (xp->xp_context == EXPAND_PACKADD)
+ return ExpandPackAddDir(pat, num_file, file);
regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0);
if (regmatch.regprog == NULL)
@@ -5180,6 +5184,58 @@ ExpandRTDir(
return OK;
}
+/*
+ * Expand loadplugin names:
+ * 'packpath'/pack/ * /opt/{pat}
+ */
+ static int
+ExpandPackAddDir(
+ char_u *pat,
+ int *num_file,
+ char_u ***file)
+{
+ char_u *s;
+ char_u *e;
+ char_u *match;
+ garray_T ga;
+ int i;
+ int pat_len;
+
+ *num_file = 0;
+ *file = NULL;
+ pat_len = (int)STRLEN(pat);
+ ga_init2(&ga, (int)sizeof(char *), 10);
+
+ s = alloc((unsigned)(pat_len + 26));
+ if (s == NULL)
+ {
+ ga_clear_strings(&ga);
+ return FAIL;
+ }
+ sprintf((char *)s, "pack/*/opt/%s*", pat);
+ globpath(p_pp, s, &ga, 0);
+ vim_free(s);
+
+ for (i = 0; i < ga.ga_len; ++i)
+ {
+ match = ((char_u **)ga.ga_data)[i];
+ s = gettail(match);
+ e = s + STRLEN(s);
+ mch_memmove(match, s, e - s + 1);
+ }
+
+ if (ga.ga_len == 0)
+ return FAIL;
+
+ /* Sort and remove duplicates which can happen when specifying multiple
+ * directories in dirnames. */
+ remove_duplicates(&ga);
+
+ *file = ga.ga_data;
+ *num_file = ga.ga_len;
+ return OK;
+}
+
#endif
#if defined(FEAT_CMDL_COMPL) || defined(FEAT_EVAL) || defined(PROTO)