-
Notifications
You must be signed in to change notification settings - Fork 23
/
KiteSublime.py
72 lines (53 loc) · 2.12 KB
/
KiteSublime.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from .setup import *; setup_all()
from .lib.languages import Languages
import sublime
if int(sublime.version()[0]) < 3:
sublime.error_message(
'Package KiteSublime does not work on your version of Sublime.\n\n' +
'Sublime will disable this package.'
)
raise ImportError('unsupported Sublime: {}'.format(sublime.version()))
import sys
if sys.platform not in ('darwin', 'win32', 'linux', 'linux2'):
sublime.error_message(
'Package KiteSublime is not supported on your OS.\n\n' +
'Sublime will disable this package.'
)
raise ImportError('unsupported platform: {}'.format(sys.platform))
from .lib import app_controller, deferred, logger, reporter
from .lib import installer, onboarding, settings
from .lib.commands import *
from .lib.handlers import *
_consumer = None
def plugin_loaded():
"""Called when the plugin is first loaded. Sets up an exception handler
to forward uncaught exceptions to Rollbar, instantiates a single consumer
instance to handle deferred events, and locates and starts the Kite
Engine if available.
"""
app_controller.locate_kite()
kite_installed = app_controller.is_kite_installed()
if not kite_installed:
installer.install_kite()
elif reporter.check_reporting_enabled():
reporter.setup_excepthook()
global _consumer
_consumer = deferred.consume()
setup_completion_rules()
if kite_installed:
if settings.get('start_kite_engine_on_startup', True):
app_controller.launch_kite_if_not_running()
if settings.get('show_help_dialog', True):
onboarding.open_tutorial(Languages.PYTHON)
logger.log('Kite v{} activated'.format(package_version()))
def plugin_unloaded():
"""Called before the plugin is unloaded. Stops the consumer immediately
without waiting for the queue to be empty and removes the uncaught
exception handler. Also removes the Kite status from all the currently
open views.
"""
if _consumer:
_consumer.stop()
reporter.release_excepthook()
StatusHandler.erase_all_statuses()
logger.log('Kite deactivated')