2016-12-01 26 views
1

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

我发现WorkspaceConfiguration API,但似乎在运行时检索/更新值。

我在寻找我的设置+评论到默认设置文件中

例如, TSLint如何做到这一点: enter image description here

回答

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." 
      } 
     } 
    } 
... 

希望这有助于