So I accidentally managed (thanks to some help from ChatGPT) to write a sublime plugin that categorizes all color schemes into light and dark, and lists them in 2 separate lists in command palette.
There is only one small issue:
I load both .sublime-color-scheme
and .tmTheme
and parse them manually (as json and xml respectively). However, the background that I get from them is not always what sublime displays. That’s for 3 reasons.
- Sometimes it’s a variable (I hacked a workaround where I just regex match certain common colors, that are typically used in the var name).
- Sometimes it’s a calculation / formula.
- Sometimes there are multiple mentions of the background in the tmTheme file. I tried getting the first instance, and the last instance, but sometimes Sublime seems to pick neither when you set the theme.
My question is: is there a way to reliably get the resolved main background color (in hex) as sublime would actually apply it? Any help much appreciated.