Yes, perhaps if you are not against hacking a syntax file. First you need to include the HTML syntax file from the Javascript syntax file - see :help syn-include for information on this; secondly, you need to declare that the HTML syntax can be found inside certain elements (like strings). Thirdly, if you want to be able to enable and disable it, you can make these commands dependent on the global variable and write some mappings that set or cancel the variable and then reload the syntax file.
For examples on how inclusion works, take a look at syntax/html.vim (which includes Javascript and CSS syntax files), syntax/perl.vim (which includes a POD syntax file), or php.vim (which includes highlighting SQL syntax in strings due to global validity).
Edit: I worked a bit to make this happen in my copy.
At the beginning of syntax/javascript.vim , just below syn case ignore , add
syn include @javaScriptHTML syntax/html.vim unlet b:current_syntax syn spell default " HTML enables spell-checking globally, turn it off
Then add @javaScriptHTML to the contained= lists for javaScriptStringD and javaScriptStringS .
Finally, you need to edit syntax/html.vim so that it doesn't include syntax/javascript.vim if it was loaded from javascript: find the line that reads
if main_syntax != 'java' || exists("java_javascript")
and change it to
if main_syntax != 'javascript' && ( main_syntax != 'java' || exists("java_javascript")
hobbs Sep 25 '09 at 5:36 2009-09-25 05:36
source share