Skip to content

Instantly share code, notes, and snippets.

@adamdriscoll
Created December 22, 2018 10:01
Show Gist options
  • Save adamdriscoll/dc14d6e35b73909e436bb778e93c57b7 to your computer and use it in GitHub Desktop.
Save adamdriscoll/dc14d6e35b73909e436bb778e93c57b7 to your computer and use it in GitHub Desktop.
Access VS Code's theme colors programmatically
import stripJsonComments = require('strip-json-comments');
var workbenchSettings = vscode.workspace.getConfiguration("workbench");
var theme = workbenchSettings.colorTheme;
var themePath = null;
var extension = vscode.extensions.all.find(x => {
var extensionTheme = x.packageJSON.contributes.themes && x.packageJSON.contributes.themes.find(y => {
return y.label === theme;
});
if (extensionTheme != null) {
themePath = extensionTheme.path;
return true;
}
return false;
});
themePath = path.join(extension.extensionPath, themePath);
fs.readFile(themePath, (error, data) => {
var themeInfo = JSON.parse(stripJsonComments(data.toString()));
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment