Sublime Forum

Accesing plugin resources in ST3

#1

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

0 Likes

#2

Use “Packages/RuleEditor/RulePack.tmLanguage”. This will be accepted in every version.

0 Likes

#3

Thanks! Didnt try with hardcoded forward slashes but it works!

0 Likes