Atom not completing HTML snippets


#1

It worked before but currently I’m not able to expand snippets.
This works for everything else (js, sass, css) but when I want to expand my snippet
for a HTML comment it just wraps tags around it.
Example: my snippet is set to expand -- to <!-- --> but instead expands to <--> <-->

My syntax mode is set to HTML. Take a look at the gif below to see what I mean.
Text in tags in gif preview is empty, but this is just a glitch in Gifgrabber… Don’t pay attention

snippets.cson:

'.source.html':
  'HTML Comment':
    'prefix': '--'
    'body': '<!-- $1 -->'

#2

I copy and pasted the snippet configuration you have here into my snippets.cson and I cannot reproduce on Atom v0.139.0-4867e3e on OS X 10.10. Can you reproduce after completely exiting Atom and restarting with atom --safe?

Also, do you have more than one '.source.html' key in your snippets.cson? Remember that CSON is just like JSON, in that later keys override earlier keys.


#3

Works in safe mode. Don’t have any HTML snippets coming after that.
Below is my entire snippet file.

############# HTML #############
'.source.html':
  'HTML Comment':
    'prefix': '--'
    'body': '<!-- $1 -->'

#############  CSS #############
'.source.scss':
  'Multiline comment':
    'prefix': '/*'
    'body': '/* $1 */'

#############  JS  #############
'.source.js':
  'Anon Init Function':
    'prefix': 'init'
    'body': '(function(){\n\n\tfunction init(){\n\t\t$1\n\t}\n\n\tinit();\n\n})();'

I think it’s something in my settings rather than snippets.cson though…


#4

If it works in Safe Mode then it is most likely a package that is conflicting. Or something in your Init Script.


#5

Figured it out! The Emmet package adds a snippet for autocompletion with the tab key.

Disabled emmet and it works again.


#6

I’ve posted the same issue on https://github.com/ThusStyles/meteor-snippets/issues/4 and https://github.com/emmetio/emmet-atom/issues/146 and it is certain that Emmet is the culprit, without yet an apparent solution except for changing emmet’s key binding or disabling emmet completely.

Bu I think the solution should be provided by Atom itself as a hook that plugins can tap into because tab and some other key combinations are so general that plugins can only provide a “contribution” rather than an “alternative” to whatever use that key binding may be known for.


#7

Don’t forget that in context a tab can mean something totally different. In some of my packages I have overridden tab when my panel is active.


#8

I see your point. Then perhaps packages should have a way to “borrow” a key press event and than “return” it back so that it can be utilized by more than one package which service the same context, or even better yet, a daisy chaining mechanism can be considered upon.


#9

You’re magnificent. I opened at issue at GitHub about this.


#10

The question happens on me too. I haven’t find the package named Emmet, I start atom in safe mode not work either. The snippet is like this. But the ‘–’ can trigger the comment. Python script the snippet works fine. And why this happens?

'.source.html':
  'jinja variable':
    'prefix': 'jv'
    'body': 'xxx'

#11

Can you post screenshots of your editor before and after you press tab? Those would help people visualize what’s happening for you.


#12

snippet configuration

before type


after type in jv

after hit tab
20180127163701


#13

Ah, I know what’s wrong. The scope name for HTML is text.html.basic. So you want your first line to read .text.html.


#14

omg, thanks my bro.


#15

No problem. I overlooked that at first because it’s not something I think much about.