Sublime Forum

Extend syntax definition from user folder?

#1

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: https://forum.sublimetext.com/t/extend-syntax-definition-from-user-folder/147/2&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!

0 Likes

#2

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.

0 Likes

#3

I think maybe you can delete internal javascript syntax, and put your defition syntax to user folder.

0 Likes

#4

Ok. Thanks for the verification.

So how does the syntax additions of a plugin like jQuery (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?

0 Likes

#5

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.

<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.

0 Likes

#6

Ok. That seems the best that can be done right now. Thanks for all the answers.

0 Likes

Extend syntax definition from user folder