How to disable snippets in Atom?

I recently started using Atom . One of the problems I ran into is that there are too many / ambiguous fragments for Ruby. This makes tabs difficult, as sometimes you get a little unnecessary code instead of the name you want. I am wondering how to disable a specific fragment from the Ruby Language package, or not to disable all fragments. It is not recommended to completely disable the Ruby package.

+6
source share
1 answer

Unfortunately, there is currently no built-in function for this kind of thing.

Until a filter function is added to the snippets package, the only way to access these fragments is to disable the package from your init script.

For example, something like this will allow you to filter the fragments returned for this 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 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 
+3
source

Source: https://habr.com/ru/post/975701/


All Articles