Home Download Buy Blog Forum Support

Extend ST3 Project Tagging

Extend ST3 Project Tagging

Postby chrisguilbeau on Sun Jun 23, 2013 6:38 am

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?
chrisguilbeau
 
Posts: 19
Joined: Fri Nov 11, 2011 5:06 am

Re: Extend ST3 Project Tagging

Postby freewizard on Mon Jun 24, 2013 12:37 am

Same Q here, should I change the syntax files to get that?
using Sublime Text 3 dev in OS X 10.8
my ST packages: https://github.com/freewizard
freewizard
 
Posts: 36
Joined: Wed Feb 09, 2011 4:14 am

Re: Extend ST3 Project Tagging

Postby FichteFoll on Mon Jun 24, 2013 2:32 am

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 http://docs.sublimetext.info/en/latest/ ... xdefs.html for a brief description (and tutorial).

  2. 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(tm).
FichteFoll
 
Posts: 408
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: Extend ST3 Project Tagging

Postby fjl on Mon Jun 24, 2013 6:54 am

Here's an example tmPreferences file:

Code: Select all
<?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>Macro Symbols</string>
    <key>scope</key>
    <string>entity.name.macro.definition.erlang</string>
    <key>settings</key>
    <dict>
        <key>showInSymbolList</key>
        <integer>1</integer>
       
        <key>symbolTransformation</key>
        <string>s/^/Macro: /</string>
       
        <key>showInIndexedSymbolList</key>
        <integer>1</integer>
       
        <key>symbolIndexTransformation</key>
        <string>s/^/Macro: /</string>
    </dict>
</dict>
</plist>
fjl
 
Posts: 36
Joined: Wed Dec 28, 2011 12:41 am

Re: Extend ST3 Project Tagging

Postby jufei9494 on Tue Jun 10, 2014 10:25 am

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.
jufei9494
 
Posts: 9
Joined: Fri Jun 06, 2014 6:25 am

Re: Extend ST3 Project Tagging

Postby FichteFoll on Tue Jun 10, 2014 12:24 pm

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).
FichteFoll
 
Posts: 408
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: Extend ST3 Project Tagging

Postby jufei9494 on Wed Jun 11, 2014 3:28 am

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: Select all
<?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>


But it seems does not work. :(
jufei9494
 
Posts: 9
Joined: Fri Jun 06, 2014 6:25 am

Re: Extend ST3 Project Tagging

Postby FichteFoll on Wed Jun 11, 2014 9:58 pm

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.
FichteFoll
 
Posts: 408
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany


Return to General Discussion

Who is online

Users browsing this forum: svenax, ToddFiske and 30 guests