【问题标题】:Write initial settings to settings.json将初始设置写入 settings.json
【发布时间】:2016-12-01 20:36:25
【问题描述】:

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

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

我希望将我的设置 + cmets 放入默认设置文件中

例如TSLint 是如何做到的:

【问题讨论】:

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


    【解决方案1】:

    我希望我能正确回答您的问题:我假设您的意思是用户设置 settings.json,您可以通过 File>Preferences>User Settings 获得。

    如果您知道 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."
                }
            }
        }
    ...
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-12
      • 2014-02-06
      • 1970-01-01
      • 2016-02-15
      • 2020-05-01
      • 2019-01-23
      • 2011-04-03
      • 2012-11-05
      相关资源
      最近更新 更多