file-icons / atom

Atom file-specific icons for improved visual grepping.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Imba icon

GavinRay97 opened this issue · comments

Hey, I was just curious whether or not you guys could add the Imba icon, a compile-to-JS language.

See:
https://github.com/somebee/imba
https://atom.io/packages/language-imba

I'm currently doing it right now through LESS in the stylesheet, feels really hacky. The language-imba package declares:

Scope: source.imba
File Types: imba

But yet despite this, the grammar being properly autodetected, and using a custom language definition in Atom's config coffeescript, I couldn't get the CSS selector to trigger. I don't think I should even need to declare it a custom file type because of the Scope and File Type from the language package, but I tried anways

  core:
    customFileTypes:
      "source.imba": [
        "imba"
      ]

Still just get:

<span class="name icon default-icon" title="test.imba" data-name="test.imba" data->test.imba</span>

So using this:

.icon[data-name$="imba"]:before{
  content: url('http://imba.io/images/logo.svg');
}

Unfortunately the SVG doesn't scale well at small dimensions, but what can you do?

Imba Atom Icon

Thank you guys!

Unfortunately the SVG doesn't scale well at small dimensions, but what can you do?

We have a dedicated repository where new icon requests can be submitted. I've already added an SVG for it in 09faaba, however, so there's no need to file a separate issue.

I don't think I should even need to declare it a custom file type because of the Scope and File Type from the language package

Well... there is. The package's file-to-icon mappings are handled in config.cson... file-icons has no way of knowing what colour or icon class to assign a filetype, and a language package isn't going to enlighten it either.

Thank you for adding it!

The package's file-to-icon mappings are handled in config.cson... file-icons has no way of knowing what colour or icon class to assign a filetype, and a language package isn't going to enlighten it either.

I wasn't aware of this, how is it that picks up every other language's file types? Are all the other file types I work with just supported/recognized by Atom per default?

Nope, we manually declare the scope in the config file itself. See the documentation at the top of the file:

Name of any TextMate grammars which trigger the icon when overriding a file's grammar. This may be a string or regex; if provided the former, it's used to construct a case-insensitive pattern that's checked against the end of the string (e.g., "js" will be treated as if /.js$/i were written). Not every grammar will/should change an icon, especially for very generic formats like JSON or YAML.

However, the config also supports a shorthand. E.g., this line:

ANTLR:
	icon: "antlr"
	match: [
		[".g", "medium-red", "antlr"]
	]

... expands into this at compile-time:

ANTLR:
	icon: "antlr"
	match: [
		[".g", "medium-red", alias: "antlr", interpreter: "antlr", scope: "antlr"]
	]

In most cases, all three properties are identical, so the shorthand is sufficient for most cases.

It's becoming increasingly tempting to move the icon-config logic to a separate repository...

Ahhh yeah, I feel like a moron, I was browsing the commit changes just now and saw the File Icons package config.cson and that you manually defined everything there, and had added an entry for the Imba file type.

Came back to strike out my comment and amend that I'm an idiot but you beat me to it. You're on top of things!

It's becoming increasingly tempting to move the icon-config logic to a separate repository...

I saw that discussion while trying to figure out how to implement the Icon without using LESS. I would advocate for it, just due to extensibility purposes honestly.

Edited