In my CursorRuler plugin I use the following at the top to determine the ST build version before anything else happens:
[code]import sublime
It’s important for us to know if we’re running in ST3 or ST2.
Build 3010 and older of the Sublime Text 3 builds do not have the API
available during program startup. As of build 3011 sublime.version()
is available during startup. If we’re unable to get the version build
number we make the assumption that it’s 3000.
We’re also assuming that if we’re not in ST3 then we’re in ST2.
st = 3000 if sublime.version() == ‘’ else int(sublime.version())[/code]
This helps us keep the behavior of the special plugin_loaded() function consistent between ST2 and ST3:
[code]# In ST3 this will get called automatically once the full API becomes available.
def plugin_loaded():
CursorRuler.init()
if st < 3000:
plugin_loaded()
[/code]
Using the build number allows us to properly handle build-specific issues. In my plugin I dealt with inconsistent support for the add_on_change() method in this way:
[code]
@classmethod
def init(cls):
plugin_name = os.path.basename(file):-3]
cls.editor_settings = sublime.load_settings('Preferences.sublime-settings')
cls.settings = sublime.load_settings(plugin_name + '.sublime-settings')
# In Sublime Text 3 the `add_on_change()` method
# was not implemented until build 3013.
if st < 3000 or st >= 3013:
cls.editor_settings.add_on_change(plugin_name.lower() + '-reload', cls.__setup)
cls.settings.add_on_change('reload', cls.__setup)
cls.__setup()[/code]
Perhaps nowadays checking for add_on_change() support is unnecessary but you know what I mean 