How to add/remove a default menu entry when a X package is/isn’t enabled/installed?
On the default Sublime Text Context.sublime-menu
file there is this line, which only show on the real menu, when Goto Definition
command is available:
{ "command": "context_goto_definition", "caption": "Goto Definition" },
class ContextGotoDefinitionCommand(sublime_plugin.TextCommand):
def run(self, edit, event):
pt = self.view.window_to_text((event["x"], event["y"]))
symbol, locations = symbol_at_point(self.view, pt)
navigate_to_symbol(self.view, symbol, locations)
def is_visible(self, event):
pt = self.view.window_to_text((event["x"], event["y"]))
symbol, locations = symbol_at_point(self.view, pt)
return len(locations) > 0
def want_event(self):
return True
Now I want to do something similar. How to enable this menu entry below, only when there is not available/enable/installed the package SyncedSideBar
?
{ "command": "reveal_in_side_bar", "caption": "Reveal in Side Bar" },
I could think about a dedicated plugin to detect whether the SyncedSideBar
package is available and insert it into the Context.sublime-menu
when is is not available and to remove it when it is available. Is it the only way?
I want to this because the package SyncedSideBar
became the menu entry Reveal in Side Bar
not useful as it is always revealing it on the side bar.
But sometimes, you want to disable the package SyncedSideBar
because it causes trouble, then the menu entry Reveal in Side Bar
is necessary/useful again.