Sublime Forum

User Niceties

#1

A few post-publishing questions:

  1. I could have sworn that my commands were previously showing up in the Command Palette but they are not as a downloaded package (and I may be misremembering entirely.) Is there something special I need to do to get commands listed there? My snippets do show up in the snippets selection box, just not commands.

  2. I realized that many packages have nice options available in Preferences >> Package Settings and so I should probably emulate that, since I do have a settings file in there. Are there any best practices there? I can probably just crack open one of the packages I see that does have a settings entry and just see how they did it, but I figured it couldn’t hurt to find out what NOT to do also.

0 Likes

#2

1

IIRC it behaves a bit different if your package is in Packages or in User.

2

IMO Gitgutter gets it right by also having the two panes with default and user config. So, that’s the one to steal borrow from.

0 Likes

#3
>>> import sys
>>> vhdl = sys.modules["VHDL Mode"]
>>> dir(vhdl.vhdl_mode)

this will print your commands. However in your repo I don’t see a .sublime-commands file. You need that in order for the commands to show up in the command palette. Docs here.

Yes, that’s the way to do it :wink:

1 Like

#4

Okay thanks. sublime-commands and I think Emacs Pro Essentials has a nice Preferences menu entry so I will emulate that for sublime-menu!

0 Likes

#5

May be worth to add that GitGutter has a different behavior in builds newer than 3124 than in older builds, because the default preferences also changed there. If you publish a new package I would only publish it for 3124 and newer builds and just use the edit_preferences command instead of using the visibility solution done by GitGutter.

0 Likes

#6

I’ll look up edit_preferences. I’m not sure I’ve seen how that works or seen it used yet.

0 Likes

#7

I used it in a package I am going to publish. Just use this file and change the caption and path to VHDL Mode.

2 Likes

#8

PS: You should locally rename the package folder from vhdl_mode to VHDL Mode to avoid upcoming bugs :wink:

0 Likes

#9

Hehe, thanks. Yeah I caught that too. So I made those changes and then copied files into my sublime-package file. And it seems to work except the console is throwing a couple of errors at the same time.

I have:

                            {
                                "caption": "Settings",
                                "command": "edit_settings", "args":
                                {
                                    "base_file": "${packages}/VHDL Mode/vhdl_mode.sublime-settings",
                                    "default": "{\n\t$0\n}\n"
                                }
                            },

And like I said, if I use that menu option (it’s showing up properly) it seems to open a new window with side by side frames with the settings and a new file in User that’s blank. In the console it says:

Unable to open /C/Users/mnorton/AppData/Roaming/Sublime Text 3/Packages/VHDL Mode/vhdl_mode.sublime-settings
Unable to open /C/Users/mnorton/AppData/Roaming/Sublime Text 3/Packages/User/vhdl_mode.sublime-settings

Is this just because it’s trying a couple of different locations for the User’s preferences and neither exist yet?

EDIT: Yeah I guess there’s just a hierarchy of places it checks. I wrote new settings entries and saved. Next time it only complained about not finding “VHDL Mode” directory settings (the first of the messages). The User error went away. I tried out a function that utilised the settings, and it picked up the user defined ones, so I guess I’m all good.

0 Likes