Sublime Forum

Allow organizing User files in sub directories

#1

I’m pretty sure this has been asked already in the past, but I couldn’t find anything via the forum search, so here goes. My User directory has grown quite a bit, to the point that it’s getting difficult to manage. As of today it consists of 95 files (and still growing)!

~/svn/sysconf {dev}$ ls home/.config/sublime-text/Packages/User/
__pycache__                        git_log.py                                          quick_find.py
ANSIescape                         git_show.py                                         refresh.py
Log Highlight                      git_squash.py                                       reindent.py
Projects                           git_stash.py                                        rm_comments.py
snippets                           git_status.py                                       save_cursor_positions.py
tests                              GitGutter.sublime-settings                          scroll.py
__init__.py                        github.py                                           selection.py
Adaptive.sublime-theme             goto.py                                             sidebar.py
builds.py                          increase_decrease.py                                Side Bar.sublime-menu
C.sublime-settings                 INI.sublime-settings                                SingleTrailingNewLine.sublime-settings
clear_console.py                   linters.py                                          smart_goto.py
Color Highlight.sublime-settings   list_all_cmds.py                                    smart_paste.py
create_snippet_from_sel.py         LSP-bash.sublime-settings                           smart_wrap_text.py
Default (Linux).sublime-keymap     LSP-pyright.sublime-settings                        status_bar.py
Default.sublime-commands           LSP.sublime-settings                                SublimeLint.sublime-settings
Default.sublime-theme              Monokai.sublime-color-scheme                        SublimeLinter.sublime-settings
Default Dark.sublime-theme         Monokai.tmTheme                                     Tab Context.sublime-menu
Distraction Free.sublime-settings  Monokai Pro (Filter Spectrum).sublime-color-scheme  tabs.py
edit_settings.py                   move_focus.py                                       Terminus.sublime-settings
events.py                          Origami.sublime-settings                            toggle.py
exec_last_cmd.py                   OverrideAudit.status                                TOML.sublime-settings
file.py                            Package Control.sublime-settings                    unittesting.json
FileHistory.sublime-settings       Package Control.user-ca-bundle                      utils.py
find_results.py                    PanePane.sublime-settings                           utils_base.py
Flake8Lint.sublime-settings        Preferences.sublime-settings                        utils_command.py
Git.sublime-settings               prettify.py                                         utils_db.py
git_branches.py                    pydoc.py                                            utils_git.py
git_checkout.py                    Pylinter.sublime-settings                           utils_input.py
git_commit.py                      pylinters.py                                        utils_settings.py
git_diff.py                        pypaths.py                                          utils_ui.py
git_files.py                       Pytest This.sublime-build                           utils_view.py
git_grep.py                        Python.sublime-settings                             

It would be nice if ST allowed to organize User files in sub directories. I suppose this could be achieved via a new setting/preference such as:

    // A list of sub-directories relative to the User/* directory where
    // ST will look for plugins, themes, settings, etc.
    "user_sub_directories": [
        "keymaps",
        "settings",
        "color-schemes",
        "themes",
        "plugins",
        "builds",
        "menus",
    ]

It must be noted that ST already allows to put snippets in a separate directory (e.g. User/snippets/*).

Thoughts?

0 Likes

#2

Settings, keymaps, … are picked up from sub directories, too.

It’s just the plugins which may require some extra work to expose all API classes to ST. Or maybe just create a “User Plugins” package to group them. I have a “Default Extended” for instance, which contains everything which should be default behavior.

The main issue is location of settings, keymaps, mousemaps and various other package/plugin related resources is controlled by plugins themself. And those put all user relevant files directly into User package. There’s little ST core can do about it.

0 Likes

#3

You can put all of your plugins in a separate folder in the Packages/ directory (That’s what I do). As long as they are at the top level, everything will still continue to work.

1 Like

#4

Hi @deathaxe @OdatNurd or anyone who might have the insider knowledge -

I have a followup question. I did an experiment today with my Sublime Text 4 (4183).

  1. I found the user-defined keymap files, e.g. Default (OSX).sublime-keymap, are still picked up even if I put it in a sub-directory inside User, e.g. in User/keymaps/. That is, it works.

  2. But the Preferences.sublime-settings file is not picked up if I put it inside a sub-directory in User, e.g. User/settings/. That is, Sublime Text has no idea that there is such a sublime-settings there.

My understanding is that both the keymap files and the preferences file are application-level configuration, not plugin-level configuration. Can you please explain about the difference - why the keymaps can be put inside a sub-directory inside User, but the preferences cannot be so? Can you please talk a little bit more about the mechanism that Sublime Text scans the User directory and picks up the configuration files?

(Note - I do have some prior knowledge that a config file can be picked up at default / user-global / user-project levels. No questions about that part.)

Thanks!

0 Likes

#5

I’d blame implementation details for different behavior.

All sublime-keymap files are merged and applied globally, without considdering file path or file name, except platform identifier (e.g. (OSX)).

Preferences.sublime-settings files are picked up from any sub-directory of any package (except User as you found out).

It’s most likely caused by the special loading hierarchie to pickup settings from various (global and local) sources like * .sublime-project files, and views (see: https://www.sublimetext.com/docs/settings.html#settings-files).

It is probably a design decision. Note that edit_settings command always and only opens Packages/User/Preferences.sublime-settings on the right. It would require quite some extensions to support other or even multiple locations.

1 Like

#6

Thanks for the explanation! It’s clear to me now.

0 Likes