-
Notifications
You must be signed in to change notification settings - Fork 7
/
events.py
48 lines (34 loc) · 1.28 KB
/
events.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
import sublime
import sublime_plugin
class ActiveServerStatusBar(sublime_plugin.EventListener):
SETTINGS_FILE = 'Elasticsearch.sublime-settings'
def update_status_bar(self, view):
sublime.set_timeout_async(lambda: self._update_status_bar(view))
def _update_status_bar(self, view):
settings = sublime.load_settings(self.SETTINGS_FILE)
base_url = settings.get("base_url")
index = settings.get("index")
doc_type = settings.get("doc_type")
options = dict(
base_url=base_url,
index=index,
doc_type=doc_type
)
if view is not None:
view.set_status(
"elasticsearch-client",
"Elasticsearch: {base_url}".format(**options))
def on_new(self, view):
self.update_status_bar(view)
def on_load(self, view):
self.update_status_bar(view)
def on_activated(self, view):
self.update_status_bar(view)
def on_deactivated(self, view):
self.update_status_bar(view)
def on_post_save(self, view):
self.update_status_bar(view)
def on_pre_close(self, view):
self.update_status_bar(view)
def on_window_command(self, window, command_name, args):
self.update_status_bar(window.active_view())