emmetio / emmet-docs

Emmet Docs & Tutorials
http://docs.emmet.io
272 stars 62 forks source link

Custom Snippets no longer working #53

Closed ch4ppy closed 4 years ago

ch4ppy commented 4 years ago

After recent update, my custom snippets have all stopped working. It feels like they are being overridden by sublimeText3's autocomplete feature maybe? The file types in question are .scss and .blade.php. I have been using and relying on these snippets for over a year and all the sudden nothing. I have "disable_completions": false and "remove_html_completions": true

        "html":
        {
            "filters": "html, blade",
            "profile": "html",
            "snippets":
            {
                "container": "<div class=\"container container--large\">\n\t<div class=\"row\">\n\t\t<div class=\"col-${1}\">${2}</div>\n\t</div>\n</div>",
                "fe": "@foreach($0)\n@endforeach"
            }
        }

^ the above "container" snipped usually opens up into some nested divs but now when i hit tab it expands into just container--large.

ch4ppy commented 4 years ago

Addition - seems like normal emmet strings are failing as well - div.container.container--large+div.row+div.col-lg-3.offset-lg-2+div.col-lg-5 just does nothing when I hit tab

sergeche commented 4 years ago

In new version, snippets format is changed: snippets are aliases to another Emmet snippets. Two things to consider:

  1. Simply write another Emmet abbreviation as snippet value
  2. To output some arbitrary content (like in fe snippet) you should write value as text node in Emmet terms, e.g. wrap with {}.

So, your snippets should look like this:

"container": "div.container.container--large>.row>[class="col-${1}"]",
"fe": "{@foreach($0)\n@endforeach}"

Note that config format is also changed: https://github.com/emmetio/sublime-text-plugin#adding-custom-emmet-snippets

Addition - seems like normal emmet strings are failing as well

Do you see underline and preview when you write abbreviation? https://github.com/emmetio/sublime-text-plugin#expanding-abbreviation

ch4ppy commented 4 years ago

Thank you @sergeche - looks like my old syntax snippets were causing a lot of errors. The syntax you included had an error, the quotes around "col-${1}" were erroring out. So the following is where I ended up: "container": "div.container.container--large>.row>[class=col-${0}]",. Thanks for pointing me in the right direction.

sergeche commented 4 years ago

Yeah, my bad, double quotes should be escaped in JSON, or you can use single quote or no quotes if value is a single word.

ch4ppy commented 4 years ago

@sergeche - sorry to revive this thread but I am having trouble getting my old scss snippets to work now. here is the whole "stylesheets" block I was hoping you could help identify what I am doing wrong here...

        "stylesheets": {
            "snippets": {
                "mdlg": "{@include media-down(lg){$0}}",
                "mdmd": "{@include media-down(md){$0}}",
                "mdsm": "{@include media-down(sm){$0}}",
                "mdxs": "{@include media-down(xs){$0}}",
                "molg": "{@include media-only(lg){$0}}",
                "momd": "{@include media-only(md){$0}}",
                "mosm": "{@include media-only(sm){$0}}",
                "moxl": "{@include media-only(xl){$0}}",
                "mulg": "{@include media-up(lg){$0}}",
                "mumd": "{@include media-up(md){$0}}",
                "musm": "{@include media-up(sm){$0}}",
                "muxl": "{@include media-up(xl){$0}}"
            }
        },
sergeche commented 4 years ago

Stylesheets use different snippets format: it either property alias (e.g. padding or transform:translate|scale) or arbitrary text (e.g. not the property). So, for stylesheets you don’t have to wrap it with {}. Also note that it’s better to use native ST snippets in this case

ch4ppy commented 4 years ago

@sergeche thank you for your help I appreciate it