@@ -1768,6 +1768,45 @@ set_context_for_wildcard_arg(
17681768 }
17691769}
17701770
1771+ /*
1772+ * Set the completion context for the "++opt=arg" argument. Always returns
1773+ * NULL.
1774+ */
1775+ static char_u *
1776+ set_context_in_argopt (expand_T * xp , char_u * arg )
1777+ {
1778+ char_u * p ;
1779+
1780+ p = vim_strchr (arg , '=' );
1781+ if (p == NULL )
1782+ xp -> xp_pattern = arg ;
1783+ else
1784+ xp -> xp_pattern = p + 1 ;
1785+
1786+ xp -> xp_context = EXPAND_ARGOPT ;
1787+ return NULL ;
1788+ }
1789+
1790+ #ifdef FEAT_TERMINAL
1791+ /*
1792+ * Set the completion context for :terminal's [options]. Always returns NULL.
1793+ */
1794+ static char_u *
1795+ set_context_in_terminalopt (expand_T * xp , char_u * arg )
1796+ {
1797+ char_u * p ;
1798+
1799+ p = vim_strchr (arg , '=' );
1800+ if (p == NULL )
1801+ xp -> xp_pattern = arg ;
1802+ else
1803+ xp -> xp_pattern = p + 1 ;
1804+
1805+ xp -> xp_context = EXPAND_TERMINALOPT ;
1806+ return NULL ;
1807+ }
1808+ #endif
1809+
17711810/*
17721811 * Set the completion context for the :filter command. Returns a pointer to the
17731812 * next command after the :filter command.
@@ -2491,13 +2530,28 @@ set_one_cmd_context(
24912530
24922531 arg = skipwhite (p );
24932532
2494- // Skip over ++argopt argument
2495- if ((ea .argt & EX_ARGOPT ) && * arg != NUL && STRNCMP ( arg , "++" , 2 ) == 0 )
2533+ // Does command allow " ++argopt" argument?
2534+ if ((ea .argt & EX_ARGOPT ) || ea . cmdidx == CMD_terminal )
24962535 {
2497- p = arg ;
2498- while (* p && !vim_isspace (* p ))
2499- MB_PTR_ADV (p );
2500- arg = skipwhite (p );
2536+ while (* arg != NUL && STRNCMP (arg , "++" , 2 ) == 0 )
2537+ {
2538+ p = arg + 2 ;
2539+ while (* p && !vim_isspace (* p ))
2540+ MB_PTR_ADV (p );
2541+
2542+ // Still touching the command after "++"?
2543+ if (* p == NUL )
2544+ {
2545+ if (ea .argt & EX_ARGOPT )
2546+ return set_context_in_argopt (xp , arg + 2 );
2547+ #ifdef FEAT_TERMINAL
2548+ if (ea .cmdidx == CMD_terminal )
2549+ return set_context_in_terminalopt (xp , arg + 2 );
2550+ #endif
2551+ }
2552+
2553+ arg = skipwhite (p );
2554+ }
25012555 }
25022556
25032557 if (ea .cmdidx == CMD_write || ea .cmdidx == CMD_update )
@@ -3120,6 +3174,12 @@ ExpandFromContext(
31203174 ret = ExpandSettingSubtract (xp , & regmatch , numMatches , matches );
31213175 else if (xp -> xp_context == EXPAND_MAPPINGS )
31223176 ret = ExpandMappings (pat , & regmatch , numMatches , matches );
3177+ else if (xp -> xp_context == EXPAND_ARGOPT )
3178+ ret = expand_argopt (pat , xp , & regmatch , matches , numMatches );
3179+ #if defined(FEAT_TERMINAL )
3180+ else if (xp -> xp_context == EXPAND_TERMINALOPT )
3181+ ret = expand_terminal_opt (pat , xp , & regmatch , matches , numMatches );
3182+ #endif
31233183#if defined(FEAT_EVAL )
31243184 else if (xp -> xp_context == EXPAND_USER_DEFINED )
31253185 ret = ExpandUserDefined (pat , xp , & regmatch , matches , numMatches );
@@ -3253,7 +3313,9 @@ ExpandGeneric(
32533313 if (!fuzzy && xp -> xp_context != EXPAND_MENUNAMES
32543314 && xp -> xp_context != EXPAND_STRING_SETTING
32553315 && xp -> xp_context != EXPAND_MENUS
3256- && xp -> xp_context != EXPAND_SCRIPTNAMES )
3316+ && xp -> xp_context != EXPAND_SCRIPTNAMES
3317+ && xp -> xp_context != EXPAND_ARGOPT
3318+ && xp -> xp_context != EXPAND_TERMINALOPT )
32573319 sort_matches = TRUE;
32583320
32593321 // <SNR> functions should be sorted to the end.
0 commit comments