Well, this is turning out to not be as bad as I first thought it would. Of course I know the way I have it working is probably hackish but its working for now. And from what limited testing I have done, it actually improves the syntax highlighting of cfscript inside cfscript tags as well.
Im really not sure if this has any adverse side effects yet as I havent obviously tested it thoroughly but so far it seems to be working. I added code folding for functions and if statements so far but that could be expanded alot im sure.
if you try this out, let me know how it works. If you know a better way to handle this or how to improve on it, again, please let me know as Im just hacking trying to figure this out.
Here is what I did to get it working:
At the top of the language grammar change your foldingStartMarker and foldingEnd Marker to this:
foldingStartMarker = '(?x)
(<(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script |ul|ol|form|dl|cfloop|cfif|cfswitch|cfcomponent|cffunction|cfcase|cfdefaultcase|cfsavecontent)\b.*?>
|<!---(?!.*---\s*>)|function\s*|if
)';
foldingStopMarker = '(?x)
(</(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|scrip t|ul|ol|form|dl|cfloop|cfif|cfswitch|cfcomponent|cffunction|cfcase|cfdefaultcase|cfsavecontent)>
|^(?!.*?<!---).*?---\s*>|\}
)';
I simply added the selectors after the comment selectors. This could be added onto a ton Im sure.
For the syntax highlighting, I added this:
{ name = 'source.js';
begin = 'component|/';
end = '/}';
patterns = ( { include = 'source.js'; } );
},
right before this line in the grammar:
{ name = 'meta.tag.structure.any.html';
Should be pretty easy to setup and try if your doing any CF9 script work.
- Russ