tonsky / sublime-profiles

Profile Switcher for Sublime Text
MIT License
82 stars 3 forks source link

Merge preferences with default ones #6

Open tbruckmaier opened 3 years ago

tbruckmaier commented 3 years ago

Hi, thanks for your package, very useful! I think it would be even more handy, if the preferences of a certain profile would be merged with the default ones in User/Preferences.sublime-settings (and not completly overwritten).

There are some settings, which make sense to be the same in all profiles (hardware_acceleration, ignored_packages, dictionary, ...). Right now, I have to manually sync them.

This would be a breaking change, but maybe it can be an option per profile at least?

tonsky commented 3 years ago

My motivation for not merging was that I specifically didn’t wanted to undo settings that I make in my default profile.

But your use-case seems valid as well. Maybe non-default profiles can have a key in them that would define if default should be merged in? Something like profiles.merge_default which defaults to false if not specified?

Would you be willing to provide a PR?

tbruckmaier commented 3 years ago

Yes, I can do that, though it might take a while.. if anyone else wants to step in, go for it

tbruckmaier commented 3 years ago

Hey, just had a look at the code. It seems that right now, the config files get just renamed, and the config values itselves are never touched/parsed in python.

For this issue to be solved, we would have to implement the parsing & merging in python, and write the resulting merged dictionary to Preferences.sublime-settings. That would loose all formatting in that file though (order & comments). I have a lot of comments in my Preferences.sublime-settings file and would like to keep them. If we dont want to loose that information, we would need a workflow which backs up all profile files, and some way to switch back to the original?

I don't see a clean way how that could be implemented, so I leave it like that for now and just copy the duplicated config values. No need to make this perfectly fine plugin too bloated for little functionality gain, what do you think?

tonsky commented 3 years ago

Interesting! I lost hope in keeping comments in the config long ago. I think if you change anything through command (e.g. color scheme) ST reformats and deletes any comments? Anyways, I learned the hard way not to keep anything there.

But I agree it’s a loot of work and a lot of decisions. We’ll also need a way to store default prefs somewhere, as well as unmodified versions of profiles and merged ones.

It was a nice idea though, thank you for it! One day, maybe...