I'm not sure I'm using the right tool for the job here, but I'm trying to embed Lua syntax highlighting inside a block syntax. The only way I can make this work is with a syn region. I can find the block easily enough with a syn match, but trying to embed another syntax in there (e.g. with contains=@Lua just ends up bleeding all other the place.
This is for the vim-sile syntax plugin. I've managed to do something similar embedding Lua for an inline syntax where the region end actually is just a delimiter, so that is hilghlighted correctly. See for example:
\begin[papersize=a5]{document} \nofolios \font[family=Libertinus Serif] \begin{script} -- Lua comment .myvar = "mod4=" .. 4 % 2 \end{script} \begin{raggedright} % sile comment Lorem ipsum... \end{raggedright} \script{myvar = "mod4=" .. 4 % 2} lorem \emph{ipsum}... \end{document} Note how the Lua code inside the \script{...} command works great, but the same code in the \begin{script}...\end{script} block does not.
I have matches already setup for parsing the details of \begin{<command>} and those are nicely highlighted for other possible values, but specifically for script when Lua is going to be embedded I can't figure out how to use my regular highlighting for the delimiters and use them in the start/end.
syn region sileBlockLua matchgroup=Delimiter start="\\begin{script}" end="\\end{script}" contains=@LUA This finds the blocks and does the Lua embedding right, but the start and end text ends up as Delimiter.
How can I capture a region to embed another syntax, but also capture and highlgiht the start and end delimiters?
