Gruntfuggly / auto-snippet

A vscode extension to automatically insert a predefined snippet when a file is created, or an empty file is opened.
Other
14 stars 1 forks source link

Missing, empty or invalid snippet [solution] #20

Open ivanstnsk opened 4 months ago

ivanstnsk commented 4 months ago

Hi there! If you got this error like me, just note that this extension doesn't work with prefix. Put a snippet name not prefix.

Screenshot 2024-05-16 at 21 59 22

Problem:

{
      "pattern": "**/*.tsx",
      "snippet": "rff"  <-- prefix
}

Solution:

{
      "pattern": "**/*.tsx",
      "snippet": "React Functional Component"  <-- snippet name
}
Kenny-MWI commented 4 months ago

I still get the "Missing, empty or invalid snippet: new php` error when opening a new php file. I've slimmed down my snippet to just the first line that I want inserted and the error still happens. What am I missing?

// php.json
{
    "new php": {
        "prefix": "newphp",
        "body": [
            "<?php"
        ],
        "description": "newphp"
    },
}

and

// settings.json
"autoSnippet.snippets": [
    {
        "pattern": "**/*.php",
        "snippet": "new php"
    }
],

Edit: Oh, I had to move my snippet from php.json to the global snippets and now it works perfectly.