derekwyatt/vim-scala — pull request #59 by blaenk (2014-04-23 02:58:10+00:00)
Title: allow embedded highlighting

Hey, I'm using vim-scala to highlight codeblocks embedded in markdown files using [vim-pandoc-syntax](https://github.com/vim-pandoc/vim-pandoc-syntax/). A [commit](https://github.com/derekwyatt/vim-scala/commit/7daf2562f1d1efb0955a863abf725ac438c35e82) introduced a `contains=TOP` directive which has since then been added to two other rules.

The embedded codeblock highlighting more or less works by defining a region (the codeblock) and saying that it `contains=@thelanguage`. However, in this case the contained language (scala) is using `contains=TOP` which leads to the images shown in [this issue](https://github.com/vim-pandoc/vim-pandoc-syntax/issues/54).

What I've done to fix this is to create a small function that checks if the `@scala` group is defined, which would mean that this is for highlighting embedded scala codeblocks. If it is, then it uses `contains=@scala` instead of `contains=TOP`, otherwise (regular files) it uses `TOP`.

I tested it in regular scala files and files that embed scala codeblocks and they both work fine.