Home Download Buy Blog Forum Support

Accesing plugin resources in ST3

Accesing plugin resources in ST3

Postby alvms on Mon Jun 17, 2013 1:48 pm

Hi,

In ST2 I had the following event listener:
def on_load(self, view):
if view.match_selector(0, "text.xml"):
if view.find('<RulePack', 0) or view.find('<Rules', 0):
print("Setting Rulepack syntax")
view.set_syntax_file(os.path.join(sublime.packages_path(), 'RuleEditor', 'RulePack.tmLanguage'))

In ST3 (MacOS) I needed to change it to a static "Packages" folder:
def on_load(self, view):
if view.match_selector(0, "text.xml"):
if view.find('<RulePack', 0) or view.find('<Rules', 0):
print("Setting Rulepack syntax")
view.set_syntax_file(os.path.join('Packages', 'RuleEditor', 'RulePack.tmLanguage'))

The problem I have is that it only works in MacOS, On Windows, it complains about not been able to access the syntax file.

What is the right way to access plugin resources cross-platform in ST3?

Thanks,
A
alvms
 
Posts: 26
Joined: Sun May 26, 2013 9:15 pm

Re: Accesing plugin resources in ST3

Postby jps on Tue Jun 18, 2013 1:41 am

Use "Packages/RuleEditor/RulePack.tmLanguage". This will be accepted in every version.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Accesing plugin resources in ST3

Postby alvms on Tue Jun 18, 2013 8:57 am

Thanks! Didnt try with hardcoded forward slashes but it works!
alvms
 
Posts: 26
Joined: Sun May 26, 2013 9:15 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 9 guests