abusaidm / html-snippets

VSCode html-snippets extention
MIT License
101 stars 75 forks source link

Add support for non .html files #20

Closed komali2 closed 7 years ago

komali2 commented 7 years ago

It would be awesome if this worked when I was editing .hbs, .ejs, etc files.

komali2 commented 7 years ago

I spent some time during the afternoon looking into what would be required for this and have hit a wall. It seems what needs to happen is simply editing files.associations like so:

    "files.associations": {
        "*.hbs": "html"
    }

but I can't figure out how to do that from an extension. I tried a couple things, including editing the package.json to look like:

{
    "name": "test-snippets",
    "displayName": "TEST Snippets",
    "description": "Full HTML tags including HTML5 Snippets",
    "version": "0.0.18",
    "publisher": "abusaidm",
    "icon": "images/icon.png",
    "engines": {
        "vscode": "^0.10.1"
    },
    "extensionDependencies": [
        "html"
    ],
    "galleryBanner": {
        "color": "#1E81C1",
        "theme": "light"
    },
    "categories": [
        "Snippets"
    ],
    "contributes": {
        "snippets": [
            {
                "language": "html",
                "path": "./snippets/snippets.json"
            },
            {
                "language": "php",
                "path": "./snippets/snippets.json"
            },
            {
                "language": "javascript",
                "path": "./snippets/snippets.json"
            },
            {
                "language": "javascriptreact",
                "path": "./snippets/snippets.json"
            }
        ],
        "languages": [{
            "id": "html",
            "extensions": [ ".hbs" ],
            "aliases": [ "HTML", "html" ]
        }]
    }
}

No good. Someone smarter than me?

komali2 commented 7 years ago

Helpful links:

https://code.visualstudio.com/docs/languages/overview https://code.visualstudio.com/docs/customization/colorizer https://code.visualstudio.com/docs/extensionAPI/extension-points#_contributeslanguages

jagretz commented 7 years ago

Adding the file association is a good enough solution for me! Thanks!

"files.associations": {
        "*.hbs": "html"
    }
abusaidm commented 7 years ago

hello,

I am closing this now, as the solution demonstrated resolves this issue.

Thank you all.