atom/grammar-selector

Changed order of syntax detection based on file extension

Closed this issue · 2 comments

I'm not sure if this is the right place for this issue... Does this package handle the automatic detection of which language package to use for a specified file extension? Or is that a part of Atom's core, or some other package?

I'm using 2 different language packages (language-csharp and language-glsl), which both want to do syntax highlighting for the ".cs" file extension.

I've had both packages installed for as long as I've been using Atom (since before 1.0), and ".cs" files have been highlighted as C# (correctly, in my opinion). However, today I noticed that all of my ".cs" files are being highlighted as GLSL shaders. Here, "cs" is probably short for "compute shader".

I checked the history of the language-glsl package, and it has had the ".cs" extension in use for 2 years. I personally would consider this a bug in language-glsl, but I know that other people may disagree, if they work with GLSL compute shaders, and not with C#.

Has the order of "priority" been changed in how language packages claim ownership of file extensions? Have core packages overridden community packages and now it's the other way around, or has the order been alphabetical (and now it's random)?

Is there any way to either change the order of priority between language packages, or to manually force ".cs" files to be treated as C#?

I'm having the same issue. I think more than one factor makes this quite critical. On the language-glsl part and also the Khronos Group for choosing such a file extension when there's a widely deployed (which is also heavily used on videogames no less) already using that extension, but also on Atom's side for not allowing a simple way to override. I followed the docs but my .cs files are still loaded as GLSL.

Can we get an official comment on this?

I don't think we've intentionally changed the priority. In this case, you can use Atom's "custom filetype" config to ensure that .cs files are highlighted as C-sharp.

https://discuss.atom.io/t/how-do-i-make-atom-recognize-a-file-with-extension-x-as-language-y/26539

Add this setting to your ~/.atom/config.cson:

core:
  customFileTypes:
    'source.cs': ['cs']

Let me know if you have problems setting this up.