Sublime Forum

Setting syntax file based on file extension in ST3

#1

My sublime-github plugin uses a pretty hacky method of setting the syntax file for a gist based on that gist’s file extension: 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?

0 Likes

#2

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

0 Likes

#3

Perfect! Thank you.

0 Likes