4

I have written syntax highlighting for a slightly unfamiliar language (Cadence SKILL) in sublime text 2.

Its working like a charm, however I miss the feature of CTRL + R , which locates all the symbols (functions) in the present file in an easily accessible way.

Can anyone please suggest how to tell Sublime Text where to look for a pattern of function (procedure) declaration?

Thanks!

2 Answers 2

4

Take a look at Default/Symbol List.tmPreferences. You can create this preference file and specify scopes to include in the symbol list. You may also want to look at Java/Symbol List <some specifier>.tmPreferences for examples of a language specific symbol list. Alternatively, you can ensure the things that you want to include have the scope entity.name.function or entity.name.type.

edit

You will need to look at your color scheme file. These files are Plist, so you may want to use something like PlistJsonConverter to make it a little more readable (though this is more of a personal preference). In this file, you will see a number of dictionary entries. One of the keys to these entries is scope. When a matching scope is found as defined by your language definition. You will also see a "settings" key that defines details about color, font style, etc. Since you want different colors, you will need to apply different scopes. You will need to define a custom Symbol List preference file so everything gets included properly. The following is from the Java package.

<?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>Symbol List: Classes</string>
    <key>scope</key>
    <string>source.java meta.class meta.class.identifier</string>
    <key>settings</key>
    <dict>
        <key>showInSymbolList</key>
        <integer>1</integer>
    </dict>
    <key>uuid</key>
    <string>22E489AE-989E-4A76-9C18-89944CF5013D</string>
</dict>
</plist>

You will define whatever scopes are being applied to the entries you want to appear in the list.

6
  • Thanks :) However I am not so comfortable with "entity.name.function" etc. terminologies. Can you please share a resource to learn them? But at least I got the pointer to move ahead.
    – deowood
    Commented Apr 25, 2013 at 3:55
  • "entity.name.function" is just a scope name. I make the assumption you know what scopes are since it sounds like you wrote a syntax file. In terms of learning, for me it was browsing through the ST files and looking through the textmate docs. manual.macromates.com/en I guess for ST specifically, if I saw something happen occur differently, on a language specific basis, I started searching through those files to see how it was done.
    – skuroda
    Commented Apr 25, 2013 at 8:57
  • I don't know what scopes are, however the syntax file was just made modifying the 'lisp' syntax file! Its working good for me now, but I guess I need to dig deep into these things if I want these advanced features to work. Thanks a lot :)
    – deowood
    Commented Apr 26, 2013 at 7:48
  • Simply put, scopes are names applied to patterns matching the regular expression patterns. But yea, it's probably worthwhile to learn a bit about them if you are going to modify syntax files (or modify color schemes I suppose).
    – skuroda
    Commented Apr 26, 2013 at 16:02
  • Hi there, first of all thanks to you, as I have, to a good degree understood scopes and I have achieved what I originally asked (see all the symbols in ctrl + R ). However, I want more! Sublime Text is not using different colors for different scopes. How do I achieve that? (FYI, I am using the cobalt theme). Thanks
    – deowood
    Commented May 8, 2013 at 10:31
0

I too made one myself for Cadence Skill. You can try it out here

https://github.com/noisyass2/SublimeCadenceSkill

2
  • hi there, I am using your syntax highlighting now (just switched to ST3). Its far better than what I achieved. However, in the symbols List, I am seeing lot many things (like hiCreateLabel etc), how do I see only the procedure names when I press Ctrl + R?
    – deowood
    Commented Nov 21, 2013 at 8:51
  • oh that was intentional, i included all the function calls with the function declarations. but yeah, i updated it now and removed those function calls on the symbolsList (ctrl+R).
    – noisyass2
    Commented Dec 9, 2013 at 8:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.