Sublime Forum

Load Settings Issues

#1

I’m having some issues with sublime.load_settings…

I have my default settings files in

%AppData%\Sublime Text 3\Packages\AcecoolCodeMappingSystem\settings\

The user settings files are in

%AppData%\Sublime Text 3\Packages\User\AcecoolCodeMappingSystem\settings\

I have a file named plugin_runtime.sublime-settings with 3 main values in the user file ( source_file - which is a short filename, source_path - full path to the file, and source_ext which is the source file extension )

When I load settings - none of the values properly get red until I load settings and set them - if I save them, the values save properly to the correct user folder settings files - but loading on plugin_loaded shows them as unset even if the file shows as set… and saving to the same path works fine…

I’ve also tried loading from the full path sublime.packages_path( ), ‘AcecoolCodeMappingSystem’, ‘settings’, ‘plugin_runtime.sublime-settings’ using os.path.join…

It doesn’t work and there are so many issues… I submitted one - I can load from the full path to file with sublime.packages_path( ) and the data is read… BUT if I set a value and try saving to that same exact path I can’t because Packages/User/ is prefixed to save_settings by default…

And, if I save to just AcecoolCodeMappingSystem/settings/plugin_runtime.sublime-settings then the file ends up blank ( because the full path and short path are different strings, even though they lead to the identical file…

On top of this, it seems like it loads the main plugin file AND the user file at the same time - this wouldn’t be an issue, but the default file has everything set as null… is it overwriting the user file when sublime text opens up because I’m only saving if the values are set to non None and non empty string…

This is really frustrating - the logic is sound but the way the paths are set up is annoying…

Is there any way to parse the files manually? Then I can simply load the file directly until the issue is resolved ( and I’m not going to put the settings files in the root plugin or User directory because I plan on having many settings files for each language, possibly extension and each syntax in addition to others as I expand the plugin )…

Parse the files manually on load into a Dict, and converting that dict back into json? - is there a built in feature on doing this or do I have to write my own?

I basically set my plugin to load all settings files on plugin_loaded into self.settings[ _name ] ( I had it separated so settings and settings_user but since load_settings may be loading both at the same time I got rid of it ) - but I see no difference… the issues are still there… the data is only ‘set’ when I set the data despite trying to load / save to identical paths, or trying to load / save to full path and shortened path… it just doesn’t work in nested folders…

There seems to be no standard to using these functions because loading with full path works but if you try saving using anything other than the path used to load it and you end up with a blank file. Even with the correct path to save - the file doesn’t load at all… or it loads only the default file which is all blank with comments stating what each key / value pairing is for – and not the user file which has values assigned ( but then they get deleted on load_settings … )

Any help is appreciated.

0 Likes