有人可以完整解释 Atom 的数据语法属性(用于键绑定(bind)选择器)的语法吗?
例如,有什么区别
[data-grammar='source example']
和
[data-grammar~='source example']
?
另外,如何指定多种语法?例如,您如何指定键绑定(bind)应限制为 html 或 xml 格式?
如果某处已经存在关于此的文档,我还没有找到它,但希望能指出它。
最佳答案
简单示例:
keymap.cson:
"atom-text-editor[data-grammar='text tex latex']":
'f5':'latex:build'
语法信息和文档
我首先查看 file-types
包裹。 source
和text
对语言进行分类 - source
处理开发语言,而 text
处理文档/日志格式。
您可以通过阅读飞行手册来添加和自定义语言识别。我在下面链接了一些对此有帮助的特定部分。
Flight Manual | Basic Customization:
block 引用>与
[data-grammar]
合作:给出的小文档列在“深度键盘映射”部分下。
Flight Manual | Keymaps in Depth
block 引用>这也描述了
not([...])
下面使用的功能以及如何操作各种规则。虽然在上面,语法是以点格式列出的,即
source.c
,在[data-grammar='<name>']
中使用它们相反,需要格式空格。我如何在 keymap.cson 配置中使用数据语法选项的示例如下(这里我使用的是 Latex 包):
"atom-text-editor[data-grammar='text tex latex']": 'f5':'latex:build'
~
不是数据语法所需功能的正确语法。相反,使用类似"atom-text-editor:not([data-grammar='<name>'])":
的内容请注意,您不会使用
data-grammar
类似于config.cson
。语言细节的语法看起来像这样:# **config.cson** ".latex.tex.text": editor: softWrap: true
额外有用的信息 - 已注册语法列表
Object.keys(atom.grammars.grammarsByScopeName).sort().join('\n')
输出的转储通过开发控制台(查看 > 开发人员 > 切换开发人员选项 > 控制台)source.c source.cake source.clojure source.coffee source.cpp source.cs source.css source.css.less source.css.scss source.csx source.diff source.gfm source.git-config source.go source.gotemplate source.java source.java-properties source.js source.js.rails source.js.jquery source.js.regexp source.js.regexp.replacement source.json source.litcoffee source.makefile source.nant-build source.objc source.objcpp source.perl source.perl6 source.plist source.python source.python.django source.regexp.python source.ruby source.ruby.gemfile source.ruby.rails source.ruby.rails.rjs source.sass source.shell source.sql source.sql.mustache source.sql.ruby source.strings source.toml source.verilog source.yaml text.bibtex text.git-commit text.git-rebase text.html.basic text.html.erb text.html.gohtml text.html.jsp text.html.mustache text.html.php text.html.ruby text.hyperlink text.junit-test-report text.log.latex text.plain text.plain.null-grammar text.python.console text.python.traceback text.shell-session text.tex text.tex.latex text.tex.latex.beamer text.tex.latex.memoir text.todo text.xml text.xml.plist text.xml.xsl
关于atom-editor - 键绑定(bind)的原子数据语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43008745/