将初始设置写入settings.json

时间:2016-12-01 20:36:25

标签: visual-studio-code vscode-settings vscode-extensions

我正在寻找一种方法,在安装我的扩展程序时将初始设置写入settings.json。

我找到了WorkspaceConfiguration API,但似乎在运行时检索/更新了值。

我希望将我的设置+评论放入默认设置文件

e.g。 TSLint如何做到: enter image description here

1 个答案:

答案 0 :(得分:1)

我希望我能正确理解你的问题:我认为你的意思是用户设置settings.json你可以通过文件>首选项>用户设置获得。

如果您知道TSLint会这样做,您可以转到您的扩展文件夹(windows:$ USERFOLDER / .vscode / extensions),选择扩展名(在我的情况下,它是文件夹“eg2.tslint-0.6.7”并查看文件。

...
"contributes": {
    "configuration": {
        "type": "object",
        "title": "TSLint",
        "properties": {
            "tslint.enable": {
                "type": "boolean",
                "default": true,
                "description": "Control whether tslint is enabled for TypeScript files or not."
            },
            "tslint.rulesDirectory": {
                "type": [
                    "string",
                    "array"
                ],
                "items": {
                    "type": "string"
                },
                "description": "An additional rules directory",
                "default": ""
            },
            "tslint.validateWithDefaultConfig": {
                "type": "boolean",
                "description": "Validate a file when there is only a default tslint configuration is found",
                "default": false
            },
            "tslint.configFile": {
                "type": "string",
                "description": "The path to the rules configuration file",
                "default": ""
            },
            "tslint.ignoreDefinitionFiles": {
                "type": "boolean",
                "default": true,
                "description": "Control if TypeScript definition files should be ignored"
            },
            "tslint.exclude": {
                "type": [
                    "string",
                    "array"
                ],
                "items": {
                    "type": "string"
                },
                "description": "Configure glob patterns of file paths to exclude from linting"
            },
            "tslint.run": {
                "type": "string",
                "enum": [
                    "onSave",
                    "onType"
                ],
                "default": "onType",
                "description": "Run the linter on save (onSave) or on type (onType)"
            },
            "tslint.nodePath": {
                "type": "string",
                "default": "",
                "description": "A path added to NODE_PATH when resolving the tslint module."
            },
            "tslint.autoFixOnSave": {
                "type": "boolean",
                "default": false,
                "description": "Turns auto fix on save on or off."
            }
        }
    }
...

希望这有帮助