Sublime Forum

Sublime Text 3 file icons in sidebar

#21

You explained it well enough, how all this stuff works is confusing at the best of times.

0 Likes

#22

I don’t see anything wrong with this. A good solution.

I disagree.

The syntax specific icon preferences are the syntax domain.

The scope for the icon is defined in the icon preference. If the theme defines it then the dependency is inverted because if the syntax changes the scope then the theme needs to be updated. you may say, well, if the syntax changes the icon then the icon in the theme wont work. True, but if the theme fell back to a default icon it wouldn’t be big deal. The theme just wouldn’t support a specific icon for the syntax until it added an icon for it. There is not much wrong with this. Sometimes you can’t solve every problem.

Also, some themes may support more icons than others. A fallback system is a good solution for this. Otherwise you have every other theme maintaining icon preferences. And their syntax scopes. Every syntax scope changes needs to update every theme. Every new syntax needs to add preferences to all the themes. This is a mess.

I don’t buy this. If they’re just javascript, add it as a file extension to the javascript package.

I think the scope based approach probably works well, except it probably needs to fallback to an existing icon to solve the issues were discussing.

I agree with this. I don’t see how we can agree on this, yet you feel the icon preferences should be handled by the theme.

0 Likes

#23

I can’t afford to spend any more time on this, so unless we get an update from a dev on this, I won’t have anything else to say.

0 Likes

#24

Here is a script I hacked together to generate file icon preferences for one or more packages.

For example, running the script within the sublimehq/Packages will output something like the examples below.

The script could be modified to generate different variations of perferences e.g one for each package, one for each syntax, one for each file extension, all the above. Depends on what direction you would want to go. One for each file extension would allow targeting, in a fine grain way, specific file extension e.g. a different icon for both php and phtml.

This script as of posting, only generates an icon for each package containing the scope for each syntax in the package. But there is an option to also generate an icon for each syntax too. Or just for each syntax.

Examples

Run with only the --package option

=> package: ./TCL
     name: TCL
     icon file type: file_type_tcl
     icon file: TCL/Icon.tmPreferences
     syntax: ./TCL/HTML (Tcl).sublime-syntax
       name: HTML (Tcl)
       scope: text.html.tcl
       icon file type: file_type_tcl_html_tcl
       icon file: TCL/Icon (HTML (Tcl)).tmPreferences
     syntax: ./TCL/Tcl.sublime-syntax
       name: Tcl
       scope: source.tcl
       icon file type: file_type_tcl_tcl
       icon file: TCL/Icon (Tcl).tmPreferences
     scope: text.html.tcl, source.tcl
   created icon preferences file: TCL/Icon.tmPreferences
=> package: ./Text
     name: Text
     icon file type: file_type_text
     icon file: Text/Icon.tmPreferences
     scope: 
=> package: ./Textile
     name: Textile
     icon file type: file_type_textile
     icon file: Textile/Icon.tmPreferences
     syntax: ./Textile/Textile.sublime-syntax
       name: Textile
       scope: text.html.textile
       icon file type: file_type_textile_textile
       icon file: Textile/Icon (Textile).tmPreferences
     scope: text.html.textile
   created icon preferences file: Textile/Icon.tmPreferences
=> package: ./XML
     name: XML
     icon file type: file_type_xml
     icon file: XML/Icon.tmPreferences
     syntax: ./XML/XML.sublime-syntax
       name: XML
       scope: text.xml
       icon file type: file_type_xml_xml
       icon file: XML/Icon (XML).tmPreferences
     scope: text.xml
   created icon preferences file: XML/Icon.tmPreferences
=> package: ./YAML
     name: YAML
     icon file type: file_type_yaml
     icon file: YAML/Icon.tmPreferences
     syntax: ./YAML/YAML.sublime-syntax
       name: YAML
       scope: source.yaml
       icon file type: file_type_yaml_yaml
       icon file: YAML/Icon (YAML).tmPreferences
     scope: source.yaml
   created icon preferences file: YAML/Icon.tmPreferences

Run with both --package and --syntax options

=> package: ./TCL
     name: TCL
     icon file type: file_type_tcl
     icon file: TCL/Icon.tmPreferences
     syntax: ./TCL/HTML (Tcl).sublime-syntax
       name: HTML (Tcl)
       scope: text.html.tcl
       icon file type: file_type_tcl_html_tcl
       icon file: TCL/Icon (HTML (Tcl)).tmPreferences
   created icon preferences file: TCL/Icon (HTML (Tcl)).tmPreferences
     syntax: ./TCL/Tcl.sublime-syntax
       name: Tcl
       scope: source.tcl
       icon file type: file_type_tcl_tcl
       icon file: TCL/Icon (Tcl).tmPreferences
   created icon preferences file: TCL/Icon (Tcl).tmPreferences
     scope: text.html.tcl, source.tcl
   created icon preferences file: TCL/Icon.tmPreferences
=> package: ./Text
     name: Text
     icon file type: file_type_text
     icon file: Text/Icon.tmPreferences
     scope: 
=> package: ./Textile
     name: Textile
     icon file type: file_type_textile
     icon file: Textile/Icon.tmPreferences
     syntax: ./Textile/Textile.sublime-syntax
       name: Textile
       scope: text.html.textile
       icon file type: file_type_textile_textile
       icon file: Textile/Icon (Textile).tmPreferences
   created icon preferences file: Textile/Icon (Textile).tmPreferences
     scope: text.html.textile
   created icon preferences file: Textile/Icon.tmPreferences
=> package: ./XML
     name: XML
     icon file type: file_type_xml
     icon file: XML/Icon.tmPreferences
     syntax: ./XML/XML.sublime-syntax
       name: XML
       scope: text.xml
       icon file type: file_type_xml_xml
       icon file: XML/Icon (XML).tmPreferences
   created icon preferences file: XML/Icon (XML).tmPreferences
     scope: text.xml
   created icon preferences file: XML/Icon.tmPreferences
=> package: ./YAML
     name: YAML
     icon file type: file_type_yaml
     icon file: YAML/Icon.tmPreferences
     syntax: ./YAML/YAML.sublime-syntax
       name: YAML
       scope: source.yaml
       icon file type: file_type_yaml_yaml
       icon file: YAML/Icon (YAML).tmPreferences
   created icon preferences file: YAML/Icon (YAML).tmPreferences
     scope: source.yaml
   created icon preferences file: YAML/Icon.tmPreferences
0 Likes

#25

I just wanted to note that I have seen this thread and mentions of my name, but I personally haven’t dealt with themes much, and don’t currently have opinions or extra insight to provide.

Like many other aspects of Sublime, it is the sort of polish/tidying I would like to address at some point, but it is not on the top of my priority list right at the moment.

3 Likes

#26

I understand it’s low priority task, and maybe at some point it will be fixed or introduced other approach. But for now can I create theme dependency which include these preferences? Currently this is the best solution as possible.

0 Likes

#27

further to what has been discussed it, the following has almost been mentioned but I thought I would outline it explicitly just in case other people want to know about it or stumble across it.

If you have a custom theme installed - only one (as per the recommendations :wink: ) - but are not using it (I know, naughty me - not using Boxy!), you will lose file icons for a lot of files because the tmPreferences that define the icon files for that theme will still be picked up, but the Default theme won’t contain icon files with those names. Moral of the story, if you are not using a custom theme, add it to ignored packages or uninstall it :slight_smile:

4 Likes