I am writing a sublime plugin for my own use.
We have several projects, each command may apply to each project.
I can hardcode these submenus, but it's not so good.
Can I create these project sub menu dynamically? Many thanks.
You can only create menu items using .sublime-menu
files - you could of course manually create/delete these using a plugin.
However, I would recommend simply hiding menu items that aren't relevant. The TextCommand
, WindowCommand
and ApplicationCommand
all have an is_visible
method that can be overridden. This method gets called every time a menu item references the command. By overriding this method, you can implement some logic to decide whether to show the menu item or not.