Sublime Forum

Job: $20 for creating a really simple difinition syntax

#1

If you have the routine this will take you half an hour.

I need a really simple syntax with just six really simple regex patterns.

You need to match simple tags like #k# and #j# really simple.

There are also two levels of folding.

PM me if you are interested.

0 Likes

#2

Most people here are pretty generous with their time. If you post things in a bit more detail I’d be willing to help you out for free.

Syntax definitions do not let you specify code folding levels at the moment (the key is there, but it is ignored).

Edit: From what you’ve mentioned so far…

<?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>name</key>
	<string>kjemmo</string>

	<key>scopeName</key>
	<string>source.kjemmo</string>

	<key>patterns</key>
	<array>
		<dict>
			<key>name</key>
			<string>keyword.k.kjemmo</string>
			<key>match</key>
			<string>#k#</string>
		</dict>

		<dict>
			<key>name</key>
			<string>keyword.j.kjemmo</string>
			<key>match</key>
			<string>#j#</string>
		</dict>
	</array>

</dict>
</plist>
0 Likes

#3

Thanks for the positive reply Nick.

Im am glad to be in friendly place :smiley:

Here are the tags highlighted, That I would like to stand out from ordinary text (like plain english).

#S#
#SB#
#P#
#BP#
#EP#

The regex could be a simple as e.g. code[/code]
Regarding code folding. Are there another way to define that?

Thanks again.

0 Likes

#4

Sorry did not see your code example.

Will try to do it and post the result.

0 Likes

#5

Should be pretty straightforward, as you’ve said. Remember that syntax coloring is a separate process handled by a .tmTheme file.

I recall a thread on here about creating code folds via a plugin, but I can’t find it. This thread popped up today though, seems relevant.

0 Likes

#6

Thanks.

I made it work. All the talk about converting from json and new file extension like .tmLanguage confused me.

It turn out that this is dead simple XML like Nick described. No need for any conversion simple enough to write in XML.

Still had to figure out how to make a new package/folder - that only acts as a folder when accessed from sublime text.

The different colors comes with the:

keyword.S.kjemmo

Is there a list of the words that can be used somewhere?

And is it possible to edit an existing color theme?

I will look into ‘RegReplace’ it seems very usefull for a lot of things.

0 Likes

#7

The colors come from the scope, which is defined by the “name” tag. So if you have

<key>name</key> <string>this.is.my.scope.name</string>

You could give that a specific color/style in the color scheme (.tmTheme) file. Moreover, you can use CSS-like syntax to be as generic or specific as you want. So you could give this a color, and this.is another color, and this.is.my.scope another, and so on. The most specific scope gets the color. This is all better described here and here. The latter describes the accepted scope hierarchy, but you can create a scope with any name. You’ll just have to manually add support in the .tmTheme if you leave the standard naming conventions.

You can edit the color scheme as you would any other file. The built in schemes are located in /Packages/Color Scheme - Default/ . Take a look there; you can also check out my sublime-settings repo for the custom syntax scheme I use.

0 Likes

#8

Thanks again Nick.

Starting to see the opportunities here - I think Sublime text 2 just became my preferred editor!

0 Likes

#9

tmLanguages are in PLIST, which, yes, is XML. The reason to switch back and forth between PLIST and JSON is that the latter is a lot less cumbersome to write out.

The PlistJsonConverter plugin allows converting between the two as does (I think) AAAPackageDev.

0 Likes

#10

JSON is certainly easier to write out from the key/value standpoint, and I think it’s more readable as well, but since a language file is mostly regex, and in JSON you have to do tons of extra regex escaping, I find it easier to just work staight in PLIST/XML. If you turn on Sublime’s autocompletion and make use of Alt + . , it’s not bad at all to write all those open/close tags.

0 Likes

#11

@nick Both the regex escaping (in JSON) and the proliferation of tags (in PLIST) are annoying. It’s a choice between two evils, for sure :smile:

0 Likes

#12

I prefer imperative python for declaring the grammars

0 Likes