Sublime Forum

Extend ST3 Project Tagging

#1

I’d like goto symbol in project to work with a few custom data-structures in our python code. I was wondering if there was a way to add regular expressions to things the tagger matches. Is this possible? If so, how does one do it?

0 Likes

#2

Same Q here, should I change the syntax files to get that?

0 Likes

#3

Technically, yes, but it’s not as easy as you’d expect.

You need to do 2 different things:

  1. Copy the “Python.tmLanguage” syntax definition and modify it. Yes, this is the toughest part, but if you want to highlight your own “data-structures” you have to add a highlighter for them.

See docs.sublimetext.info/en/latest/ … xdefs.html for a brief description (and tutorial).

  1. Create a .tmPreferences file with your specific selector and add a “showInSymbolList” key. See “Packages/Python/Symbol List.tmPreferences” for a good example on this.

Sadly, there are no docs available for this but I intend to write some soon™.

0 Likes

"goto definition" and "goto symbol in project" with sass
#4

Here’s an example tmPreferences file:

[code]<?xml version="1.0" encoding="UTF-8"?>

name Macro Symbols scope entity.name.macro.definition.erlang settings showInSymbolList 1
    <key>symbolTransformation</key>
    <string>s/^/Macro: /</string>
   
    <key>showInIndexedSymbolList</key>
    <integer>1</integer>
   
    <key>symbolIndexTransformation</key>
    <string>s/^/Macro: /</string>
</dict>
[/code]
0 Likes

#5

hi:
I need to add a .tmPerference file for my macro and I wish to know:
What the name should I use for my .tmPerference file?
Where should I put the file for ST3?

Thanks in advanced.

0 Likes

#6

The file name doesn’t matter and is never looked at. Choose whatever makes them organized.

The location doesn’t really matter as well, it only has to be inside a Package directory (that means, a subdirectory of the Packages dir).

0 Likes

#7

Thanks for your response.
So as your suggestion, I created a file named h2.tmPerferences and put it in a directory of some package.
Here is the content:

[code]<?xml version="1.0" encoding="UTF-8"?>

name Symbol List scope source.hit meta.function.hit settings showInSymbolList 1 symbolTransformation ^\s\S]*function\s+([a-zA-Z_0-9\(\)\[\]\& ,]*) uuid 005BE156-8D74-4036-AF38-283708645116 [/code]

But it seems does not work. :frowning:

0 Likes

#8

That symbolTransformation doesn’t look right to me. I only know of regexp replaces in the form s/regexp/replace/. There might be more but I don’t know any.

0 Likes