Sublime Forum

Customer some rule for syntax highlight and function list

#1

hi:
I am working on developing a macro called HitMicro. It is a script language used to communicate with our device. Now the file is very big. I currently use Ultraedit to edit the file, the Ultraedit has syntax file for the hitmicro (file extension is .hit). But i love ST3, and I wish to edit it in ST3. So do you know how can i use it in ST3?

I need the following functions:

  1. Syntax highlight, even if need I set the rule myself
  2. In Goto Symbol window, show the function list, of course even if need I set the rule for function.

Thanks in advanced!

0 Likes

#2

Very possible, take a look to this short thread for a start Creating a very basic highlighter scheme

0 Likes

#3

hi:
Thanks for your kindly response.

I have created a new .tmLanguage file and use it to highlight the file.

Now I am trying to resolve my second question: how to add the function to the Goto Symbol window.

I have highlight the function name with my patterns like:

        <dict>
            <key>match</key>
            <string>^\s\S]*function\s+([a-zA-Z_0-9\(\)\[\]\& ,]*)</string>
            <key>captures</key>
            <dict>
                <key>1</key>
                <dict>
                    <key>name</key>
                    <string>storage.type.function.hit</string>
                </dict>
                <key>2</key>
                <dict>
                    <key>name</key>
                    <string>entity.name.function.hit</string>
                </dict>
                <key>3</key>
                <dict>
                    <key>name</key>
                    <string>meta.function.hit</string>
                </dict>
            </dict>
        </dict>

But now the function still not appear in the Goto Symbol window.

Who can tell me how to do this?

Thanks in advanced

0 Likes

#4

My suggestion is to open the “CSS.sublime-package” and take a look to these files named “Symbol XYZ”

0 Likes

#5

hi:
first, CSS.sublime-package is a binary file.
I searched some website, and heard that I need to prepare a .tmPerferences file.

So i created one and put the following content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>name</key>
	<string>Symbol List</string>
	<key>scope</key>
	<string>source.hit meta.function.hit</string>
	<key>settings</key>
	<dict>
		<key>showInSymbolList</key>
		<integer>1</integer>
		<key>symbolTransformation</key>
		<string>
		^\s\S]*function\s+([a-zA-Z_0-9\(\)\[\]\& ,]*)
	</string>
	</dict>
	<key>uuid</key>
	<string>005BE156-8D74-4036-AF38-283708645116</string>
</dict>
</plist>
Now my problem is: what name should i use for this file and where should I put this file so that ST3 can use it?

Thanks.

0 Likes

#6

CSS.sublime-package is a ZIP file :slight_smile:

I think if you put the file in the same folder of the file that has the syntax highlighting should just work. I guess you are creating a “hit” package… as …/Packages/hit/Yourfiles.tmSomething

0 Likes

#7

Hi:
I am not create a package. I just put the .tmLanguage file in packages\User directroy.
Now I put the .tmPerferences file in the packages\User directroy

But still it does not work. Is something in “source.hit meta.function.hit”?

0 Likes