首页 > 解决方案 > Writing a vscode plugin for adding snippets but only for file composer.json

问题描述

Did you know if it's possible to write a vscode plugin to match only a given file?

My plugin already works but add snippets for all .json files. I wish to be able to add these snippets only if the current file is composer.json.

My current package.json (partial) is:

{
    "contributes": {
        "snippets": [
            {
                "language": "json",
                "path": "./snippets/snippets.code-snippets"
            }
        ]
    }
}

The idea is to be able to having something like:

{
    "contributes": {
        "snippets": [
            {
                "filename": "composer.json",   <-- JUST FOR ILLUSTRATION PURPOSE
                "path": "./snippets/snippets.code-snippets"
            }
        ]
    }
}

Thanks.

标签: visual-studio-codepluginscomposer-phpcode-snippets

解决方案


推荐阅读