Sublime Forum

Can the API retrieve key values from a .sublime-settings kept in a deeply nested folder structure?

#1

I was actually curious on how deep can one nest a .sublime-settings file and the API still be able to retrieve the key ?
For example I kept a settings file in a 5 layer nested deep folder and was still able to retrieve key values in a python file kept in the root directory.

0 Likes

#2

With the exception of the User package, Sublime will find and load a sublime-settings file no matter where it’s stored inside of a package, so your plugin can use load_settings() to get at the settings contained in them regardless of the location they’re in.

The User package is special; Sublime will only find and load sublime-settings files that are at the root of the package and other settings files are ignored. This is because save_settings() writes the settings file to the root of the package (it can’t know to put it in some other folder) so it only loads files from the root as well. Otherwise it would be possible for you to “lock” a setting and make it unchangeable by putting a sublime-settings file in a folder in the User package where Sublime can’t write to it to change it.

2 Likes

#3

That’s some food for thought. I actually rummaged through the sublime.py file to see how the sublime.load_settings() works but there was again something on the lines of sublime_api.load_settings() and since I wasn’t able to find any sublime_api files, I guessed, it must be some file that interfaces with the low level C++ API which one can’t access.

0 Likes