Home Download Buy Blog Forum Support

Sidebar icons, extensions, and syntax discovery

Sidebar icons, extensions, and syntax discovery

Postby facelessuser on Thu May 29, 2014 6:24 pm

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:
Code: Select all
{
    "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.
facelessuser
 
Posts: 1571
Joined: Tue Apr 05, 2011 7:38 pm

Re: Sidebar icons, extensions, and syntax discovery

Postby tito on Thu May 29, 2014 9:23 pm

Great discovery! :)
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 855
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: Sidebar icons, extensions, and syntax discovery

Postby iamntz on Thu May 29, 2014 11:33 pm

Uh... Is not what that „open all with current extension as...” menu does? o.O
iamntz
 
Posts: 910
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: Sidebar icons, extensions, and syntax discovery

Postby facelessuser on Fri May 30, 2014 12:16 am

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

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.
facelessuser
 
Posts: 1571
Joined: Tue Apr 05, 2011 7:38 pm

Re: Sidebar icons, extensions, and syntax discovery

Postby zackzheng on Sat May 31, 2014 6:41 am

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. :D
zackzheng
 
Posts: 4
Joined: Wed May 07, 2014 5:06 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests