基于这个问题(https://github.com/atom/atom/issues/1718)来自atom的github关于customFileTypes选项,我的config.cson中有以下内容。
"*":
core:
customFileTypes:
"source.html": [
"cshtml"
]
Run Code Online (Sandbox Code Playgroud)
我的目的是使用 HTML 语法自动打开 cshtml 文件以进行语法高亮显示,但是,我的 cshtml 文件仍然以纯文本形式打开。
如果我更改"source.html"为"source.gfm",那么我的 cshtml 文件会以 Github Flavored Markdown 的形式打开,所以我怀疑这"source.html"不是我应该使用的名称。
我怎样才能让它发挥作用?而且,我在哪里可以获得语法名称列表?
Made this work by using text.html.basic as the scope name, so my config looks like this:
"*":
core:
customFileTypes:
"text.html.basic": [
"cshtml"
]
Run Code Online (Sandbox Code Playgroud)
要获得资格范围的名称列表,打开了Atom控制台(Ctrl+ Alt+I在Windows,Ctrl+ Shift+I在Linux中)和运行Object.keys(atom.grammars.grammarsByScopeName)。
你得到一个数组作为回报,所以Object.keys(atom.grammars.grammarsByScopeName).sort().join('\n')会给你一个很好的排序列表。