13

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

1 Answer 1

26

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

Sign up to request clarification or add additional context in comments.

1 Comment

Worked for me, as have most all your answers.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.