vscode:是否有 api 用于从 vscode 扩展访问配置值
vscode: is there an api for accessing config values from a vscode extension
我正在为 vscode 1.12.2 编写扩展,我正在尝试确定默认主题。 Atom Editor 有一个很好的API for accessing config values,例如:
atom.config.defaultSettings.core.themes[0]
"one-dark-ui"
atom.config.defaultSettings.core.themes[1]
"one-dark-syntax"
在vscode中有类似的东西吗?
我可以在 ~/AppData/Roaming/Code/User/settings.json
中看到值 'workbench.colorTheme':
// "terminal.integrated.shell.windows": "/Program Files/Git/bin/bash.exe"
"terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/k",
"C:\Program Files\Git\bin\bash.exe"
],
"workbench.colorTheme": "Default Light+" <-- here
但是,我宁愿不求助于自定义解决方案,我直接将配置文件读取为 JSON,特别是因为它允许非默认 JSON 值,例如评论,我大概必须预先解析出来。
虽然这个问题狭隘地针对确定主题,但它确实适用于任何配置参数。我在 vscode html api 或浏览打字文件 /c/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/vscode.d.ts
中没有看到任何内容
你试过了吗:
const workbenchConfig = vscode.workspace.getConfiguration('workbench')
const theme = workbenchConfig.get('colorTheme')
这是配置对象的文档:https://code.visualstudio.com/docs/extensionAPI/vscode-api#WorkspaceConfiguration
我正在为 vscode 1.12.2 编写扩展,我正在尝试确定默认主题。 Atom Editor 有一个很好的API for accessing config values,例如:
atom.config.defaultSettings.core.themes[0]
"one-dark-ui"
atom.config.defaultSettings.core.themes[1]
"one-dark-syntax"
在vscode中有类似的东西吗?
我可以在 ~/AppData/Roaming/Code/User/settings.json
中看到值 'workbench.colorTheme':
// "terminal.integrated.shell.windows": "/Program Files/Git/bin/bash.exe"
"terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/k",
"C:\Program Files\Git\bin\bash.exe"
],
"workbench.colorTheme": "Default Light+" <-- here
但是,我宁愿不求助于自定义解决方案,我直接将配置文件读取为 JSON,特别是因为它允许非默认 JSON 值,例如评论,我大概必须预先解析出来。
虽然这个问题狭隘地针对确定主题,但它确实适用于任何配置参数。我在 vscode html api 或浏览打字文件 /c/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/vscode.d.ts
你试过了吗:
const workbenchConfig = vscode.workspace.getConfiguration('workbench')
const theme = workbenchConfig.get('colorTheme')
这是配置对象的文档:https://code.visualstudio.com/docs/extensionAPI/vscode-api#WorkspaceConfiguration