Yaml snippet not triggering after a field name


#1

I have created a snippet along the lines of the following:

'.source.yaml':
  'snippet foo':
    'prefix': 'foo'
    'body': 'bar'

When creating a yaml document the above snippet will execute just fine, however when I try to invoke the snippet after a field name it breaks.

field_name: foo

In this instance the ‘foo’ has a scope of ‘source.yaml’ and ‘string.unquoted.yaml’ and will not trigger the snippet. I’ve done some searching but haven’t stumbled across anyone else with this issue - can anyone advise on where I’ve gone astray?


#2

Why not just use '.yaml' as your selector?


#3

Unfortunately setting the selector to ‘.yaml’ doesn’t fix the issue, the snippet still triggers on a new line but not after a field name.


#4

UPDATE:

After further digging into the packages that make up Atom here’s what I’ve found:

The Autocomplete-snippet package is responsible for recommending the snippets when I begin to type the snippet’s name.

Autocomplete-snippet is disabled (in the source code) for any line that is considered to be a string or a comment via the following line in lib/snippets-provider.coffee:

class SnippetsProvider
  selector: '*'
  disableForSelector: '.comment .string'
  inclusionPriority: 1

This ‘feature’ seems documented here at github.com/atom/autocomplete-snippets/issues/55

Removing the ‘.string’ from the disableForSelector means that editing Yaml with snippets works for inline key values.

Next question is how to make this configurable rather than running with my own private version of autocomplete-snippets.


#5

That would make sense. I haven’t been able to replicate your issue, but I also have autocomplete-snippets disabled.