Sublime Forum

Package menu in ST2?

#1

Hi all,

sorry if this has been mentioned before—I could not find a reference to it. How do I create a "Packages | " submenu in ST2? I would really like to port my LaTeX plugin to ST2. Converting the existing package-menu file (in the LaTeX subdirectory) to JSON does not seem to work, but perhaps I am doing something wrong.

Thanks!
Marciano

0 Likes

#2

Package menus aren’t supported yet in Sublime Text 2, but they will be in the future.

0 Likes

#3

OK, thanks. Can I define package-specific keybindings? I tried creating a file called “Default (OSX).sublime-keymap” with the same JSON syntax as the file by the same name in “Packages/Default” (with an additional keybinding), but that did not seem to do anything. That is, the new key binding was not recognized.

Thanks again! M

0 Likes

#4

OK, I think I answered my own question. You must explicitly add your key bindings using the Preferences | User Key Bindings menu. That’s OK for now.

0 Likes

#5

You can create extra package-level key bindings, but you’ll have to restart after doing so.

For example, if you save this:


	{ "keys": "ctrl+k", "ctrl+q"], "command": "show_about_window" }
]

In Packages/Python/Default (Windows).sublime-keymap, then on next startup, you should see this in the console:

found 3 files for base name Default (Windows).sublime-keymap

Which indicates the extra file is being read in.

0 Likes

#6

I have a question regarding plugin specific keymapings.

I have a plugin, I added the keymaping to the Default (OSX).sublime-keymap, everything worked just smooth as a peach.

Then I decided I wanted my plugin to use it’s own keybindings so that I can keep the keybindings and plugin together.
So when I copied the Default (OSX).sublime-keymap to plugin_name.sublime-keymap, cleared the default one, restarted, and now I get this error:
no command for selector: noop:

is this expected behavior?

Thanks
n

0 Likes

#7

That message is unrelated, and can be ignored.

Only keymaps named “Default ().sublime-keymap” are used, any other files will be ignored.

0 Likes

#8

Jps,

Grand thanks. Is there plan to support other keymap named files?

N

0 Likes

#9

Yes, but you don’t need them for this.

Just make a set of Default (XXX).sublime-keymap files in your package directory, and they’ll get merged into the key bindings on load.

0 Likes

#10

jps,

So that being said if I were to do something like this:

Default (python_debugger).sublime-keymap

That should get merged into the keybindings on load, right?

n

0 Likes

#11

You need to put the platform name there:

Default (Windows).sublime-keymap
Default (OSX).sublime-keymap
Default (Linux).sublime-keymap
0 Likes

#12

Perhaps it would make sense to have one file with key bindings that are common to all platforms, say Default.sublime-keymap, and then the three files you mentioned for platform-specific key bindings (with those taking precedence over the generic file in case of a conflict)?

0 Likes

#13

That would be good. As an alternative, an “include” directive would also work.

0 Likes

#14

BTW, merging in package menus is now fully supported in S2! You also have the option to place a menu as high as the main menubar too. Context menus also have merge support.

0 Likes