@@ -111,7 +111,7 @@ static int ExpandFromContext(expand_T *xp, char_u *, int *, char_u ***, int);
111111static int expand_showtail (expand_T * xp );
112112#ifdef FEAT_CMDL_COMPL
113113static int expand_shellcmd (char_u * filepat , int * num_file , char_u * * * file , int flagsarg );
114- static int ExpandRTDir (char_u * pat , int * num_file , char_u * * * file , char * dirname []);
114+ static int ExpandRTDir (char_u * pat , int flags , int * num_file , char_u * * * file , char * dirname []);
115115static int ExpandPackAddDir (char_u * pat , int * num_file , char_u * * * file );
116116# ifdef FEAT_CMDHIST
117117static char_u * get_history_arg (expand_T * xp , int idx );
@@ -4628,22 +4628,23 @@ ExpandFromContext(
46284628 if (xp -> xp_context == EXPAND_COLORS )
46294629 {
46304630 char * directories [] = {"colors" , NULL };
4631- return ExpandRTDir (pat , num_file , file , directories );
4631+ return ExpandRTDir (pat , DIP_START + DIP_OPT , num_file , file ,
4632+ directories );
46324633 }
46334634 if (xp -> xp_context == EXPAND_COMPILER )
46344635 {
46354636 char * directories [] = {"compiler" , NULL };
4636- return ExpandRTDir (pat , num_file , file , directories );
4637+ return ExpandRTDir (pat , 0 , num_file , file , directories );
46374638 }
46384639 if (xp -> xp_context == EXPAND_OWNSYNTAX )
46394640 {
46404641 char * directories [] = {"syntax" , NULL };
4641- return ExpandRTDir (pat , num_file , file , directories );
4642+ return ExpandRTDir (pat , 0 , num_file , file , directories );
46424643 }
46434644 if (xp -> xp_context == EXPAND_FILETYPE )
46444645 {
46454646 char * directories [] = {"syntax" , "indent" , "ftplugin" , NULL };
4646- return ExpandRTDir (pat , num_file , file , directories );
4647+ return ExpandRTDir (pat , 0 , num_file , file , directories );
46474648 }
46484649# if defined(FEAT_USR_CMDS ) && defined(FEAT_EVAL )
46494650 if (xp -> xp_context == EXPAND_USER_LIST )
@@ -5119,13 +5120,19 @@ ExpandUserList(
51195120#endif
51205121
51215122/*
5122- * Expand color scheme, compiler or filetype names:
5123- * 'runtimepath'/{dirnames}/{pat}.vim
5123+ * Expand color scheme, compiler or filetype names.
5124+ * Search from 'runtimepath':
5125+ * 'runtimepath'/{dirnames}/{pat}.vim
5126+ * When "flags" has DIP_START: search also from 'start' of 'packpath':
5127+ * 'packpath'/pack/ * /start/ * /{dirnames}/{pat}.vim
5128+ * When "flags" has DIP_OPT: search also from 'opt' of 'packpath':
5129+ * 'packpath'/pack/ * /opt/ * /{dirnames}/{pat}.vim
51245130 * "dirnames" is an array with one or more directory names.
51255131 */
51265132 static int
51275133ExpandRTDir (
51285134 char_u * pat ,
5135+ int flags ,
51295136 int * num_file ,
51305137 char_u * * * file ,
51315138 char * dirnames [])
@@ -5155,6 +5162,36 @@ ExpandRTDir(
51555162 vim_free (s );
51565163 }
51575164
5165+ if (flags & DIP_START ) {
5166+ for (i = 0 ; dirnames [i ] != NULL ; ++ i )
5167+ {
5168+ s = alloc ((unsigned )(STRLEN (dirnames [i ]) + pat_len + 22 ));
5169+ if (s == NULL )
5170+ {
5171+ ga_clear_strings (& ga );
5172+ return FAIL ;
5173+ }
5174+ sprintf ((char * )s , "pack/*/start/*/%s/%s*.vim" , dirnames [i ], pat );
5175+ globpath (p_pp , s , & ga , 0 );
5176+ vim_free (s );
5177+ }
5178+ }
5179+
5180+ if (flags & DIP_OPT ) {
5181+ for (i = 0 ; dirnames [i ] != NULL ; ++ i )
5182+ {
5183+ s = alloc ((unsigned )(STRLEN (dirnames [i ]) + pat_len + 20 ));
5184+ if (s == NULL )
5185+ {
5186+ ga_clear_strings (& ga );
5187+ return FAIL ;
5188+ }
5189+ sprintf ((char * )s , "pack/*/opt/*/%s/%s*.vim" , dirnames [i ], pat );
5190+ globpath (p_pp , s , & ga , 0 );
5191+ vim_free (s );
5192+ }
5193+ }
5194+
51585195 for (i = 0 ; i < ga .ga_len ; ++ i )
51595196 {
51605197 match = ((char_u * * )ga .ga_data )[i ];
0 commit comments