summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-08-26 21:58:31 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-26 21:58:31 +0100
commitaf9a6002e0761012cb7108cbfa179a880d3cb49b (patch)
tree4e9829123d060c1a61f529093b0eb815df83eff9
parent0f618386367ba9388e1f50bc665bc1add6c01567 (diff)
patch 9.0.0283: cannot complete "syn list @cluster"v9.0.0283
Problem: Cannot complete "syn list @cluster". Solution: Recognize and handle "list @". (Björn Linse, closes #10990)
-rw-r--r--src/syntax.c30
-rw-r--r--src/testdir/test_syntax.vim4
-rw-r--r--src/version.c2
3 files changed, 32 insertions, 4 deletions
diff --git a/src/syntax.c b/src/syntax.c
index 93f5601caf..1fc205414e 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -6341,7 +6341,8 @@ static enum
EXP_SUBCMD, // expand ":syn" sub-commands
EXP_CASE, // expand ":syn case" arguments
EXP_SPELL, // expand ":syn spell" arguments
- EXP_SYNC // expand ":syn sync" arguments
+ EXP_SYNC, // expand ":syn sync" arguments
+ EXP_CLUSTER // expand ":syn list @cluster" arguments
} expand_what;
/*
@@ -6396,10 +6397,17 @@ set_context_in_syntax_cmd(expand_T *xp, char_u *arg)
expand_what = EXP_SPELL;
else if (STRNICMP(arg, "sync", p - arg) == 0)
expand_what = EXP_SYNC;
- else if ( STRNICMP(arg, "keyword", p - arg) == 0
+ else if (STRNICMP(arg, "list", p - arg) == 0)
+ {
+ p = skipwhite(p);
+ if (*p == '@')
+ expand_what = EXP_CLUSTER;
+ else
+ xp->xp_context = EXPAND_HIGHLIGHT;
+ }
+ else if (STRNICMP(arg, "keyword", p - arg) == 0
|| STRNICMP(arg, "region", p - arg) == 0
- || STRNICMP(arg, "match", p - arg) == 0
- || STRNICMP(arg, "list", p - arg) == 0)
+ || STRNICMP(arg, "match", p - arg) == 0)
xp->xp_context = EXPAND_HIGHLIGHT;
else
xp->xp_context = EXPAND_NOTHING;
@@ -6414,6 +6422,9 @@ set_context_in_syntax_cmd(expand_T *xp, char_u *arg)
char_u *
get_syntax_name(expand_T *xp UNUSED, int idx)
{
+#define CBUFFER_LEN 256
+ static char_u cbuffer[CBUFFER_LEN]; // TODO: better solution
+
switch (expand_what)
{
case EXP_SUBCMD:
@@ -6437,6 +6448,17 @@ get_syntax_name(expand_T *xp UNUSED, int idx)
"maxlines=", "minlines=", "region", NULL};
return (char_u *)sync_args[idx];
}
+ case EXP_CLUSTER:
+ {
+ if (idx < curwin->w_s->b_syn_clusters.ga_len)
+ {
+ vim_snprintf((char *)cbuffer, CBUFFER_LEN, "@%s",
+ SYN_CLSTR(curwin->w_s)[idx].scl_name);
+ return cbuffer;
+ }
+ else
+ return NULL;
+ }
}
return NULL;
}
diff --git a/src/testdir/test_syntax.vim b/src/testdir/test_syntax.vim
index 93e56d7985..7f1e5f0e00 100644
--- a/src/testdir/test_syntax.vim
+++ b/src/testdir/test_syntax.vim
@@ -201,6 +201,10 @@ func Test_syntax_completion()
call feedkeys(":syn match \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_match('^"syn match Boolean Character ', @:)
+
+ syn cluster Aax contains=Aap
+ call feedkeys(":syn list @A\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_match('^"syn list @Aax', @:)
endfunc
func Test_echohl_completion()
diff --git a/src/version.c b/src/version.c
index 2eb817cf9d..c3fbe5f591 100644
--- a/src/version.c
+++ b/src/version.c
@@ -708,6 +708,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 283,
+/**/
282,
/**/
281,