Skip to content

Commit 2d02839

Browse files
committed
patch 8.0.0157: no completion for :syntax spell and :syntax sync
Problem: No command line completion for ":syntax spell" and ":syntax sync". Solution: Implement the completion. (Dominique Pelle)
1 parent 453b576 commit 2d02839

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

src/syntax.c

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6383,7 +6383,9 @@ syntax_present(win_T *win)
63836383
static enum
63846384
{
63856385
EXP_SUBCMD, /* expand ":syn" sub-commands */
6386-
EXP_CASE /* expand ":syn case" arguments */
6386+
EXP_CASE, /* expand ":syn case" arguments */
6387+
EXP_SPELL, /* expand ":syn spell" arguments */
6388+
EXP_SYNC /* expand ":syn sync" arguments */
63876389
} expand_what;
63886390

63896391
/*
@@ -6434,6 +6436,10 @@ set_context_in_syntax_cmd(expand_T *xp, char_u *arg)
64346436
xp->xp_context = EXPAND_NOTHING;
64356437
else if (STRNICMP(arg, "case", p - arg) == 0)
64366438
expand_what = EXP_CASE;
6439+
else if (STRNICMP(arg, "spell", p - arg) == 0)
6440+
expand_what = EXP_SPELL;
6441+
else if (STRNICMP(arg, "sync", p - arg) == 0)
6442+
expand_what = EXP_SYNC;
64376443
else if ( STRNICMP(arg, "keyword", p - arg) == 0
64386444
|| STRNICMP(arg, "region", p - arg) == 0
64396445
|| STRNICMP(arg, "match", p - arg) == 0
@@ -6445,18 +6451,38 @@ set_context_in_syntax_cmd(expand_T *xp, char_u *arg)
64456451
}
64466452
}
64476453

6448-
static char *(case_args[]) = {"match", "ignore", NULL};
6449-
64506454
/*
64516455
* Function given to ExpandGeneric() to obtain the list syntax names for
64526456
* expansion.
64536457
*/
64546458
char_u *
64556459
get_syntax_name(expand_T *xp UNUSED, int idx)
64566460
{
6457-
if (expand_what == EXP_SUBCMD)
6458-
return (char_u *)subcommands[idx].name;
6459-
return (char_u *)case_args[idx];
6461+
switch (expand_what)
6462+
{
6463+
case EXP_SUBCMD:
6464+
return (char_u *)subcommands[idx].name;
6465+
case EXP_CASE:
6466+
{
6467+
static char *case_args[] = {"match", "ignore", NULL};
6468+
return (char_u *)case_args[idx];
6469+
}
6470+
case EXP_SPELL:
6471+
{
6472+
static char *spell_args[] =
6473+
{"toplevel", "notoplevel", "default", NULL};
6474+
return (char_u *)spell_args[idx];
6475+
}
6476+
case EXP_SYNC:
6477+
{
6478+
static char *sync_args[] =
6479+
{"ccomment", "clear", "fromstart",
6480+
"linebreaks=", "linecont", "lines=", "match",
6481+
"maxlines=", "minlines=", "region", NULL};
6482+
return (char_u *)sync_args[idx];
6483+
}
6484+
}
6485+
return NULL;
64606486
}
64616487

64626488
#endif /* FEAT_CMDL_COMPL */

src/testdir/test_syntax.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ func Test_syntax_completion()
150150
call feedkeys(":syn case \<C-A>\<C-B>\"\<CR>", 'tx')
151151
call assert_equal('"syn case ignore match', @:)
152152

153+
call feedkeys(":syn spell \<C-A>\<C-B>\"\<CR>", 'tx')
154+
call assert_equal('"syn spell default notoplevel toplevel', @:)
155+
156+
call feedkeys(":syn sync \<C-A>\<C-B>\"\<CR>", 'tx')
157+
call assert_equal('"syn sync ccomment clear fromstart linebreaks= linecont lines= match maxlines= minlines= region', @:)
158+
153159
call feedkeys(":syn list \<C-A>\<C-B>\"\<CR>", 'tx')
154160
call assert_match('^"syn list Boolean Character ', @:)
155161

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
157,
767769
/**/
768770
156,
769771
/**/

0 commit comments

Comments
 (0)