Can syntax clusters contain other clusters?

18 views
Skip to first unread message

BPJ

unread,
Jun 18, 2022, 8:58:58 AM6/18/22
to vim...@googlegroups.com
The subject line says it all: I'm trying to use syntax clusters and wonder if clusters may contain other clusters, i.e. should this work?

syn cluster mydslAnyValue contains=@mydslValue,@mydslContainer
syn cluster mydslAllValues contains=@mydslAnyValue,mydslConstant

TIA,

/bpj

Bram Moolenaar

unread,
Jun 18, 2022, 11:50:35 AM6/18/22
to vim...@googlegroups.com, BPJ
Yes, there is an example just above ":help E848".

--
BODY: I'm not dead!
CART DRIVER: 'Ere. He says he's not dead.
LARGE MAN: Yes he is.
BODY: I'm not!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

BPJ

unread,
Jun 18, 2022, 12:24:38 PM6/18/22
to Bram Moolenaar, vim_use, BPJ
The problem was with something else. Sorry for the noise!

BPJ

unread,
Aug 23, 2022, 6:54:57 AM8/23/22
to bpj, vim_use
For my DSL I have a syntax region for text between a pair of delimiters inside which other syntax items should come in a specific order, say first dslFoo, then dslBar, then dslBaz.
I can use nextgroup=dslBar to declare which item should come after dslFoo and so on, but how do I declare that the first item inside the region must be a dslFoo? Is there a better approach than defining the opening delimiter as a match item to be followed by a dslFoo item and so on, but doesn't that prevent me from using contains and containedin? I wish I could do something like firstcontained=dslFoo on the region.

What is the best way to do this?

/bpj

Charles Campbell

unread,
Aug 23, 2022, 1:02:55 PM8/23/22
to vim...@googlegroups.com
BPJ wrote:
> For my DSL I have a syntax region for text between a pair of
> delimiters inside which other syntax items should come in a specific
> order, say first dslFoo, then dslBar, then dslBaz.
> I can use nextgroup=dslBar to declare which item should come after
> dslFoo and so on, but how do I declare that the first item inside the
> region must be a dslFoo? Is there a better approach than defining the
> opening delimiter as a match item to be followed by a dslFoo item and
> so on, but doesn't that prevent me from using contains and
> containedin? I wish I could do something like firstcontained=dslFoo on
> the region.
>
> What is the best way to do this?
>
> /bpj
>
Good luck with getting this! I've asked for it over a decade ago. Bottom
line: currently, you can't.

Uses: region would start properly but, since its a region, would allow
it to be folded, syntax changed (perl/tex/sh) for start/end patterns, etc.

Chip Campbell

M

unread,
Aug 23, 2022, 2:45:09 PM8/23/22
to vim...@googlegroups.com

вт, 23 авг. 2022 г. в 20:02, Charles Campbell <camp...@drchip.org>:
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/8baf4165-1e94-9032-3d83-15aee8a82f61%40drchip.org.

What if you define dslFoo after both dslBar and dslBaz? Won't it be enough?

Kind regards,
Matvey

BPJ

unread,
Aug 24, 2022, 6:15:46 AM8/24/22
to vim_use
I have found that using patterns with lookahead/lookbehind works reasonably well in most cases (for this syntax at least). It feels like overkill though and is harder to maintain because I may need to change patterns in two or more places instead of one.


Reply all
Reply to author
Forward
0 new messages