Based on this issue (https://github.com/atom/atom/issues/1718) from atom's github concerning the customFileTypes option, I have the following in my config.cson.
"*":
core:
customFileTypes:
"source.html": [
"cshtml"
]
My intention is for cshtml files to be automatically opened with the HTML grammar for syntax highlighting, however, my cshtml files still open as Plain Text.
If I change "source.html" to "source.gfm", then my cshtml files open as Github Flavoured Markdown, so I suspect that "source.html" isn't the name I should be using.
How can I get this to work? And, where can I get a list of names for grammars?
Made this work by using text.html.basic as the scope name, so my config looks like this:
"*":
core:
customFileTypes:
"text.html.basic": [
"cshtml"
]
To get a list of eligible scope names, open the Atom console (Ctrl+Alt+I in Windows, Ctrl+Shift+I in Linux) and run Object.keys(atom.grammars.grammarsByScopeName).
You get an array in return, so Object.keys(atom.grammars.grammarsByScopeName).sort().join('\n') will give you a nicely sorted list.
In case you want to display the file with the ASP.NET Razor theme (standard for .cshtml files), go ahead and do the following:
Download the language-cshtml package https://atom.io/packages/language-cshtml
Change you ~/.atom/config.cson to include the following:
"*":
core:
customFileTypes:
"text.html.cshtml": "cshtml"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With