There are a lot of bugs when it comes to the Sublime Text settings system. Iāll be making my own to solve some of themā¦ There isnāt true inheritance which is annoying for someone trying to edit one key of a table instead of replace the entire thing.
Also, when a plugin is installed, it seems as though the settings file wonāt properly load until Sublime Text restarts - this may be how Iām using the code, but I only grab the data for it after the Plugin is initialized and that should only happen when fully installed and then loadedā¦ the keys will show up as None until the restart even if you change them.
I have experimented with settings files in different directors - and Sublime doesnāt support it by defaultā¦ It exists the main settings files to be in your package folder, and then all of the User edited variants to be in the User/ folder without being in the package directory which I believe to be a fault of Sublime Text as that folder will get crowded and if the settings file isnāt named in such a way to properly identify the plugin it is associated with then that can lead to other issuesā¦
This is why I wanted to keep the User plugin file in my package folder and the defaults I wanted organized in a settings/ folder in my installed package folder.
It is possible if I recall correctly that you can read the data, but the user canāt edit - or youād have to load 2 separate files - 1 default and 1 userā¦ and do the inheritance manually.
There were a lot of problems involved with trying to load a settings file from a different folder than authorizedā¦ It was such a big issue, I opened an issue report to see if they could alter the behavior of where Sublime Text looked for the fileā¦
There is also another problem, I have 4 or 5 settings files and my code is simple - it tries reading a settings file key from one area, and the default redirects it to the next file in the chain all the way through until trying to read the Sublime Text Syntax settings file then the Sublime Text Default settings fileā¦ The cost for this operation should be minimal since the data is pre-loadedā¦ Doing something like this is O( 1 ), technically, and the actual cost should be negligible but with Sublime Text, accessing the keys is actually very expensiveā¦ Another reason I want to make my own system.
I still need to open an issue report because of how expensive it is to get the data from multiple objectsā¦ It was such a big problem, I had to code different getters for each settings file and hard-code to use the right file in certain areas of my pluginā¦ It shouldnāt be as expensive as it is - it should be a negligible cost, barely noticeable when doing thousands of requests, but it can cost seconds of time for a small amount of requestsā¦ I still need to figure out if it is because of the User file, or whatā¦
This is what I am doing:
return self.GetRunTimeSetting( _key, self.GetDefinitionsSetting( _key, self.GetSyntaxSetting( 'acms_' + _key, self.GetMapSetting( _key, self.GetPluginSetting( _key, self.GetPanelSetting( _key, _default ) ) ) ) ) )
which, basically each one has this set now:
def GetSettingsObject( self, _name = '' ): return sublime.load_settings( _name )
## Plugin RunTime Settings
__settings_file_runtime__ = 'ACMS_RunTime.sublime-settings'
def GetRunTimeSettingsFileName( self ): return self.__settings_file_runtime__
def GetRunTimeSettingsObject( self ): return self.GetSettingsObject( self.GetRunTimeSettingsFileName( ) )
def SaveRunTimeSettings( self ): return self.SaveSettings( self.GetRunTimeSettingsFileName( ) )
def HasRunTimeSetting( self, _key ): return self.GetRunTimeSettingsObject( ).has( _key )
def GetRunTimeSetting( self, _key, _default = None ): return self.GetRunTimeSettingsObject( ).get( _key, _default )
def SetRunTimeSetting( self, _key, _value = None ): return self.GetRunTimeSettingsObject( ).set( _key, _value )
with the first one being the base of allā¦ and routing through that setup shouldnāt add much to a negligible costā¦