Sublime Forum

[SOLVED] Text after // Grey out

#1

Hi,

I am currently using Sublime Text 2 to write and edit Serpent code. I have the Serpent.tmLanguge as package installed. However, this greys out text after // randomly! and not everywhere. This makes it very hard to read the code with lots many comments.

I was wondering if I could modify the xml file or setting of ST 2, so that texts after // become grey.

There are the first few lines of the tmLanguage file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>bundleUUID</key>
	<string>E3BADC20-6B0E-11D9-9DC9-000D93589AF6</string>
	<key>comment</key>
	<string>
		Todo: // comments, some keywords
	</string>
	<key>fileTypes</key>
	<array>
		<string>srp</string>
	</array>
	<key>firstLineMatch</key>
	<string>^#!/.*\bpython[0-9.-]*\b</string>
	<key>foldingStartMarker</key>
	<string>^\s*(def|class)\s+([.a-zA-Z0-9_ &lt;]+)\s*(\((.*)\))?\s*:|\{\s*$|\(\s*$|\[\s*$|^\s*"""(?=.)(?!.*""")</string>

Any help would be greatly appreciated.

0 Likes

#2

I don’t know Serpent syntax and did not find the Serpent.tmLanguage you mention, but the following rule should mark all appearances of // ... as comment, if it is what you want.

<dict>
	<key>match</key>
	<string>//.*</string>
	<key>name</key>
	<string>comment.single.line.sublime-settings</string>
</dict>

It should be placed top most to be matched with high priority.

Didn’t work with tmLanguage files so far, but if they support the same kind of scope push/set such as sublime-syntax files, this rule might be missing in some rule subsets.

2 Likes

#3

I’m not at a PC right now, but I found a tmLanguage file for this and it looked like the issue is that // is not just for comments, but also an operator. I think that’s why the syntax as presented doesn’t work as you might like.

I’m not familiar enough with the older syntax spec to know if it’s as capable as sublime-syntax is though.

2 Likes

#4

Thank you very much. Fixed.

0 Likes