Giving appropriate scope to Atom snippets


#1

I am developing the Bootstrap-Sass snippets for Atom and I got a problem that my snippets pollutes the scope of built-in snippets.

For example my variable.cson consist of snippets like:

 '.source.scss':
        'Vertical base padding ':
            'prefix': 'padding-base-vertical'
            'body': '$padding-base-vertical: $1;'
        'Horizontal padding base':
            'prefix': 'padding-base-horizontal'
            'body': '$padding-base-horizontal: $1;'
            # large paddings
        'Vertical large padding ':
            'prefix': 'padding-large-vertical'
            'body': '$padding-large-vertical: $1;'
        'Horizontal padding large':
            'prefix': 'padding-large-horizontal'
            'body': '$padding-large-horizontal: $1;'
            # small paddings
        'Vertical small padding':
            'prefix': 'padding-small-vertical'
            'body': '$padding-small-vertical: $1;'
        'Horizontal small padding':
            'prefix': 'padding-small-horizontal'
            'body': '$padding-small-horizontal: $1;'
            # xs paddings
        'Vertical xsmall padding':
            'prefix': 'padding-xs-vertical'
            'body': '$padding-xs-vertical: $1;'
        'Horizontal xsmall padding':
            'prefix': 'padding-xs-horizontal'
            'body': '$padding-xs-horizontal: $1;'

Then if I type “pad” in any of .scss file it will firstly give me my snippets, and then on the very end will be normal “padding” snippet.

My question is: How can I apply my snippets contained in variable.cson only to _variable.scss or variable.scss.

I tried to look onto Atom docs but there is no example which would help me with my problem.


#2

You can’t unless the language grammar makes a distinction (by applying a class). Atom is not set up to easily do this. The only solution I can think of is to have a separate package that only activates when the active file name matches _variable.scss or variable.scss.


#3

Is there a possibility to show snippets if a prefix is “$someletters”? When i try to simply change a prefix to ‘prefix’: ‘$brand-primary’ the snippet does not show up.


#4

I’m not able to replicate this. This snippet works fine for me:

'*':
  'Test':
    prefix: '$dol'
    body: '\$dollars'

#5

It seems strange, when I put some letters than the snippet appears but if only I start prefix from a dollar sign the snippet is not showing up. What is even more bizzare I can see that the snippet starting from dollar sign exist;/