bcomnes / sublime-standard-format

:sparkles: Runs standard --fix against the javascript in your ST3 window on save or manually.
https://packagecontrol.io/packages/StandardFormat
MIT License
60 stars 21 forks source link

Feature Request: Ability to set config on per-project basis #66

Closed moltar closed 4 years ago

moltar commented 7 years ago

Use case: some older/legacy projects do not want to be "standardized". Now, I have "format on save" turned on, and it's a global settings. Forgetting to turn it off, when switching to legacy projects, causes a lot of undesirable rewriting to happen.

Would be great to have the ability to disable format on save, and maybe other settings on per-project basis.

Thanks.

bcomnes commented 7 years ago

Format on save is disable'able. Check the command palate for https://github.com/bcomnes/sublime-standard-format/blob/master/Main.sublime-menu#L74 (Format on Save)

Per project auto enable/disable:

If the plugin can't find standard in its search path, it will not perform a format, even if format-on-save is turned on. You can take advantage of this behavior to automatically enable and disable the plugin. The only requirement is that 'standard' is not installed globally, or you disable the global search path if you require a global install (https://github.com/bcomnes/sublime-standard-format/blob/master/StandardFormat.sublime-settings#L12)

The way you do this is by installing standard as a dev-dependency to projects that you want to be standardized. When you open these projects, if sublime-standard-format finds standard inside the search PATH (including local node_modules/.bin relative to the open file or project), it will try to format the file, if Format on Save is enabled.

moltar commented 7 years ago

Thanks, I was thinking of this solution too. I guess it'd work for now. But still, would be good to have settings per project :)

bcomnes commented 7 years ago

Where would you suggest the settings live? Package.json? Sublime Project file settings?

moltar commented 7 years ago

Sublime Project settings I think would be best.

bcomnes commented 7 years ago

I don't use those to much, but you are right, that would be a good addition. I've seen that pattern in VS Code recently.

bcomnes commented 4 years ago

Closing for now. If someone wants to work on this re-open or recreate.