Add file icons support in the explorer
Can you please add file icons support in the tree view?
I know that access from extension to the DOM is restricted. But it will be good to add some language-id attribute to the tree-view element. For example in the render function. So it will be easy to modify view of files with different types with CSS, without modifying DOM.
And also It will be nice to add possibility to add/modify directly CSS from extension.
I agree. Here is a screenshot of what I have in sublime.

+1
+1 I can find files much faster with the icons!

Any progress on this?
+1
I mostly have issues trying to distinguish the difference between a file and a folder quickly. There isn't even a text color difference.
What is interesting is that there is logic in place to add icon classes: https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/files/browser/views/explorerViewer.ts
private iconClass(element: FileStat): string {
if (element.isDirectory) {
return 'folder-icon';
}
return 'text-file-icon';
}
As seen above, vscode currently adds a folder-icon css class to all folders but a style is not defined for it. So if you want to see folder icon in explorer, all you have to do is add the below styles to
.monaco-tree-row .content .sub-content .explorer-item.folder-icon {
padding-left: 22px;
background: url(./parts/files/browser/media/Folder.png) 1px 4px no-repeat;
}
.monaco-tree-row.expanded .content .sub-content .explorer-item.folder-icon {
padding-left: 22px;
background: url(./parts/files/browser/media/Folder_opened.png) 1px 4px no-repeat;
}
.explorer-item.text-file-icon {
padding-left: 22px;
background: url(./parts/files/browser/media/Textfile.png) 1px 4px no-repeat;
}
and copy the below icon images to
Folder.png
Folder_opened.png
Textfile.png
Here is a preview of it in action:

In it's simplest form, implementing the file icon feature would require modifying the above iconClass method to return 'text-file-' + getFileExtension(element.name) and adding corresponding icon svg/font to each css classes (i.e., text-file-js, text-file-md, etc.)
Nice find @snpai. It would be very easy if they could add another class like text-file text-file-md. So extensions could use it to just add another CSS with all the icons.
This feature is sorely needed, and is trivial to implement. I was able to use @pflannery's fork and https://github.com/mrmartineau/SetiUI-Icons-Sublime to add in default icons right into the my own build.
One thing though: some files should be themed based off of more than extension. package.json, gulpfile.js, etc should be themed based off of name. I suppose adding built-in support for specific filename classes would be better (faster/less cluttering to the DOM) than adding a class for the entirety of every file's name.
While we wait, does anyone have a comprehensive, "good" looking grayscale icon pack? The icon pack I used doesn't mesh very well with the dark theme and is a little distracting.
@nelsonlaquet you made a good point about the gulp, grunt and package.json files and thanks for linking the icons too. I've updated my PR which puts the filename in to attributes allowing special icons for specific files. I've also added support for css theming because I feel that this is the cleanest and simplest way to deliver this feature. Check out my comments here for more info https://github.com/Microsoft/vscode/pull/3200#issuecomment-194656772
+1 I can find files much faster with the icons!
Is the file tree exposed to extensions api? if you can expose it, i think that would allow the community to create an extension for this and for any further opinionated customizations all the while VSCode itself can remain neutral on the issue
If that would be added, I'd like to port my icon extension (Brackets Icons) for Brackets to VS Code. In Brackets, an icon provider can be added, which is a function that returns an icon as a DOM element for a specified file name (docs). Since VS Code doesn't expose the DOM, there should be a layer between, but similar ideas can be used.
No API atm to change the explorer.
@bpasero is there plans for such a thing in the near future? if yes, any rough ETA?
@egamma @chrisdias please chime in.
+1
@bpasero Could you list the needed acceptance criteria to get a pull request merged? Maybe I could help then.
@donaldpipowitch I would think this feature should:
- be configurable with a flag in settings
- provide the necessary icons for all themes (SVG)
Still, our PM/UX might decide to veto. @chrisdias @stevencl please chime in.
@bpasero Thank you. Could you define "be configurable with a flag in settings" a little bit more? What do you want to configure?
- show/hide icons
- match existing (built in) icons to file patterns
- change existing (built in) icons to custom icons
- ...?