Home Download Buy Blog Forum Support

Extend syntax definition from user folder?

Extend syntax definition from user folder?

Postby wastvedt on Mon Feb 03, 2014 6:56 pm

This exact question has been asked before, but I'm hoping that 5 years later there might be a different answer.
Here's the original question: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=204&p=965&hilit=extend+syntax+definition#p965

I have a syntax definition working just fine using AAAPackageDev, but I would like it to simply augment the current (in this case) javascript syntax without having to copy the existing syntax to my user folder, making it no longer update.

Any thoughts? Thanks!
wastvedt
 
Posts: 4
Joined: Mon Feb 03, 2014 6:51 pm

Re: Extend syntax definition from user folder?

Postby skuroda on Tue Feb 04, 2014 8:24 am

Unless something has changed recently, I don't believe it's possible to simply extend a syntax. There are many syntax definitions available through package control that are more complete and updated more frequently, so you may want to check those out as well.
skuroda
 
Posts: 682
Joined: Fri Oct 05, 2012 8:11 am

Re: Extend syntax definition from user folder?

Postby shazhusan on Tue Feb 04, 2014 1:02 pm

I think maybe you can delete internal javascript syntax, and put your defition syntax to user folder.
shazhusan
 
Posts: 2
Joined: Tue Feb 04, 2014 10:58 am

Re: Extend syntax definition from user folder?

Postby wastvedt on Tue Feb 04, 2014 11:58 pm

Ok. Thanks for the verification.

So how does the syntax additions of a plugin like jQuery (https://github.com/SublimeText/jQuery) supposed to work? They include a tmLanguage file which only defines jQuery specific scopes. In ST3 I can switch the syntax for a file to use the jQuery definition instead of the default, but then I only get highlighting on jQuery elements. Does anyone know how the syntax file in that plugin is supposed to work?
wastvedt
 
Posts: 4
Joined: Mon Feb 03, 2014 6:51 pm

Re: Extend syntax definition from user folder?

Postby skuroda on Wed Feb 05, 2014 4:24 am

Sorry I didn't know you could include scopes to be included at the "root" level. I've only done it to include a nested syntax in some specific region. Though now that I think about it, that was just defining a "pattern" list for the text within a defined region. In your custom syntax file, add the following as an entry in the patterns list.

Code: Select all
<dict>
    <key>include</key>
    <string>source.js</string>
</dict>


That should pull in the JavaScript syntax. Of course, you will need to use your syntax with any fixes you have. You may also need to pull in other libraries, if they extend in a similar fashion. I haven't done much with syntax definitions before (if you didn't figure that out already), so there may be some additional quirks.
skuroda
 
Posts: 682
Joined: Fri Oct 05, 2012 8:11 am

Re: Extend syntax definition from user folder?

Postby wastvedt on Wed Feb 05, 2014 7:43 pm

Ok. That seems the best that can be done right now. Thanks for all the answers.
wastvedt
 
Posts: 4
Joined: Mon Feb 03, 2014 6:51 pm


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 18 guests