julia-themes-for-vscode
Light and dark VS Code color themes built from the four colors of the Julia logo: blue, green, red and purple. This is a port of julia-themes-for-emacs. The colors are not retyped from it. They are exported from the Emacs themes and converted, so both editors show the same colors.
The themes
| Theme |
Type |
Paper |
Surface (side bar, tabs, widgets) |
Julia Leuven Light |
light |
white #ffffff |
cool gray #f1f3f8 |
Julia Leuven Light Green |
light |
pale green #f1f8f0 |
green wash #e7f2e5 |
Julia Leuven Dark |
dark |
charcoal #1e2028 |
#292d39 |
Color roles
These are the same as in Emacs:
| Construct |
Color |
| keywords, function definitions |
green |
| strings, docstrings |
red |
constants, symbols (:foo), true/nothing |
blue |
| types, variable definitions, parameters |
purple |
| comments |
muted, italic |
macros (@time), decorators |
muted (Emacs's julia-macro-face inherits the preprocessor face) |
| function calls, operators, numbers |
plain text |
| errors / warnings |
blue / purple |
| cursor, focus borders, active tab, status bar |
purple |
| selection |
green tint |
| links |
blue, underlined |
As in Emacs, only function definitions are colored. The Julia grammar scopes every call as support.function.julia, and the themes keep those plain.
Markdown and Org headings cycle green, red, blue, purple through levels 1–6, like org-level-N.
Diff, git and terminal colors
The Emacs themes swap terminal color slots so that ANSI output matches the syntax roles: ANSI red shows as Julia blue, green as red, yellow and magenta as purple, and blue and cyan as green. VS Code's diff and git colors follow the same swaps:
|
Color |
| added lines, untracked files |
red |
| removed lines, deleted files |
blue |
| modified |
purple |
The integrated terminal uses the 16 term-color-* colors from the Emacs themes, so git diff in the terminal looks the same as in the diff editor.
Installation
The extension is not on the Visual Studio Marketplace or Open VSX. You need Node.js for npx:
git clone https://github.com/simoneSantoni/julia-themes-for-vscode.git
cd julia-themes-for-vscode
npx @vscode/vsce package
code --install-extension julia-themes-for-vscode-0.1.0.vsix
If you want to edit the themes, link the clone into the extensions directory instead. Then Developer: Reload Window picks up each rebuild:
ln -s "$PWD" ~/.vscode/extensions/simonesantoni.julia-themes-for-vscode-0.1.0
Choose a theme with Preferences: Color Theme (Ctrl+K Ctrl+T). To follow the OS light/dark setting:
{
"window.autoDetectColorScheme": true,
"workbench.preferredLightColorTheme": "Julia Leuven Light",
"workbench.preferredDarkColorTheme": "Julia Leuven Dark"
}
JuliaMono suits these themes, as it does in Emacs ("editor.fontFamily": "JuliaMono").
How the port works
../julia-themes-for-emacs ──(scripts/dump-faces.el)──▶ faces/*.json ──(scripts/build.mjs)──▶ themes/*.json
scripts/dump-faces.el loads each Emacs theme in batch Emacs. It writes every face the theme sets, about 790 of them with inheritance resolved, to faces/<theme>.json.
- Batch Emacs runs on a terminal frame, where
color-name-to-rgb rounds colors to the 8 tty colors. The script swaps in an exact color parser, so the export matches what a graphical Emacs frame shows.
scripts/build.mjs maps Emacs faces to VS Code keys:
hl-line sets the line highlight, region the selection, isearch find matches, show-paren-match bracket matches, and mode-line the status bar.
- Each
font-lock-* face becomes a TextMate rule named after it.
- Diff and git colors follow the channel swaps described above.
The script checks that its tint formula reproduces the Emacs tints exactly.
To regenerate after changing the Emacs themes (this needs GNU Emacs with its bundled leuven theme):
npm run dump # or: emacs --batch -Q -l scripts/dump-faces.el /path/to/julia-themes-for-emacs
npm run build
npm run check # exits non-zero if themes/ is out of date with faces/
To check which scope or semantic token colors some code, run Developer: Inspect Editor Tokens and Scopes.
License
MIT. See LICENSE.