We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
每一个插件都可以自行添加首选项的配置,当打开 vscode 时,根据首选项选择的配置,执行不同的逻辑,接下来说说如何实现此效果
vscode
我们现在 package.json 中配置一下我们首选项参数
package.json
{ "contributes": { "configuration": { "title": "sugar-demo-vscod", "properties": { "sugar-demo-vscode.matchConfig": { "type": "string", "description": "sugar-demo-vscod 配置,默认低配版本", "enum": [ "lowMatch", "middleMatch", "highMatch" ], "default": "lowMatch", "scope": "window" } } } } }
这里需要注意,名称 sugar-demo-vscode 要一致!
sugar-demo-vscode
上面我们已经实现了首选项配置,看看效果
我们再获取配置,然后执行不同逻辑
// 获取用户配置的版本设置 const matchConfig = vscode.workspace.getConfiguration().get('vscode-beehive-extension.matchConfig') if (matchConfig === MATCH_CONFIG_MAPS.LOW) { console.log('低配') } else if (matchConfig === MATCH_CONFIG_MAPS.MIDDLE) { console.log('中配') } else if (matchConfig === MATCH_CONFIG_MAPS.HIGH) { console.log('高配') } else { vscode.window.showErrorMessage(`unknown error`) }
如果要通过代码修改 matchConfig 内容,可以通过
// 最后一个参数,为true时表示写入全局配置,为false或不传时则只写入工作区配置 vscode.workspace.getConfiguration().update('vscode-beehive-extension.matchConfig', 'middleMatch, true);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
场景
每一个插件都可以自行添加首选项的配置,当打开
vscode
时,根据首选项选择的配置,执行不同的逻辑,接下来说说如何实现此效果代码展示
我们现在
package.json
中配置一下我们首选项参数这里需要注意,名称
sugar-demo-vscode
要一致!上面我们已经实现了首选项配置,看看效果
我们再获取配置,然后执行不同逻辑
如果要通过代码修改 matchConfig 内容,可以通过
源码展示
The text was updated successfully, but these errors were encountered: