Home Download Buy Blog Forum Support

Setting syntax file based on file extension in ST3

Setting syntax file based on file extension in ST3

Postby bgreenlee on Sat Feb 08, 2014 12:35 am

My sublime-github plugin uses a pretty hacky method of setting the syntax file for a gist based on that gist's file extension: https://github.com/bgreenlee/sublime-gi ... #L208-L229

Unfortunately, this no longer works in ST3 because the default .tmLanguage files are packaged in the ST3 executable. Is there some hidden API method that can give me a file type => syntax file mapping? Or should I just dig through the default syntax files and create my own static mapping?
bgreenlee
 
Posts: 22
Joined: Wed Jul 20, 2011 8:02 pm
Location: Seattle, WA

Re: Setting syntax file based on file extension in ST3

Postby skuroda on Sat Feb 08, 2014 2:59 am

You can still access the default files through the sublime-package files. Check the ST3 API. Of interest will be "sublime#load_resource" and "sublime#find_resource". I believe find_resource looked for an exact match, but I'm not 100% sure on that. If it does, I wrote a few helper functions to access sublime-package files (wrote it before the ST3 API was updated). It can be found at https://github.com/skuroda/PackageResources. Of interest is the find_resource method. I don't recall exactly how everything returns (should probably have documented that), but I think it should get you on your way. You may also need to use get_packages_list function. Hope that helps.
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am

Re: Setting syntax file based on file extension in ST3

Postby bgreenlee on Sat Feb 08, 2014 5:26 am

Perfect! Thank you.
bgreenlee
 
Posts: 22
Joined: Wed Jul 20, 2011 8:02 pm
Location: Seattle, WA


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 9 guests