I am writing an extension for vscode 1.12.2 and I am trying to determine the default theme. Atom Editor has a nice API for accessing config values, e.g.:
atom.config.defaultSettings.core.themes[0]
"one-dark-ui"
atom.config.defaultSettings.core.themes[1]
"one-dark-syntax"
Is there something similar to this in vscode?
I can see the value 'workbench.colorTheme' in ~/AppData/Roaming/Code/User/settings.json
:
// "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
However, I'd rather not resort to a custom solution whereby I directly read the config file as JSON, especially since it allows non-default JSON values such as comments, which I would presumably have to pre-parse-out.
While this question is narrowly directed at determining the theme, it really applies to any config parm. I didn't see anything in the vscode html api or in browsing the typings file /c/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/vscode.d.ts
To open the Settings editor, use the following VS Code menu command: On Windows/Linux - File > Preferences > Settings. On macOS - Code > Preferences > Settings.
The workspace settings file is located under the . vscode folder in your project.
You can turn on Settings Sync using the Turn On Settings Sync... entry in the Manage gear menu at the bottom of the Activity Bar. You will be asked to sign in and what preferences you would like to sync; currently Settings, Keyboard Shortcuts, Extensions, User Snippets, and UI State are supported.
This extension opens a browser preview for the editor to the side. This example shows VS Code Web being developed right inside VS Code. A Webview panel is used to render a browser-like window.
Did you try:
const workbenchConfig = vscode.workspace.getConfiguration('workbench')
const theme = workbenchConfig.get('colorTheme')
Here's the documentation on the configuration object: https://code.visualstudio.com/docs/extensionAPI/vscode-api#WorkspaceConfiguration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With