Configuration 如何关闭Atom中的代码段?

Configuration 如何关闭Atom中的代码段?,configuration,code-snippets,atom-editor,Configuration,Code Snippets,Atom Editor,我最近开始使用。我遇到的一个问题是,为Ruby定义的代码段太多/模棱两可。这会使制表符的完成变得更糟糕,因为有时您会得到一些不相关的代码,而不是您想要的名称。我想知道如何从“Language Ruby”包中关闭一个特定的代码段,或者关闭所有代码段失败。最好不要完全禁用Ruby软件包。遗憾的是,目前还没有这种内置功能 在向snippets包中添加某些过滤器功能之前,访问snippets的唯一方法是从init脚本中对包进行猴子补丁 例如,类似的内容将允许您在运行时过滤为给定编辑器返回的代码段: #

我最近开始使用。我遇到的一个问题是,为Ruby定义的代码段太多/模棱两可。这会使制表符的完成变得更糟糕,因为有时您会得到一些不相关的代码,而不是您想要的名称。我想知道如何从“Language Ruby”包中关闭一个特定的代码段,或者关闭所有代码段失败。最好不要完全禁用Ruby软件包。

遗憾的是,目前还没有这种内置功能

在向snippets包中添加某些过滤器功能之前,访问snippets的唯一方法是从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
发件人:

有两个软件包:
snippets
autocomplete snippets
,您可以从“设置”视图的“软件包”选项卡中禁用它们
autocomplete snippets
是将代码段添加到autocomplete+建议的程序包


我在Atom中也受到代码片段过载的困扰。虽然我找不到在设置中关闭代码段的方法,但我现在找到了一个可行的解决方案

在自定义代码段文件(Mac菜单:Atom>snippets…)中,在代码段的prefix属性前面加上一些字母。这样,它们总是被排序到自动完成列表的顶部。我选择了字母“aa”

余烬片段示例:

"Dirk's Label & Input":
    'prefix': 'aaLabel & Input'
    'body': """
        <label>
            $1
            <Input
                @type='text'
                @value={{this.$2}}
            />
        </label>
    """
“德克的标签和输入”:
“前缀”:“aa标签和输入”
“正文”:“
$1
"""

现在,当我键入aa时,我的所有代码片段都会首先显示…;-)

似乎不再有效了<代码>找不到模块“/usr/share/atom/resources/app.asar/node\u模块/代码段”