Use edit_settings command instead of open_file in Main.sublime-menu
jim-hart opened this issue · 3 comments
Setting definitions are currently defined with the following pattern in Main.sublime-menu
:
{
"caption": "Settings – Default",
"command": "open_file",
"args": { "file": "${packages}/Conda/Conda.sublime-settings", "platform": "Platform" }
}
This works without issue, but this method comes with the following caveats:
- We have to open the Default/User options separately
- Platform specific options must be defined for all supported platforms (each with their own
Default
andUser
component)
We can address both of these using the edit_settings
command, which sublime uses by default for its own settings. The entirety of the children
key can be replaced with a single command definition:
{
"caption": "Settings",
"command": "edit_settings",
"args":
{
"base_file": "${packages}/Conda/Conda (${platform}).sublime-settings",
"default": "{\n\t$0\n}\n"
}
}
The ${platform}
environment variable takes care of our platform component. If user settings aren't defined, the default
value creates a blank template that matches the POJO containing the default, platform specific settings.
The nice part about edit_settings
is that both the default and user settings are opened side by side, which allows for easy editing and customization.
While consolidating User
and Default
options to a single Settings
label changes the menu layout for the plugin, the new behavior matches that of editing Sublime's native options, so the end result should be a familiar experience.
I don't feel the current menu-options are a negative aspect of the plugin; this pattern is common among many popular packages, and I've used it in personal plugins as well. While sublime does a lot of things well, its documentation leaves something to be desired at times. I only recently came across edit_settings
(you can find usage of it in Default.sublime-commands
), and after putting into my own projects, overriding defaults is now much easier.