vscode.sh: auto-install a theme's bundled .vsix VS Code extension - #6
Conversation
|
Thanks for adding this. The
Right now: ext="$(jq -r '.extension // empty' "$theme_dir/vscode.json")"
...
if [[ -z "$ext" ]] || ! code --list-extensions 2>/dev/null | grep -Fxq "$ext" || [[ "$(cat "$marker" 2>/dev/null)" != "$sha" ]]; thenIf a theme ships a Recommended fix: treat the extension id as required for the optimized reinstall behavior and skip/warn when it is missing, e.g.: ext="$(jq -r '.extension // empty' "$theme_dir/vscode.json")"
if [[ -z "$ext" ]]; then
warning "VS Code .vsix found but vscode.json has no extension id"
exit 0
fiThen the install condition can just check installed state and sha drift.
I verified the PR head with: bash tests/run.sh
bash tests/vscode-vsix.test.shBoth pass currently, but the standalone |
…stall it A custom-palette theme can't reference a Marketplace id, so it ships its VS Code theme as a `vscode-extension/` source folder. `code --install-extension local.*` fails (not on the Marketplace), so the theme silently never loads. Build a real `.vsix` from that folder and install it; a prebuilt `*.vsix` in the theme dir is still honoured as a fallback. Marketplace ids are left untouched (omarchy-theme- set-vscode installs those, and also always sets `workbench.colorTheme`). Addresses review: - Require an `extension` id for a local theme (warn + skip) so the hook never reinstalls on every theme switch when the id is missing. - De-dupe via installed-state + a sha marker over the SOURCE files (a zip embeds mtimes, so hashing the built .vsix would differ every run). - Fold the behavioural assertions into tests/run.sh (build/install, idempotency, require-ext) and drop the standalone tests/vscode-vsix.test.sh.
ac20ec2 to
296820f
Compare
|
Thanks for the review — addressed both points, and reworked the approach a bit. Build from source instead of a committed binary. The hook now builds the 1. Require an 2. Tests in On install vs. load: this hook only installs (idempotently). Loading — New dependency: |
|
Merged, thank you. The updated version resolves the two review points cleanly: local extensions now require an explicit I also appreciate the switch from committed |
What
Extend the
vscode.shtheme-set hook so that when a theme ships its own VS Code extension bundled as a.vsix, it is installed automatically on theme switch. No behaviour change for themes without a.vsix(Marketplace-id themes are untouched).Why
A theme declares its VS Code theme via
current/theme/vscode.json→ Omarchy runscode --install-extension <id>and setsworkbench.colorTheme. That works for Marketplace ids (e.g.catppuccin.catppuccin-vsc,mvllow.rose-pine). But a theme with a custom palette has no Marketplace match and must bundle its own local extension. Settingextensionto a local id (local.theme-foo) makescode --install-extension local.theme-foofail (not on the Marketplace), so the theme silently never loads. Dropping the extension folder into~/.vscode/extensions/isn't reliable either: VS Code only loads registered extensions, and a failed install leaves the id flagged in~/.vscode/extensions/.obsolete. The only VS Code-native, portable install unit for a local extension is a real.vsixinstalled viacode --install-extension <file>.vsix.How
In the existing
vscode.jsonbranch, if the theme directory contains a*.vsix, install it. Idempotent + sha-aware: reinstall only when the extension is missing or the.vsixcontent changed (sha256 marker), so colour updates are picked up without a version bump and it doesn't reinstall on every switch. The theme directory is resolved from theme-env.sh'sinput_file(config-aware). Uses thesuccess()/warning()helpers.code/jqare already guarded above.Theme-author convention
Ship
vscode-extension/{package.json, themes/<name>-color-theme.json}, avscode.json({"name": "...", "extension": "local.theme-<name>"}), and a prebuilt<name>.vsixat the theme root (so it lands incurrent/theme/on apply). The.vsixneeds novsce/npm — it's a plain zip ofextension.vsixmanifest+[Content_Types].xml+extension/....Tests
tests/vscode-vsix.test.sh— mockscode, covers: no-.vsix(no install), install once, skip when unchanged, reinstall on content change, reinstall when absent. 6/6.tests/run.shstill passes (no regressions).