I screwed around a bit and here is my attempt:
_BUILD_SYS_HANDLES = dict()
buildhandle = _BUILD_SYS_HANDLES[window.id()]
if isinstance(buildhandle, int):
elif isinstance(buildhandle, str) and buildhandle != "":
def on_window_command(self, window, command_name, args):
if command_name != 'set_build_system':
index = args.get('index', None)
if not index is None:
_BUILD_SYS_HANDLES[window.id()] = index
_BUILD_SYS_HANDLES[window.id()] = args.get('file', None)
print(_BUILD_SYS_HANDLES) # debug
This almost works... It works when the user selects a build system after the plugin is loaded. On startup however, every window gets its selected build system in some way and that doesn't get caught by this event listener. So, this is pretty much unreliable.
If Sublime Text would issue the "select_build_system" command for each of its windows after all the plugins are loaded, this would actually work.