从配置文件中读取扩展配置

时间:2019-04-05 17:56:42

标签: visual-studio-code vscode-extensions

请帮助从配置贡献点读取配置值。在${extension_path}\package.json中,我接下来的部分:

{
    "name": "markdown-table-of-contents",
    "displayName": "Generate table of contents for markdown",
    "publisher": "dkultasev",
    "description": "",
    "version": "0.0.1",
    "engines": {
        "vscode": "^1.31.0"
    },
    "categories": [
        "Other"
    ],
    "activationEvents": [
        "onCommand:extension.sqlGenerateYAMLComment"
    ],
    "main": "./out/extension.js",
    "contributes": {
        "configuration": {
            "title": "Default name to use for YAML comment block",
            "properties": {
                "markdown-table-of-contents.author_name": {
                    "type": [
                        "string",
                        "Change Name"
                    ],
                    "default": null,
                    "description": "Specify default name when generating YAML comment block"
                }
            }


        }
...

然后在extension_folder\.vscode\settings.json中设置"markdown-table-of-contents.author_name": "Dmitrij Kultasev",并在扩展代码中尝试获取以下值:

const name = vscode.workspace.getConfiguration('markdown-table-of-contents').get('author_name');

它是Change Name,但我希望Dmitrij Kultasevsettings.json文件中配置

0 个答案:

没有答案