elm-community / SublimeElmLanguageSupport

Elm language syntax highlighting and tool integration for ST2/3.

Home Page:https://packagecontrol.io/packages/Elm%20Language%20Support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Global user preferences don't work in ELS.

bholtbholt opened this issue · comments

I set all my package settings in my global user settings: Preferences.sublime-settings. They look like:

{
  "auto_complete": true,
  "color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",
  ... etc
  "js_prettier":
  {
    "auto_format_on_save": true,
    "prettier_cli_path": "node_modules/.bin/prettier",
    "prettier_options":
    {
      "printWidth": 120,
      "singleQuote": true,
      "trailingComma": "all"
    }
  },
}

I expected to be able to do this with Elm Language Support, but it doesn't appear to work. The settings I've added are:

"elm_language_support":
{
	"elm_format_on_save": true,
	"elm_paths": "/usr/local/bin/:/usr/local/bin/elm-oracle"
},

The only way I can enable ELS is by following the instructions in the readme

Preferences -> Package Settings -> Elm Language Support -> User

Is it possible to enable global user preferences in ELS?

The difference I've noticed in this package vs other packages is the file name, and I wonder if that is what causes it not to work. For example, JS Prettier and Emmet both have a Main.sublime-menu file that import the settings file. I don't know if that's it, but I hope it helps.

Thanks for putting this package together!

@bholtbholt Putting package settings in your global user settings file like that is not recommended. It's not how Sublime Text's settings system was designed to be used, and it only works in packages like JS Prettier and Emmet because of how those packages have chosen to support project-specific settings.

The reason this works in packages like JS Prettier and Emmet, is that they support project-specific settings. Here's the code in JS Prettier that does this: JsPrettier.py lines 762-766

As you can see in the ST3 docs, you're supposed to put settings that you want only to affect a specific project in the .sublime-project file, to override the settings in your global user settings file. But because of the way ST3 settings work, if your global user settings file happens to contain settings for the package in question and your project-specific file doesn't, then the global settings will be used as the project-specific settings.

So on the one hand, could/should Elm Language Support add support for project-specific settings? Yes, I think that would be a good idea, and I'll open a separate issue for that.

But I don't think it's a good idea to go putting all your package settings in your main user preferences file. First of all, many packages (just like this one) don't support loading settings from there. Secondly, if you ever do want to use package-specific settings to override one or two of your package settings for a particular project, you will have to duplicate all of your settings for that package, because the globally-set values won't carry over into the project once you have overridden them in the project file.

Instead, I recommend you use a separate package user settings file for each package that you want to customise. That's how Sublime Text's settings system was designed to work, and that way you can set all your “standard” preferences for a package there, and then just override one or two of them in a project-specific settings file if you want to, without having to duplicate all the other settings for that package in the project file.

Hope that makes sense!

Tracking project-specific settings here: #30

@sentience Thanks for the explanation 😄