Sublime Forum

Sidebar icons, extensions, and syntax discovery

#1

Okay, so I just discovered this. I don’t know how long its been in here or if this works in ST2 (at least sidebar icons won’t), but let me lay this out for people.

Lets say you have a tmLanguage file: MyAwesome.tmLanguage file.

Now I have known about tmLanguage settings files, but what I didn’t realize is that you can append to the recognized extensions of the XML in it. You can create a settings file MyAwesome.sublime-settings in your user folder add new extensions that will cause sublime to automatically open that file with the correct syntax and use the associated icon for that syntax in the sidebar:

For example. I have a makefile that uses the extension .mak, but sublime doesn’t recognize the extension as a makefile, so I create Makefile.sublime-settings in my User folder and add this:

{ "extensions": "mak"] }

Now sublime recognizes mak as a make file, and now applies the appropriate sidebar icon!

This is something I will be implementing in ApplySyntax moving forward. I think adding an extension option in ApplySyntax that creates these files for us will allow us to append new extensions and get their icons showing up correct.

0 Likes

#2

Great discovery! :smile:

0 Likes

#3

Uh… Is not what that „open all with current extension as…” menu does? o.O

0 Likes

#4

Yes, but there was more to it than just that…

I didn’t know it existed because I never use that menu to select syntax, I use the quick panel or I configure it in ApplySyntax which can handle more than just extensions, but yes, I realize the correlation now.

But what I found most interesting is that the setting affects the sidebar icon which gives some extra usefulness. Sadly it only does extensions, so more complicated file patterns can’t be added. ApplySyntax can handle the more complicated file patterns, but you don’t get the correct icon in the sidebar.

So what was most interesting is not extension -> syntax relation which I wouldn’t have bothered posting about since nothing is gained for me that I didn’t already have control of, but it was the extension -> syntax -> icon relationship. I thought it might be interesting for people to know.

0 Likes

#5

I think it is better to recognize the file by its extensions. Like a kind of binary file, it contains lots of file types. In this version, pdf file is also recognized as a binary file. :smiley:

0 Likes