我最近开始使用Atom。我遇到的一个问题是为Ruby定义了太多/含糊不清的代码段。这会使制表符补全变得更糟,因为有时您会得到一些无关的代码,而不是想要的名称。我想知道如何从“ Language Ruby”包中关闭特定的片段,或者无法关闭所有片段。最好不要完全禁用Ruby包。
可悲的是,目前没有内置功能可用于此类操作。
在片段添加了某些过滤器功能之前,访问片段的唯一方法是从您的init脚本中猴子对该软件包进行补丁。
例如,类似的内容将允许您在运行时过滤给定编辑器返回的代码片段:
# we need a reference to the snippets package
snippetsPackage = require(atom.packages.getLoadedPackage('snippets').path)
# we need a reference to the original method we'll monkey patch
__oldGetSnippets = snippetsPackage.getSnippets
snippetsPackage.getSnippets = (editor) ->
snippets = __oldGetSnippets.call(this, editor)
# we're only concerned by ruby files
return snippets unless editor.getGrammar().scopeName is 'source.ruby'
# snippets is an object where keys are the snippets's prefixes and the values
# the snippets objects
console.log snippets
newSnippets = {}
excludedPrefixes = ['your','prefixes','exclusion','list']
for prefix, snippet of snippets
newSippets[prefix] = snippet unless prefix in excludedPrefixes
newSnippets
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句