在 MacVim 中组合多种语法

Combining multiple syntaxes in MacVim

我正在尝试为 MacVim 创建一个自定义语法荧光笔,它使用 CSS 和 PHP 的组合,其中 CSS 是静态选择器,有时会嵌入PHP 代码(非常类似于 HTML+PHP)。

这是我的语法文件:

"Import CSS first
runtime! syntax/css.vim
unlet b:current_syntax

" Use PHP any time there is <? ?>
syn include @syntaxPHP syntax/php.vim
syn region regionPHP start="<?" end="?>" contains=@syntaxPHP

当我打开以下内容时:

.my-css {
    <?php echo 'my-php'; ?>
}

只有 php 部分有颜色,css 没有。

使用containedin=ALL:

syn region regionPHP start="<?" end="?>" containedin=ALL contains=@syntaxPHP