Sublime Forum

Issue with load_resource apparently not working from within .sublime-package

#1

Hello!

I’m losing my mind trying to figure out how to properly load resource in order to read all snippets from “snippets” subfolder in our SublimeKSP plugin. It works perfectly fine as loose package, but as soon as it’s packed into .sublime-package, we come up with bupkus and nothing gets added to completions (which for our plugin means snippets work fine in ST3 but NOT in ST4!).

The code is here

And I know it looks ugly, I only just now discovered it could’ve also been done like this:

from sublime_lib import ResourcePath
snippets_path = ResourcePath('Packages', __package__, 'snippets')
snippet_list = snippets_path.children()

But I tried this too and it also came up with an empty snippet_list once it’s inside .sublime-package.

Help? Thank you!

0 Likes

#2

Managed to get an anser on the very helpful ST Discord!

This turned out to be a plugin lifecycle thing. I was doing load_resource in the global area of my root plugin file, possibly before API was even loaded. I needed to wrap this completion stuff in an def plugin_loaded().

Phew!

1 Like