Nishkalkashyap / monaco-vscode-textmate-theme-converter

monaco-vscode-textmate-theme-converter
MIT License
54 stars 7 forks source link

Monaco theme `base` field is always `vs-dark` #11

Open wkordalski opened 2 years ago

wkordalski commented 2 years ago

Monaco theme base field is always vs-dark. But, depending on the theme it may be also vs or hc-black (https://github.com/microsoft/vscode/blob/.../src/vs/monaco.d.ts#L1018). We should at least inform users of this library (in README/docs/etc.), that the users of the library should tweak this field by themselves.

This field can be obtained from theme entry in contributes section of package.json file of extension defining the theme. For example, see: https://github.com/microsoft/vscode/blob/.../extensions/theme-defaults/package.json

Kuinox commented 1 year ago

Thanks for the issue ! I wrote some script to automatically set it, but it looks like monaco miss hc-light.

Edit: The commit you reference is old, they added it since: https://github.com/microsoft/vscode/blob/964dc545abd63c5f6f6c42755f1c11c2c912a0b5/src/vs/monaco.d.ts#L1091

Here is my script that download the package.json to correct the converted themes:

const themeObj = {};
const themePackageJson = await (await fetch('https://raw.githubusercontent.com/microsoft/vscode/main/extensions/theme-defaults/package.json')).json();
const themesMetadata = themePackageJson.contributes.themes;

themes.forEach(s => {
    themeObj[s.name] = s.theme;
    themeObj[s.name].base = themesMetadata.find(t=>path.basename(t.path) == s.filename).uiTheme;
    themeObj[s.name].inherit = true;
    if(themeObj[s.name].colors === undefined) {
        themeObj[s.name].colors = {}; // workaround monaco bug: if not set, will throw "Cannot read properties of undefined (reading 'editor.foreground')"
    }
});
connorjclark commented 2 months ago

This is in Python, but I wrote a script that grabs any themes you want from the vs code extensions github, applying the insight Kuinox shared above, plus resolving parent themes by resolving theme myself into one theme (since monaco does not allow you to use custom configs as a base)

https://gist.github.com/connorjclark/07f9d1751eb26490636e50f7e24d42d3

zip attached if someone just wants the results of the handful of themes I converted -

themes.zip