Sublime Forum

Coldfusion comment block theming

#1

Is there any way to edit a theme so that it displays a background colour on lines with a coldfusion comment block, like I could do with normal comment blocks?

<dict> <key>name</key> <string>Block comment</string> --> do this also for coldfusion comments <key>scope</key> <string>source comment.block</string> <key>settings</key> <dict> <key>background</key> <string>#2D2D2A</string> <key>foreground</key> <string>#FFFFFF</string> </dict> </dict>

coldfusion comment block:

<!---
*	
*	this is a coldfusion comment block
*
--->
0 Likes

#2

In a few words… the problem is probably not in the theme but in syntax definition.
Use ctrl+alt+shift+p with cursor inside your coldfusion comment block to display in the status bar the scope under your cursor.
The scope must contain “comment.block”. If not, you have to modify your coldfusion.tmLanguage to specify that this block is a “comment.block” (http://sublimetext.info/docs/en/extensibility/syntaxdefs.html)

0 Likes

#3

oh ok, that clears a few things up. And I’ve had a look at that page you linked to, but I’m not getting it entirely…

I have this is my tmLanguage file:

   <key>cfcomment</key>
	<dict>
		<key>begin</key>
		<string>&lt;!---</string>
		<key>end</key>
		<string>---\s*&gt;</string>
		<key>name</key>
		<string>comment.line</string>
		<key>patterns</key>
		<array>
			<dict>
				<key>include</key>
				<string>#cfcomment</string>
			</dict>
		</array>
	</dict>

Do you perhaps ahve any idea what I should change to give it the same formatting as say “comment.block.js” in a .js file? I tried changing the name to “comment.block” and “comment.block.js”, but that won’t work. I’m probably missing something else I need to do, right…?

0 Likes

#4

Syntax def. is not my cup of tea either…

What ctrl+alt+shift+p display ? comment.line ?

If so you have probably to add a “source comment.line” block in your theme.

0 Likes

#5

It says “text.html.cfm comment.line”, but adding a comment.line block in my monokai theme.
I already have normal comment line colouring for that comment block though. I’m just trying to find out how to give it a background colour when it consists of multiple lines, like with what I did with js and css files…

0 Likes

#6

[quote=“dreagan”]It says “text.html.cfm comment.line”, but adding a comment.line block in my monokai theme.
I already have normal comment line colouring for that comment block though. I’m just trying to find out how to give it a background colour when it consists of multiple lines, like with what I did with js and css files…[/quote]

:confused:
I thought that the comment block wasn’t colored at all…

If I understand well, you want a background for comment block and no background for comment line ?
Is the syntax for comment line different than comment block ?
Yes you’re right, I’ve no idea what coldfusion is :wink:

0 Likes

#7

No, the comment syntax is always “<!— --->”, just like with html but with an extra hyphen. That’s why the comment, regardless if it’s multiple lines or not, gets the default comment line font colour.

I already have a “source comment.block” defined in my monokai theme, so that comment blocks in js and css get a lighter background colour, so I could insert documentation and find sections in my code more easily. But because the coldfusion comment block is regarded as a comment line, it doesn’t get this background colour…
It’s no big deal really, but I thought I’d give it a try, since Sublime lends itself to customization pretty nicely.

Coldfusion is a server side scripting language by Adobe. Works real nice.

0 Likes

#8

Sorry, but I couldn’t help you much, you need someone that know how tmLanguage work.
You probably have to add a new rule in your coldfusion.tmLanguage before the existing one, something like that:

<key>match</key> <string>&lt;!---.*---\s*&gt;</string> <key>name</key> <string>comment.singleline</string>

In the end you need 2 different scope, one for single line comment and one for block comment.
And adapt your tmTheme to match them.

0 Likes

#9

@dreagon

I’m developing the ColdFusion/CFScript tmlanguage files at github.com/SublimeText/ColdFusion

The reason the comment block is set to line is so that most color themes will be able to differentiate coldfusion comments from regular html comments.

Thinking about this a little more it should not be the job of a language file to dictate style.
So I’ll go ahead and push an update.

@bizoo doing a single line match like that is a good idea thanks.

0 Likes

#10

Hah! Thanks, it now displays “comment.block.cfml”. So I think I’m heading towards the right direction.
However… >_> It’s still not getting the desired background colour. Even though all other comment.block’s from other languages do…
Do I need to add something to the monokai theme different than the code I posted above…?

Also, I’m not able to add comments anymore using the [ctr+shit+/]-command… >.>

I want to thank you both for helping me out so far, it’s been educational… ^^

0 Likes

#11

I just confirmed comment triggers are working fine on a clean install.
You can try removing the contents of your Data folder and git cloning the ColdFusion package again or doing a clean install again.

Anyway, as far as the coloring/theming goes, if you want to match the ColdFusion comment blocks, the scope in your theme file for comments should be:

<string>comment.block</string> and that it matches all comment.block.* scopes
Or

text.html.cfm comment.block but this will match only comment.block.* comments in text.html.cfm
Right now your theme is set to

<string>source comment.block</string> which only matches comment.block in source.* files

HTH GL

0 Likes