Reputation: 3584
I've recently started using Atom. One problem I've run into is that there are too many / ambiguous snippets defined for Ruby. This makes tab completion worse, as you sometimes get a bit of irrelevant code instead of the name you wanted. I'm wondering how to turn off a specific snippet from the "Language Ruby" package, or failing that turning off all snippets. Preferably without disabling the Ruby package entirely.
Upvotes: 8
Views: 1934
Reputation: 191
I too suffer from snippet overload in Atom. While I couldn't find a way to turn snippets off in the settings, I found a workable solutions for now.
In the custom snippets file (Mac menu: Atom > Snippets...), prepend your snippets' prefix property with some letter. This way they're always sorted to the top of the autocomplete list. I chose the letters 'aa'.
Ember snippet example:
"Dirk's Label & Input":
'prefix': 'aaLabel & Input'
'body': """
<label>
$1
<Input
@type='text'
@value={{this.$2}}
/>
</label>
"""
Now when I type aa all my snippets show first ... ;-)
Upvotes: 0
Reputation: 4352
From atom discussion board:
There are two packages:
snippets
andautocomplete-snippets
that you can disable from the settings-view packages tab.autocomplete-snippets
is the package that adds snippets to the autocomplete+ suggestions.
Upvotes: 0
Reputation: 175
Sadly, there's currently no built-in feature for this kind of thing.
Until some filter feature is added to the snippets package, the only way to access the snippets is to monkey-patch the package from your init script.
For instance something like that will allow you to filter the snippets returned for a given editor at runtime:
# 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
Upvotes: 3