I have a plugin with several pieces: snippets, syntax files and tests, and soon a couple of build systems. This gets messy when the files are all in the root of the plugin folder, along with Package Control stuff, so I have put them in subfolders:
. ├── Build Systems │ └── Check Justfile.sublime-build ├── Snippets │ └── bash.sublime-snippet ├── Syntax │ ├── Just.sublime-syntax │ └── tests │ ├── etc.
This is fine for most things, but now my Build System has become more complex than can be managed with a simple
.sublime-build file. I need to define my own command, subclassing
sublime_plugin.WindowCommand. This, in turn, needs to go inside a
.py file. I’ve named mine
check_justfile_build.py. But when I place that file inside the
Build Systems folder, it is never loaded because (as I understand it) Sublime only looks in the plugin root to load
.py files. But I’d really like to keep each category of resource files together.
As a workaround for this, I’ve had success with renaming the folder and putting this in a
.py file in the package root:
from .BuildSystems.check_justfile_build import CheckJustfileBuildCommand
Although that doesn’t work in this particular case because “Build Systems” has a space in it. I tried the following, but it fails with
No module named "Build Systems":
import importlib importlib.import_module("Build Systems.check_justfile_build.CheckJustfileBuildCommand")
I’d be grateful for a pointer to some best practice examples of well-structured packages with multiple different categories of Sublime resources including
.py files. I can’t be the first person to run into this?